{"record":{"id":"d56cafecbc1e472b","repo":"phacility/phabricator","slug":"this-command-only-operates-on-database-masters-bu","errorCode":null,"errorMessage":"This command only operates on database masters, but the selected database hosts do not include any masters.","messagePattern":"This command only operates on database masters, but the selected database hosts do not include any masters\\.","errorType":"exception","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"error","filePath":"src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php","lineNumber":33,"sourceCode":"    return $this;\n  }\n\n  final public function getAnyAPI() {\n    return head($this->getAPIs());\n  }\n\n  final public function getMasterAPIs() {\n    $apis = $this->getAPIs();\n\n    $results = array();\n    foreach ($apis as $api) {\n      if ($api->getRef()->getIsMaster()) {\n        $results[] = $api;\n      }\n    }\n\n    if (!$results) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'This command only operates on database masters, but the selected '.\n          'database hosts do not include any masters.'));\n    }\n\n    return $results;\n  }\n\n  final public function getSingleAPI() {\n    $apis = $this->getAPIs();\n    if (count($apis) == 1) {\n      return head($apis);\n    }\n\n    throw new PhutilArgumentUsageException(\n      pht(\n        'This server is configured in cluster mode, with multiple database '.\n        'hosts. Use \"--host\" to specify which host you want to operate on.'));","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php#L15-L51","documentation":"PhabricatorStorageManagementWorkflow::getMasterAPIs() found no master among the selected database hosts. Writing storage workflows (upgrade, destroy, adjust) operate only on masters; when every selected ref is a replica — or no ref is configured as master — the command aborts with this usage exception before touching anything.","triggerScenarios":"Cluster database configuration where every selected host has role replica: `--host` pointed at a replica, or the master entry missing or its role misspelled in the cluster database configuration, so the $results array stays empty.","commonSituations":"Pointing --host at the read-replica hostname; a cluster config where the master block is commented out or role is typo'd; running soon after a failover without updating roles; single-host installs accidentally configured with role replica.","solutions":["Pass `--host <ref-key>` naming a host whose role is master.","Review the cluster database configuration and make sure the intended server has role master (fix typos, uncomment entries).","Run `./bin/storage status` to see which hosts and roles the tool resolves.","After a promotion or failover, update the role configuration before running storage commands."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before invoking a writing workflow, confirm a master is selectable\n$apis = $workflow->getAPIs();\n$has_master = false;\nforeach ($apis as $api) {\n  if ($api->getRef()->getIsMaster()) {\n    $has_master = true;\n  }\n}\nif (!$has_master) {\n  throw new Exception('no master host selected; pass --host or fix roles');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep cluster role configuration in review scope; a typo'd role silently removes the master.","Run ./bin/storage status after any cluster config change to confirm roles resolve."],"tags":["phabricator","bin-storage","cluster","database-config","replication"],"backgroundTag":"no-master-database-host","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}