@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve messaging around repository locks

Summary:
Fixes T6958. Ref T7484.

- When we collide on a lock in `bin/repository update`, explain what that means.
- GlobalLock currently uses a "lock name" which is different from the lock's actual name. Don't do this. There's a small chance this fixes T7484, but I don't have high hopes.

Test Plan: Ran `bin/repository update X` in two windows really fast, got the new message in one of them.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T6958, T7484

Differential Revision: https://secure.phabricator.com/D12574

+18 -6
+15 -1
src/applications/repository/management/PhabricatorRepositoryManagementUpdateWorkflow.php
··· 56 56 $lock_name = 'repository.update:'.$repository->getID(); 57 57 $lock = PhabricatorGlobalLock::newLock($lock_name); 58 58 59 - $lock->lock(); 59 + try { 60 + $lock->lock(); 61 + } catch (PhutilLockException $ex) { 62 + throw new PhutilProxyException( 63 + pht( 64 + 'Another process is currently holding the update lock for '. 65 + 'repository "%s". Repositories may only be updated by one '. 66 + 'process at a time. This can happen if you are running multiple '. 67 + 'copies of the daemons. This can also happen if you manually '. 68 + 'update a repository while the daemons are also updating it '. 69 + '(in this case, just try again in a few moments).', 70 + $repository->getMonogram()), 71 + $ex); 72 + } 73 + 60 74 try { 61 75 $no_discovery = $args->getArg('no-discovery'); 62 76
+3 -5
src/infrastructure/util/PhabricatorGlobalLock.php
··· 28 28 */ 29 29 final class PhabricatorGlobalLock extends PhutilLock { 30 30 31 - private $lockname; 32 31 private $conn; 33 32 34 33 private static $pool = array(); ··· 41 40 $namespace = PhabricatorLiskDAO::getStorageNamespace(); 42 41 $namespace = PhabricatorHash::digestToLength($namespace, 20); 43 42 44 - $full_name = $namespace.'-g:'.$name; 43 + $full_name = 'ph:'.$namespace.':'.$name; 45 44 46 45 $length_limit = 64; 47 46 if (strlen($full_name) > $length_limit) { ··· 57 56 $lock = self::getLock($full_name); 58 57 if (!$lock) { 59 58 $lock = new PhabricatorGlobalLock($full_name); 60 - $lock->lockname = $name; 61 59 self::registerLock($lock); 62 60 } 63 61 ··· 99 97 $result = queryfx_one( 100 98 $conn, 101 99 'SELECT GET_LOCK(%s, %f)', 102 - 'phabricator:'.$this->lockname, 100 + $this->getName(), 103 101 $wait); 104 102 105 103 $ok = head($result); ··· 114 112 queryfx( 115 113 $this->conn, 116 114 'SELECT RELEASE_LOCK(%s)', 117 - 'phabricator:'.$this->lockname); 115 + $this->getName()); 118 116 119 117 $this->conn->close(); 120 118 self::$pool[] = $this->conn;