Page MenuHomePhabricator

Phorge GitLab widget generates writes to cache table for task views
Open, MediumPublicBUG REPORT

Description

While investigating T401157, I noticed that the GitLab MR widget generates writes to the cache table (phabricator_caches.general_cache) for task views by way of a locking mechanism to prevent multiple simultaneous requests to the GitLab API for the same search.

Roughly:

$cache = PhabricatorCaches::getMutableCache();
$changes = $cache->getKey($cachekey, null);
if ($changes === "loading") {
  // Data is being loaded by another request / process, avoid hammering GitLab:
  return array();
}
if (! $changes) {
  // Attempt to avoid thundering herd - lock the cache by setting it to
  // "loading" while https request is pending, timeout the cache entry in 5
  // seconds:
  $cache->setKey($cachekey, "loading", 5);

  // etc.
}

Although I'm not sure if it has any bearing on T401157, this is definitely not the smartest thing I've ever done. The getMutableCache() call might be replaceable with a getRuntimeCache() that returns one backed with machine-local APCu, but I'll need to confirm that actually works and is appropriate.

Details

Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
Draft: mr. widget locking: switch to getRuntimeCache()repos/phabricator/extensions!56brennenwork/T401160-mr-widget-cachewmf/stable
Customize query in GitLab