1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

Parameterize the repository read and write locks

Summary:
Ref T13202. See PHI889. Update the read and write locks to the modern parameterized verison, which handles hashing/normalization and can store better logs.

This parameterized mode was added in D19173 and has been used successfully for some time, but not all locks have switched over to it yet.

Test Plan:
- Added an `fprintf(STDERR, $full_name)` to the lock code.
- Pulled a repository.
- Saw sensible lock name on stdout before "acquired read lock...".
- Additional changes in this patch series will vet this more completely.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13202

Differential Revision: https://secure.phabricator.com/D19701
This commit is contained in:
epriestley 2018-09-23 08:37:26 -07:00
parent 3244324cb1
commit 7db265cd5d

View file

@ -76,18 +76,20 @@ final class PhabricatorRepositoryWorkingCopyVersion
public static function getReadLock($repository_phid, $device_phid) { public static function getReadLock($repository_phid, $device_phid) {
$repository_hash = PhabricatorHash::digestForIndex($repository_phid); $parameters = array(
$device_hash = PhabricatorHash::digestForIndex($device_phid); 'repositoryPHID' => $repository_phid,
$lock_key = "repo.read({$repository_hash}, {$device_hash})"; 'devicePHID' => $device_phid,
);
return PhabricatorGlobalLock::newLock($lock_key); return PhabricatorGlobalLock::newLock('repo.read', $parameters);
} }
public static function getWriteLock($repository_phid) { public static function getWriteLock($repository_phid) {
$repository_hash = PhabricatorHash::digestForIndex($repository_phid); $parameters = array(
$lock_key = "repo.write({$repository_hash})"; 'repositoryPHID' => $repository_phid,
);
return PhabricatorGlobalLock::newLock($lock_key); return PhabricatorGlobalLock::newLock('repo.write', $parameters);
} }