{"record":{"id":"8fe1aeae18c6aec9","repo":"phacility/phabricator","slug":"unable-to-connect-to-master-database-s-this","errorCode":null,"errorMessage":"Unable to connect to master database (\"%s\"). This is a severe failure; your request did not complete.","messagePattern":"Unable to connect to master database \\(\"(.+?)\"\\)\\. This is a severe failure; your request did not complete\\.","errorType":"exception","errorClass":"PhabricatorClusterImpossibleWriteException","httpStatus":null,"severity":"critical","filePath":"src/infrastructure/storage/lisk/PhabricatorLiskDAO.php","lineNumber":147,"sourceCode":"\n    if (!$master && !$replica) {\n      $this->raiseUnconfigured($database);\n    }\n\n    $this->raiseUnreachable($database, $master_exception);\n  }\n\n  private function raiseImproperWrite($database) {\n    throw new PhabricatorClusterImproperWriteException(\n      pht(\n        'Unable to establish a write-mode connection (to application '.\n        'database \"%s\") because this server is in read-only mode. Whatever '.\n        'you are trying to do does not function correctly in read-only mode.',\n        $database));\n  }\n\n  private function raiseImpossibleWrite($database) {\n    throw new PhabricatorClusterImpossibleWriteException(\n      pht(\n        'Unable to connect to master database (\"%s\"). This is a severe '.\n        'failure; your request did not complete.',\n        $database));\n  }\n\n  private function raiseUnconfigured($database) {\n    throw new Exception(\n      pht(\n        'Unable to establish a connection to any database host '.\n        '(while trying \"%s\"). No masters or replicas are configured.',\n        $database));\n  }\n\n  private function raiseUnreachable($database, Exception $proxy = null) {\n    $message = pht(\n      'Unable to establish a connection to any database host '.\n      '(while trying \"%s\"). All masters and replicas are completely '.","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/storage/lisk/PhabricatorLiskDAO.php#L129-L165","documentation":"A write-mode connection is required, but no configured master could be contacted — every master attempt raised an exception, so raiseImpossibleWrite() throws PhabricatorClusterImpossibleWriteException and the message states plainly that the request did not complete. This is the severe end of the cluster exceptions: distinct from read-only refusal (1497) and from nothing-configured (1499); here masters exist in configuration but are all unreachable.","triggerScenarios":"establishConnection('w') / any save() or write query while every configured master is down: mysqld crashed, host unreachable, network partition, or all masters failing auth. Replicas may still serve reads, which is why only writes die.","commonSituations":"Master host crash or reboot; network/firewall outage between application and master; wrong master address or credentials in cluster.databases; failover in progress before a new master is promoted.","solutions":["Restore reachability of at least one master: verify from the app host with mysql -h<master> and check mysqld/network on the master side","Fix the cluster database configuration (cluster.databases / mysql.host) if it points at the wrong host or uses bad credentials","Verify recovery with phabricator/bin/storage probe before letting traffic retry","If the master is genuinely lost, promote a replica to master and update configuration — during the gap, expect writes to keep failing with this exception"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Health gate before retrying writes after an outage:\n// phabricator/bin/storage probe   -> all configured masters must answer\n// Only then resume write traffic.","typeGuard":null,"tryCatchPattern":"try {\n  $conn = $dao->establishConnection('w');\n} catch (PhabricatorClusterImpossibleWriteException $ex) {\n  // All masters unreachable: page operations, back off, and retry after\n  // a probe succeeds. Reads may continue against replicas.\n}","preventionTips":["Monitor master reachability and page before failover scenarios cascade into user-facing writes","Keep cluster.databases entries accurate through host migrations; verify with bin/storage probe after changes","Give write paths a degradation plan (queue writes, serve stale reads) for master-outage windows","Document and rehearse replica-to-master promotion so the impossible-write window stays short"],"tags":["cluster","master","connection","failover","availability","mysql"],"backgroundTag":"master-database-unreachable","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}