Make query engines "overheat" instead of stalling when filtering too many results

Summary: Ref T11773. This is an initial first step toward a more complete solution, but should make the worst case much less bad: prior to this change, the worst case was "30 second exeuction timeout". After this patch, the worst case is "no results + explanatory message", which is strictly better.

Test Plan:
Made all feed stories fail policy checks, loaded home page.

  - Before adding overheating: 9,600 queries / 20 seconds
  - After adding overheating: 376 queries / 800ms

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11773

Differential Revision: https://secure.phabricator.com/D16735
This commit is contained in:
epriestley
2016-10-20 08:33:27 -07:00
parent a00e867de0
commit a3253f78ce
2 changed files with 54 additions and 0 deletions

View File

@@ -238,6 +238,8 @@ final class PhabricatorApplicationSearchController
$nux_view = null;
}
$is_overheated = $query->getIsOverheated();
if ($nux_view) {
$box->appendChild($nux_view);
} else {
@@ -265,6 +267,10 @@ final class PhabricatorApplicationSearchController
$box->appendChild($list->getContent());
}
if ($is_overheated) {
$box->appendChild($this->newOverheatedView($objects));
}
$result_header = $list->getHeader();
if ($result_header) {
$box->setHeader($result_header);
@@ -525,4 +531,27 @@ final class PhabricatorApplicationSearchController
->setDropdownMenu($action_list);
}
private function newOverheatedView(array $results) {
if ($results) {
$message = pht(
'Most objects matching your query are not visible to you, so '.
'filtering results is taking a long time. Only some results are '.
'shown. Refine your query to find results more quickly.');
} else {
$message = pht(
'Most objects matching your query are not visible to you, so '.
'filtering results is taking a long time. Refine your query to '.
'find results more quickly.');
}
return id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_WARNING)
->setFlush(true)
->setTitle(pht('Query Overheated'))
->setErrors(
array(
$message,
));
}
}