@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+17 -6
+17 -6
src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php
··· 77 77 78 78 // If any repositories have the NEEDS_UPDATE flag set, pull them 79 79 // as soon as possible. 80 - $need_update_messages = $this->loadRepositoryUpdateMessages(); 80 + $need_update_messages = $this->loadRepositoryUpdateMessages(true); 81 81 foreach ($need_update_messages as $message) { 82 82 $repo = idx($pullable, $message->getRepositoryID()); 83 83 if (!$repo) { ··· 256 256 257 257 258 258 /** 259 + * Check for repositories that should be updated immediately. 260 + * 261 + * With the `$consume` flag, an internal cursor will also be incremented so 262 + * that these messages are not returned by subsequent calls. 263 + * 264 + * @param bool Pass `true` to consume these messages, so the process will 265 + * not see them again. 266 + * @return list<wild> Pending update messages. 267 + * 259 268 * @task pull 260 269 */ 261 - private function loadRepositoryUpdateMessages() { 270 + private function loadRepositoryUpdateMessages($consume = false) { 262 271 $type_need_update = PhabricatorRepositoryStatusMessage::TYPE_NEEDS_UPDATE; 263 272 $messages = id(new PhabricatorRepositoryStatusMessage())->loadAllWhere( 264 273 'statusType = %s AND id > %d', ··· 272 281 // immediately retry. Instead, messages are only permitted to trigger 273 282 // an immediate update once. 274 283 275 - foreach ($messages as $message) { 276 - $this->statusMessageCursor = max( 277 - $this->statusMessageCursor, 278 - $message->getID()); 284 + if ($consume) { 285 + foreach ($messages as $message) { 286 + $this->statusMessageCursor = max( 287 + $this->statusMessageCursor, 288 + $message->getID()); 289 + } 279 290 } 280 291 281 292 return $messages;