@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 robustness of cluster version bookkeeping

Summary:
Ref T4292. Small fixes:

- There was a bug with the //first// write, where we'd write 1 but expect 0. Fix this.
- Narrow the window where we hold the `isWriting` lock: we don't need to wait for the client to finish.
- Release the lock even if something throws.
- Use a more useful variable name.

Test Plan:
- Made new writes to a fresh cluster repository.
- Made sequential writes.
- Made concurrent writes.
- Made good writes and bad writes.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4292

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

+31 -17
+30 -13
src/applications/diffusion/ssh/DiffusionGitReceivePackSSHWorkflow.php
··· 21 21 22 22 if ($this->shouldProxy()) { 23 23 $command = $this->getProxyCommand(); 24 - $is_proxy = true; 24 + $did_synchronize = false; 25 25 } else { 26 26 $command = csprintf('git-receive-pack %s', $repository->getLocalPath()); 27 - $is_proxy = false; 28 27 28 + $did_synchronize = true; 29 29 $repository->synchronizeWorkingCopyBeforeWrite(); 30 30 } 31 - $command = PhabricatorDaemon::sudoCommandAsDaemonUser($command); 32 31 33 - $future = id(new ExecFuture('%C', $command)) 34 - ->setEnv($this->getEnvironment()); 32 + $caught = null; 33 + try { 34 + $err = $this->executeRepositoryCommand($command); 35 + } catch (Exception $ex) { 36 + $caught = $ex; 37 + } 35 38 36 - $err = $this->newPassthruCommand() 37 - ->setIOChannel($this->getIOChannel()) 38 - ->setCommandChannelFromExecFuture($future) 39 - ->execute(); 39 + // We've committed the write (or rejected it), so we can release the lock 40 + // without waiting for the client to receive the acknowledgement. 41 + if ($did_synchronize) { 42 + $repository->synchronizeWorkingCopyAfterWrite(); 43 + } 44 + 45 + if ($caught) { 46 + throw $caught; 47 + } 40 48 41 49 if (!$err) { 42 50 $repository->writeStatusMessage( ··· 45 53 $this->waitForGitClient(); 46 54 } 47 55 48 - if (!$is_proxy) { 49 - $repository->synchronizeWorkingCopyAfterWrite(); 50 - } 56 + return $err; 57 + } 58 + 59 + private function executeRepositoryCommand($command) { 60 + $repository = $this->getRepository(); 61 + $command = PhabricatorDaemon::sudoCommandAsDaemonUser($command); 62 + 63 + $future = id(new ExecFuture('%C', $command)) 64 + ->setEnv($this->getEnvironment()); 51 65 52 - return $err; 66 + return $this->newPassthruCommand() 67 + ->setIOChannel($this->getIOChannel()) 68 + ->setCommandChannelFromExecFuture($future) 69 + ->execute(); 53 70 } 54 71 55 72 }
-3
src/applications/repository/storage/PhabricatorRepository.php
··· 2410 2410 2411 2411 2412 2412 private function shouldEnableSynchronization() { 2413 - // TODO: This mostly works, but isn't stable enough for production yet. 2414 - return false; 2415 - 2416 2413 $device = AlmanacKeys::getLiveDevice(); 2417 2414 if (!$device) { 2418 2415 return false;
+1 -1
src/applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php
··· 82 82 $table, 83 83 $repository_phid, 84 84 $device_phid, 85 - 1, 85 + 0, 86 86 1); 87 87 } 88 88