@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.

Give Asana feed publishing tasks a less aggressive retry/backoff schedule

Summary:
Ref T2852. Asana sync tasks currently have a standard retry/backoff schedule, but the defaults are quite aggressive (retry every 60s forever). Instead, retry at increasing intervals and stop retrying after a few tries.

- Retry at intervals and stop retrying after a few iterations.
- Modernize some interfaces.
- Add better information about retry behaviors to the web UI.

Test Plan: {F49194}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2852

Differential Revision: https://secure.phabricator.com/D6381

+84 -9
+76 -8
src/applications/daemon/controller/PhabricatorWorkerTaskDetailController.php
··· 41 41 $actions = $this->buildActionListView($task); 42 42 $properties = $this->buildPropertyListView($task); 43 43 44 + $retry_head = id(new PhabricatorHeaderView()) 45 + ->setHeader(pht('Retries')); 46 + 47 + $retry_info = $this->buildRetryListView($task); 48 + 44 49 $content = array( 45 50 $header, 46 51 $actions, 47 52 $properties, 53 + $retry_head, 54 + $retry_info, 48 55 ); 49 56 } 50 57 51 - $nav = $this->buildSideNavView(); 52 - $nav->selectFilter(''); 53 - $nav->appendChild($content); 58 + $crumbs = $this->buildApplicationCrumbs(); 59 + $crumbs->addCrumb( 60 + id(new PhabricatorCrumbView()) 61 + ->setName($title)); 54 62 55 63 return $this->buildApplicationPage( 56 - $nav, 64 + array( 65 + $crumbs, 66 + $content, 67 + ), 57 68 array( 58 69 'title' => $title, 70 + 'dust' => true, 71 + 'device' => true, 59 72 )); 60 73 } 61 74 ··· 161 174 pht('Lease Expires'), 162 175 $expires); 163 176 164 - $view->addProperty( 165 - pht('Failure Count'), 166 - $task->getFailureCount()); 167 - 168 177 if ($task->isArchived()) { 169 178 $duration = number_format($task->getDuration()).' us'; 170 179 } else { ··· 183 192 $view->addProperty( 184 193 pht('Data'), 185 194 $data); 195 + 196 + return $view; 197 + } 198 + 199 + private function buildRetryListView(PhabricatorWorkerTask $task) { 200 + $view = new PhabricatorPropertyListView(); 201 + 202 + $data = id(new PhabricatorWorkerTaskData())->load($task->getDataID()); 203 + $task->setData($data->getData()); 204 + $worker = $task->getWorkerInstance(); 205 + 206 + $view->addProperty( 207 + pht('Failure Count'), 208 + $task->getFailureCount()); 209 + 210 + $retry_count = $worker->getMaximumRetryCount(); 211 + if ($retry_count === null) { 212 + $max_retries = phutil_tag('em', array(), pht('Retries Forever')); 213 + $retry_count = INF; 214 + } else { 215 + $max_retries = $retry_count; 216 + } 217 + 218 + $view->addProperty( 219 + pht('Maximum Retries'), 220 + $max_retries); 221 + 222 + $projection = clone $task; 223 + $projection->makeEphemeral(); 224 + 225 + $next = array(); 226 + for ($ii = $task->getFailureCount(); $ii < $retry_count; $ii++) { 227 + $projection->setFailureCount($ii); 228 + $next[] = $worker->getWaitBeforeRetry($projection); 229 + if (count($next) > 10) { 230 + break; 231 + } 232 + } 233 + 234 + if ($next) { 235 + $cumulative = 0; 236 + foreach ($next as $key => $duration) { 237 + if ($duration === null) { 238 + $duration = 60; 239 + } 240 + $cumulative += $duration; 241 + $next[$key] = phabricator_format_relative_time($cumulative); 242 + } 243 + if ($ii != $retry_count) { 244 + $next[] = '...'; 245 + } 246 + $retries_in = implode(', ', $next); 247 + } else { 248 + $retries_in = pht('No More Retries'); 249 + } 250 + 251 + $view->addProperty( 252 + pht('Retries After'), 253 + $retries_in); 186 254 187 255 return $view; 188 256 }
+8
src/applications/doorkeeper/worker/DoorkeeperFeedWorkerAsana.php
··· 602 602 return $ref; 603 603 } 604 604 605 + public function getMaximumRetryCount() { 606 + return 4; 607 + } 608 + 609 + public function getWaitBeforeRetry(PhabricatorWorkerTask $task) { 610 + $count = $task->getFailureCount(); 611 + return (5 * 60) * pow(8, $count); 612 + } 605 613 606 614 }
-1
src/infrastructure/daemon/workers/PhabricatorWorker.php
··· 59 59 * retries, or to examine the execution 60 60 * exception if you want to react to 61 61 * different failures in different ways. 62 - * @param Exception The exception which caused the failure. 63 62 * @return int|null Number of seconds to wait between retries, 64 63 * or null for a default retry period 65 64 * (currently 60 seconds).