make Trigger Daemon sleep correctly when one-time triggers exist
Summary: Trigger daemon is trying to find the next event to invoke before sleeping, but the query includes already-elapsed triggers. It then tries to sleep for 0 seconds. Test Plan: On a new instance, schedule a single trigger of type `PhabricatorOneTimeTriggerClock` to a very near time. Use top to see trigger daemon not going to 100% CPU once the event has elapsed. Reviewers: #blessed_reviewers, epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D15750
This commit is contained in:
@@ -261,7 +261,7 @@ final class PhabricatorTriggerDaemon
|
|||||||
* Get the number of seconds to sleep for before starting the next scheduling
|
* Get the number of seconds to sleep for before starting the next scheduling
|
||||||
* phase.
|
* phase.
|
||||||
*
|
*
|
||||||
* If no events are scheduled soon, we'll sleep for 60 seconds. Otherwise,
|
* If no events are scheduled soon, we'll sleep briefly. Otherwise,
|
||||||
* we'll sleep until the next scheduled event.
|
* we'll sleep until the next scheduled event.
|
||||||
*
|
*
|
||||||
* @return int Number of seconds to sleep for.
|
* @return int Number of seconds to sleep for.
|
||||||
@@ -272,6 +272,7 @@ final class PhabricatorTriggerDaemon
|
|||||||
$next_triggers = id(new PhabricatorWorkerTriggerQuery())
|
$next_triggers = id(new PhabricatorWorkerTriggerQuery())
|
||||||
->setViewer($this->getViewer())
|
->setViewer($this->getViewer())
|
||||||
->setOrder(PhabricatorWorkerTriggerQuery::ORDER_EXECUTION)
|
->setOrder(PhabricatorWorkerTriggerQuery::ORDER_EXECUTION)
|
||||||
|
->withNextEventBetween(0, null)
|
||||||
->setLimit(1)
|
->setLimit(1)
|
||||||
->needEvents(true)
|
->needEvents(true)
|
||||||
->execute();
|
->execute();
|
||||||
|
|||||||
Reference in New Issue
Block a user