Page MenuHomePhabricator

D16739.diff
No OneTemporary

D16739.diff

diff --git a/src/infrastructure/daemon/garbagecollector/PhabricatorGarbageCollector.php b/src/infrastructure/daemon/garbagecollector/PhabricatorGarbageCollector.php
--- a/src/infrastructure/daemon/garbagecollector/PhabricatorGarbageCollector.php
+++ b/src/infrastructure/daemon/garbagecollector/PhabricatorGarbageCollector.php
@@ -98,7 +98,27 @@
}
}
- return $this->collectGarbage();
+ // Hold a lock while performing collection to avoid racing other daemons
+ // running the same collectors.
+ $lock_name = 'gc:'.$this->getCollectorConstant();
+ $lock = PhabricatorGlobalLock::newLock($lock_name);
+
+ try {
+ $lock->lock(5);
+ } catch (PhutilLockException $ex) {
+ return false;
+ }
+
+ try {
+ $result = $this->collectGarbage();
+ } catch (Exception $ex) {
+ $lock->unlock();
+ throw $ex;
+ }
+
+ $lock->unlock();
+
+ return $result;
}

File Metadata

Mime Type
text/plain
Expires
Sep 18 2025, 1:49 AM (14 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
9095871
Default Alt Text
D16739.diff (925 B)

Event Timeline