@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.

Hold a lock while collecting garbage

Summary:
Fixes T11771. Adds a lock around each GC process so we don't try to, e.g., delete old files on two machines at once just because they're both running trigger daemons.

The other aspects of this daemon (actual triggers; nuance importers) already have separate locks.

Test Plan: Ran `bin/phd debug trigger --trace`, saw daemon acquire locks and collect garbage.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11771

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

+21 -1
+21 -1
src/infrastructure/daemon/garbagecollector/PhabricatorGarbageCollector.php
··· 98 98 } 99 99 } 100 100 101 - return $this->collectGarbage(); 101 + // Hold a lock while performing collection to avoid racing other daemons 102 + // running the same collectors. 103 + $lock_name = 'gc:'.$this->getCollectorConstant(); 104 + $lock = PhabricatorGlobalLock::newLock($lock_name); 105 + 106 + try { 107 + $lock->lock(5); 108 + } catch (PhutilLockException $ex) { 109 + return false; 110 + } 111 + 112 + try { 113 + $result = $this->collectGarbage(); 114 + } catch (Exception $ex) { 115 + $lock->unlock(); 116 + throw $ex; 117 + } 118 + 119 + $lock->unlock(); 120 + 121 + return $result; 102 122 } 103 123 104 124