1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 12:30:56 +01:00

Do not perform write in PhabricatorDaemonLogQuery by default

Summary:
See <http://github.com/facebook/phabricator/issues/487>. By default, we perform a write in this query to moved daemons to "dead" status after a timeout. This is normally reasonable, but after D7964 we do a setup check against the daemons, which means this query is invoked very early in the stack, before we have a write guard.

Since doing this write unconditionally is unnecessarily, surprising, and overly ambitious, make the write conditional and do not attempt to perform it from the setup check.

(We could also move this to a GC/cron sort of thing eventually, maybe -- it's a bit awkward here, but we don't have other infrastructure which is a great fit right now.)

Test Plan: Hit setup issues and daemon pages. Will confirm with user that this fixes things.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D8023
This commit is contained in:
epriestley 2014-01-21 14:04:12 -08:00
parent 56bcb33a18
commit 136af8d2ab
5 changed files with 19 additions and 4 deletions

View file

@ -73,6 +73,7 @@ final class PhabricatorDaemonConsoleController
$logs = id(new PhabricatorDaemonLogQuery())
->setViewer($user)
->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE)
->setAllowStatusWrites(true)
->execute();
$taskmasters = 0;

View file

@ -12,6 +12,7 @@ final class PhabricatorDaemonLogListController
$logs = id(new PhabricatorDaemonLogQuery())
->setViewer($viewer)
->setAllowStatusWrites(true)
->executeWithCursorPager($pager);
$daemon_table = new PhabricatorDaemonLogListView();

View file

@ -16,6 +16,7 @@ final class PhabricatorDaemonLogViewController
$log = id(new PhabricatorDaemonLogQuery())
->setViewer($user)
->withIDs(array($this->id))
->setAllowStatusWrites(true)
->executeOne();
if (!$log) {
return new Aphront404Response();

View file

@ -34,6 +34,7 @@ final class PhabricatorDaemonManagementLogWorkflow
$daemon = id(new PhabricatorDaemonLogQuery())
->setViewer($this->getViewer())
->withIDs(array($id))
->setAllowStatusWrites(true)
->executeOne();
if (!$daemon) {

View file

@ -9,6 +9,7 @@ final class PhabricatorDaemonLogQuery
private $ids;
private $status = self::STATUS_ALL;
private $daemonClasses;
private $allowStatusWrites;
public static function getTimeUntilUnknown() {
return 3 * PhutilDaemonOverseer::HEARTBEAT_WAIT;
@ -33,6 +34,11 @@ final class PhabricatorDaemonLogQuery
return $this;
}
public function setAllowStatusWrites($allow) {
$this->allowStatusWrites = $allow;
return $this;
}
public function loadPage() {
$table = new PhabricatorDaemonLog();
$conn_r = $table->establishConnection('r');
@ -80,11 +86,16 @@ final class PhabricatorDaemonLogQuery
$status = $status_dead;
}
// If we changed the daemon's status, update it.
// If we changed the daemon's status, adjust it.
if ($status != $daemon->getStatus()) {
$guard = AphrontWriteGuard::beginScopedUnguardedWrites();
$daemon->setStatus($status)->save();
unset($guard);
$daemon->setStatus($status);
// ...and write it, if we're in a context where that's reasonable.
if ($this->allowStatusWrites) {
$guard = AphrontWriteGuard::beginScopedUnguardedWrites();
$daemon->save();
unset($guard);
}
}
// If the daemon no longer matches the filter, get rid of it.