From 7db265cd5da532e8c3f1936702ce7fc0e5ee28a4 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 23 Sep 2018 08:37:26 -0700 Subject: [PATCH] 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 --- .../PhabricatorRepositoryWorkingCopyVersion.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php b/src/applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php index da5d54b57d..e297dfbf0e 100644 --- a/src/applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php +++ b/src/applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php @@ -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); }