From 4d13b6c6a8c07ee4e5c7469cbb9e76836a205eeb Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 30 Oct 2015 12:06:47 -0700 Subject: [PATCH] Add a setup warning for major clock skew issues Summary: See IRC. A user had a database set to 8 hours ahead of their web host. Try to catch and warn about these issues. Test Plan: Artificially adjusted skew, saw setup warning. Reviewers: avivey, chad Reviewed By: chad Differential Revision: https://secure.phabricator.com/D14371 --- .../check/PhabricatorMySQLSetupCheck.php | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/applications/config/check/PhabricatorMySQLSetupCheck.php b/src/applications/config/check/PhabricatorMySQLSetupCheck.php index 75ecc06239..cc792358ad 100644 --- a/src/applications/config/check/PhabricatorMySQLSetupCheck.php +++ b/src/applications/config/check/PhabricatorMySQLSetupCheck.php @@ -319,9 +319,11 @@ final class PhabricatorMySQLSetupCheck extends PhabricatorSetupCheck { ->addMySQLConfig('innodb_buffer_pool_size'); } + $conn_w = id(new PhabricatorUser())->establishConnection('w'); + $ok = PhabricatorStorageManagementAPI::isCharacterSetAvailableOnConnection( 'utf8mb4', - id(new PhabricatorUser())->establishConnection('w')); + $conn_w); if (!$ok) { $summary = pht( 'You are using an old version of MySQL, and should upgrade.'); @@ -339,6 +341,28 @@ final class PhabricatorMySQLSetupCheck extends PhabricatorSetupCheck { ->setMessage($message); } + $info = queryfx_one( + $conn_w, + 'SELECT UNIX_TIMESTAMP() epoch'); + + $epoch = (int)$info['epoch']; + $local = PhabricatorTime::getNow(); + $delta = (int)abs($local - $epoch); + if ($delta > 60) { + $this->newIssue('mysql.clock') + ->setName(pht('Major Web/Database Clock Skew')) + ->setSummary( + pht( + 'This host is set to a very different time than the database.')) + ->setMessage( + pht( + 'The database host and this host ("%s") disagree on the current '. + 'time by more than 60 seconds (absolute skew is %s seconds). '. + 'Check that the current time is set correctly everywhere.', + php_uname('n'), + new PhutilNumber($delta))); + } + } protected function shouldUseMySQLSearchEngine() {