DefaultCacheAccessTest.groovy

Clone Tools
  • last updated a few seconds ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
Ensure file lock is released before cache cleanup

Caches with on-demand locking keep hold of file locks unless contended

by other Gradle processes. Prior to this commit, such previously

acquired file locks were held for the complete duration of cache

cleanup only to be released immediately afterwards. While cache cleanup

was running, requests to release such file locks from other processes

(via `DefaultFileLockContentionHandler`) were not processed because the

`stateLock` of `DefaultCacheAccess` was already locked by another

thread and thus, the `ContentionAction` in

`LockOnDemandCrossProcessCacheAccess` was blocked until the `close()`

method in `DefaultCacheAccess` was finished.

Since cache cleanup only deletes files that are no longer in use, it

does not use file locking (which would not work anyway because the

current cache access infrastructure is not usable while the cache is

already being closed). Thus, this commit closes the

`CrossProcessCacheAccess` of the `DefaultCacheAccess` *before* cleaning

up caches.

Issue: gradle/gradle-private#1412

  1. … 1 more file in changeset.
Improve file lock contention handling

This commit improves the likelihood for lock requesters to acquire a

file lock after it is released due to contention. After the lock has

been released, the former lock holder now sends a packet to the sockets

of all requesters. While old clients will simply ignore the additional

packet, new clients will interpret it as a signal that the file lock has

been released and will try to acquire it immediately.

Issue: gradle/gradle-private#1412.

  1. … 14 more files in changeset.
Provide an empty contended action instead of null

This contention handling is already active for exclusive locks, but

without an action it is ignoring requests from other parties.

With this, it sends confirmation that the request was received

and that lock releasing is in progress. Although the release itself

is not performed by the contended action, but manually after the

lock is no longer needed (which is the contract for exclusive locks).

  1. … 2 more files in changeset.
Start whenContented action before waiting for the lock

The action is now also responsible for receiving confirmation that the

lock is in the process of being released.

  1. … 5 more files in changeset.
Move org.gradle.cache.internal to persistent-cache project

+review REVIEW-6562

    • -0
    • +729
    ./DefaultCacheAccessTest.groovy
  1. … 184 more files in changeset.