{"record":{"id":"f180dac28e7105c2","repo":"phacility/phabricator","slug":"database-s-is-configured-as-a-replica-but-ther","errorCode":null,"errorMessage":"Database \"%s\" is configured as a replica, but there is no master configured.","messagePattern":"Database \"(.+?)\" is configured as a replica, but there is no master configured\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"src/infrastructure/cluster/PhabricatorDatabaseRefParser.php","lineNumber":194,"sourceCode":"            'configuration. Replicas use the same configuration as the '.\n            'master they follow.',\n            $ref->getRefKey()));\n      }\n\n      $master_key = idx($server, 'master');\n      if ($master_key === null) {\n        if ($is_partitioned) {\n          throw new Exception(\n            pht(\n              'Database \"%s\" is configured as a replica, but does not '.\n              'specify which \"master\" it follows in configuration. Valid '.\n              'masters are: %s.',\n              $ref->getRefKey(),\n              implode(', ', $master_keys)));\n        } else if ($master_keys) {\n          $master_key = head($master_keys);\n        } else {\n          throw new Exception(\n            pht(\n              'Database \"%s\" is configured as a replica, but there is no '.\n              'master configured.',\n              $ref->getRefKey()));\n        }\n      }\n\n      if (!isset($ref_map[$master_key])) {\n        throw new Exception(\n          pht(\n            'Database \"%s\" is configured as a replica and specifies a '.\n            'master (\"%s\"), but that master is not a valid master. Valid '.\n            'masters are: %s.',\n            $ref->getRefKey(),\n            $master_key,\n            implode(', ', $master_keys)));\n      }\n","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/cluster/PhabricatorDatabaseRefParser.php#L176-L212","documentation":"A replica is configured, but no entry in `cluster.database` has `role => 'master'`, so `$master_keys` is empty and there is nothing for the replica to follow. The parser only falls back to implicit selection when at least one master exists; with zero masters it throws immediately.","triggerScenarios":"Every entry in `cluster.database` has a role that is not exactly the lowercase string `'master'` — e.g. `'Master'`, `'primary'`, or `'slave'` — while at least one entry is a replica. Note the `disabled` flag does not remove a master from this list, so the cause is almost always the role value itself.","commonSituations":"Hand-editing config and typoing the role; renaming terminology to primary/replica in config files; accidentally deleting or commenting out the master entry during cleanup.","solutions":["Set the intended master entry's role to exactly `role => 'master'` (lowercase).","If there is genuinely no local master (this install only mirrors a remote one), remove the cluster.database replica config entirely — a stand-alone install uses the standard mysql.* settings.","Verify with `bin/config get cluster.database` that at least one entry reads `role => 'master'`."],"exampleFix":"// before\n'db-primary' => array(\n  'host' => 'db1.example.com',\n  'role' => 'primary',\n),\n// after\n'db-primary' => array(\n  'host' => 'db1.example.com',\n  'role' => 'master',\n),","handlingStrategy":"validation","validationCode":"function assertAtLeastOneMaster(array $config) {\n  $masters = array();\n  foreach ($config as $key => $server) {\n    if (idx($server, 'role') === 'master') { $masters[] = $key; }\n  }\n  if (!$masters) {\n    throw new Exception(\n      'cluster.database needs at least one entry with role => \"master\".');\n  }\n  return $masters;\n}","typeGuard":"function isMasterEntry(array $server) {\n  return isset($server['role']) && $server['role'] === 'master';\n}","tryCatchPattern":null,"preventionTips":["Pin the literal 'master' string in a shared constant or template instead of free-typing roles.","Validate role values against ['master', 'replica'] in a config lint step.","Note that `disabled => true` does not remove a master from the candidate list — only the role string matters."],"tags":["php","phabricator","config","database","replication","cluster"],"backgroundTag":"database-cluster-misconfiguration","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}