Page MenuHomePhabricator

D16739.id40313.diff
No OneTemporary

D16739.id40313.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
Oct 19 2024, 2:02 AM (4 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6729762
Default Alt Text
D16739.id40313.diff (925 B)

Event Timeline