mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 12:30:56 +01:00
Only increment status message cursor if we're going to consume the message
Summary: Fixes the long uptake we saw on `meta.phacility.com`. I regressed this in D11795. We make three calls to this method, but only one actually consumes the messages. The other two are just checking to see if there are any messages. Only move the cursor up if we're actually going to process the messages. Test Plan: Sort of tricky to test convincingly since it's inherently race-prone, but ran `debug pulllocal` and pushed update messages and saw it pick them up. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D11808
This commit is contained in:
parent
6a8f31a0ec
commit
dd96967306
1 changed files with 17 additions and 6 deletions
|
@ -77,7 +77,7 @@ final class PhabricatorRepositoryPullLocalDaemon
|
|||
|
||||
// If any repositories have the NEEDS_UPDATE flag set, pull them
|
||||
// as soon as possible.
|
||||
$need_update_messages = $this->loadRepositoryUpdateMessages();
|
||||
$need_update_messages = $this->loadRepositoryUpdateMessages(true);
|
||||
foreach ($need_update_messages as $message) {
|
||||
$repo = idx($pullable, $message->getRepositoryID());
|
||||
if (!$repo) {
|
||||
|
@ -256,9 +256,18 @@ final class PhabricatorRepositoryPullLocalDaemon
|
|||
|
||||
|
||||
/**
|
||||
* Check for repositories that should be updated immediately.
|
||||
*
|
||||
* With the `$consume` flag, an internal cursor will also be incremented so
|
||||
* that these messages are not returned by subsequent calls.
|
||||
*
|
||||
* @param bool Pass `true` to consume these messages, so the process will
|
||||
* not see them again.
|
||||
* @return list<wild> Pending update messages.
|
||||
*
|
||||
* @task pull
|
||||
*/
|
||||
private function loadRepositoryUpdateMessages() {
|
||||
private function loadRepositoryUpdateMessages($consume = false) {
|
||||
$type_need_update = PhabricatorRepositoryStatusMessage::TYPE_NEEDS_UPDATE;
|
||||
$messages = id(new PhabricatorRepositoryStatusMessage())->loadAllWhere(
|
||||
'statusType = %s AND id > %d',
|
||||
|
@ -272,10 +281,12 @@ final class PhabricatorRepositoryPullLocalDaemon
|
|||
// immediately retry. Instead, messages are only permitted to trigger
|
||||
// an immediate update once.
|
||||
|
||||
foreach ($messages as $message) {
|
||||
$this->statusMessageCursor = max(
|
||||
$this->statusMessageCursor,
|
||||
$message->getID());
|
||||
if ($consume) {
|
||||
foreach ($messages as $message) {
|
||||
$this->statusMessageCursor = max(
|
||||
$this->statusMessageCursor,
|
||||
$message->getID());
|
||||
}
|
||||
}
|
||||
|
||||
return $messages;
|
||||
|
|
Loading…
Reference in a new issue