1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 03:50:54 +01:00

Scope "in-flight" PHIDs more carefully

Fixes T8125. In Feed, we query for a bunch of objects and also a bunch of transactions.

The transactions require the objects. Normally, whichever executes last will fill out of the Workspace cheaply, so this query strategy is fine overall.

The new "in-flight" code would mark everything in flight before the transactions loaded, though, so they'd fail to load even though the query plan is not cyclic.

Instead, be more surgical and mark things in flight only immediately before we put them in flight.

Test Plan: Feed now shows more stories again; files with cycles still load in finite time.

Auditors: btrahan
This commit is contained in:
epriestley 2015-05-07 21:10:43 -07:00
parent f3d76a90f0
commit 528f1a9744

View file

@ -104,16 +104,6 @@ final class PhabricatorObjectQuery
} }
private function loadObjectsByPHID(array $types, array $phids) { private function loadObjectsByPHID(array $types, array $phids) {
// Don't try to load PHIDs which are already "in flight"; this prevents us
// from recursing indefinitely if policy checks or edges form a loop. We
// will decline to load the corresponding objects.
$in_flight = $this->getPHIDsInFlight();
foreach ($phids as $key => $phid) {
if (isset($in_flight[$phid])) {
unset($phids[$key]);
}
}
$results = array(); $results = array();
$workspace = $this->getObjectsFromWorkspace($phids); $workspace = $this->getObjectsFromWorkspace($phids);
@ -129,16 +119,25 @@ final class PhabricatorObjectQuery
return $results; return $results;
} }
$this->putPHIDsInFlight($phids);
$groups = array(); $groups = array();
foreach ($phids as $phid) { foreach ($phids as $phid) {
$type = phid_get_type($phid); $type = phid_get_type($phid);
$groups[$type][] = $phid; $groups[$type][] = $phid;
} }
$in_flight = $this->getPHIDsInFlight();
foreach ($groups as $type => $group) { foreach ($groups as $type => $group) {
if (isset($types[$type])) { // Don't try to load PHIDs which are already "in flight"; this prevents
// us from recursing indefinitely if policy checks or edges form a loop.
// We will decline to load the corresponding objects.
foreach ($group as $key => $phid) {
if (isset($in_flight[$phid])) {
unset($group[$key]);
}
}
if ($group && isset($types[$type])) {
$this->putPHIDsInFlight($group);
$objects = $types[$type]->loadObjects($this, $group); $objects = $types[$type]->loadObjects($this, $group);
$results += mpull($objects, null, 'getPHID'); $results += mpull($objects, null, 'getPHID');
} }