mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-26 07:20:57 +01:00
Use the "@" operator to silence connection retry messages if initializing the stack with database config optional
Summary: Depends on D20780. Ref T13403. During initial setup, it's routine to run "bin/config" with a bad database config. We start the stack in "config optional" mode to anticipate this. However, even in this mode, we may emit warnings if the connection fails in certain ways. These warnings aren't useful; suppress them with "@". (Possibly this message should move from "phlog()" to "--trace" at some point, but it has a certain amount of context/history around it.) Test Plan: - Configured MySQL to fail with a retryable error, e.g. good host but bad port. - Ran `bin/config set ...`. - Before: saw retry warnings on stderr. - After: no retry warnings on stderr. - (Turned off suppression code artificially and verified warnings still appear under normal startup.) Maniphest Tasks: T13403 Differential Revision: https://secure.phabricator.com/D20781
This commit is contained in:
parent
f8eec38c94
commit
e0d6994adb
2 changed files with 19 additions and 4 deletions
14
src/infrastructure/env/PhabricatorEnv.php
vendored
14
src/infrastructure/env/PhabricatorEnv.php
vendored
|
@ -249,9 +249,17 @@ final class PhabricatorEnv extends Phobject {
|
|||
}
|
||||
|
||||
try {
|
||||
$stack->pushSource(
|
||||
id(new PhabricatorConfigDatabaseSource('default'))
|
||||
->setName(pht('Database')));
|
||||
// See T13403. If we're starting up in "config optional" mode, suppress
|
||||
// messages about connection retries.
|
||||
if ($config_optional) {
|
||||
$database_source = @new PhabricatorConfigDatabaseSource('default');
|
||||
} else {
|
||||
$database_source = new PhabricatorConfigDatabaseSource('default');
|
||||
}
|
||||
|
||||
$database_source->setName(pht('Database'));
|
||||
|
||||
$stack->pushSource($database_source);
|
||||
} catch (AphrontSchemaQueryException $exception) {
|
||||
// If the database is not available, just skip this configuration
|
||||
// source. This happens during `bin/storage upgrade`, `bin/conf` before
|
||||
|
|
|
@ -126,7 +126,14 @@ abstract class AphrontBaseMySQLDatabaseConnection
|
|||
$code,
|
||||
$ex->getMessage());
|
||||
|
||||
phlog($message);
|
||||
// See T13403. If we're silenced with the "@" operator, don't log
|
||||
// this connection attempt. This keeps things quiet if we're
|
||||
// running a setup workflow like "bin/config" and expect that the
|
||||
// database credentials will often be incorrect.
|
||||
|
||||
if (error_reporting()) {
|
||||
phlog($message);
|
||||
}
|
||||
} else {
|
||||
$profiler->endServiceCall($call_id, array());
|
||||
throw $ex;
|
||||
|
|
Loading…
Reference in a new issue