Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/worker/PhabricatorSearchWorker.php
Show All 32 Lines | protected function doWork() { | ||||
if (!$engine->shouldIndexObject()) { | if (!$engine->shouldIndexObject()) { | ||||
return; | return; | ||||
} | } | ||||
$key = "index.{$object_phid}"; | $key = "index.{$object_phid}"; | ||||
$lock = PhabricatorGlobalLock::newLock($key); | $lock = PhabricatorGlobalLock::newLock($key); | ||||
try { | |||||
$lock->lock(1); | $lock->lock(1); | ||||
} catch (PhutilLockException $ex) { | |||||
// If we fail to acquire the lock, just yield. It's expected that we may | |||||
// contend on this lock occasionally if a large object receives many | |||||
// updates in a short period of time, and it's appropriate to just retry | |||||
// rebuilding the index later. | |||||
throw new PhabricatorWorkerYieldException(15); | |||||
amckinley: I guess doing anything more complicated like exponential backoff would be overkill, and this at… | |||||
} | |||||
try { | try { | ||||
// Reload the object now that we have a lock, to make sure we have the | // Reload the object now that we have a lock, to make sure we have the | ||||
// most current version. | // most current version. | ||||
$object = $this->loadObjectForIndexing($object->getPHID()); | $object = $this->loadObjectForIndexing($object->getPHID()); | ||||
$engine->setObject($object); | $engine->setObject($object); | ||||
Show All 37 Lines |
I guess doing anything more complicated like exponential backoff would be overkill, and this at least ensures the indexing will happen within 15 seconds of the update torrent from stopping.