1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52: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) {
$repository_hash = PhabricatorHash::digestForIndex($repository_phid);
$device_hash = PhabricatorHash::digestForIndex($device_phid);
$lock_key = "repo.read({$repository_hash}, {$device_hash})";
$parameters = array(
'repositoryPHID' => $repository_phid,
'devicePHID' => $device_phid,
);
return PhabricatorGlobalLock::newLock($lock_key);
return PhabricatorGlobalLock::newLock('repo.read', $parameters);
}
public static function getWriteLock($repository_phid) {
$repository_hash = PhabricatorHash::digestForIndex($repository_phid);
$lock_key = "repo.write({$repository_hash})";
$parameters = array(
'repositoryPHID' => $repository_phid,
);
return PhabricatorGlobalLock::newLock($lock_key);
return PhabricatorGlobalLock::newLock('repo.write', $parameters);
}