From 0630fef9fc3692ad233e9dfebf63ea1e06a48e55 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 26 Apr 2016 05:14:20 -0700 Subject: [PATCH] Prevent web queries from running for more than 30 seconds Summary: Ref T10849. This enforces a global 30-second per-query time limit for anything not coming from the CLI. If we run into another issue with MySQL hanging in the future, this should prevent it from being nearly as bad as it was. Test Plan: - Set value to 0, verified the UI threw an exception immediately. - Set value back to 30, browsed around a bunch of pages. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10849 Differential Revision: https://secure.phabricator.com/D15799 --- src/infrastructure/storage/lisk/PhabricatorLiskDAO.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/infrastructure/storage/lisk/PhabricatorLiskDAO.php b/src/infrastructure/storage/lisk/PhabricatorLiskDAO.php index 610bc06f59..1a51467089 100644 --- a/src/infrastructure/storage/lisk/PhabricatorLiskDAO.php +++ b/src/infrastructure/storage/lisk/PhabricatorLiskDAO.php @@ -75,6 +75,12 @@ abstract class PhabricatorLiskDAO extends LiskDAO { $connection->setReadOnly(true); } + // Unless this is a script running from the CLI, prevent any query from + // running for more than 30 seconds. See T10849 for discussion. + if (php_sapi_name() != 'cli') { + $connection->setQueryTimeout(30); + } + return $connection; }