{"record":{"id":"40593a8ce05ad94e","repo":"phacility/phabricator","slug":"database-s-is-configured-as-a-replica-but-does","errorCode":null,"errorMessage":"Database \"%s\" is configured as a replica, but does not specify which \"master\" it follows in configuration. Valid masters are: %s.","messagePattern":"Database \"(.+?)\" is configured as a replica, but does not specify which \"master\" it follows in configuration\\. Valid masters are: (.+?)\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"src/infrastructure/cluster/PhabricatorDatabaseRefParser.php","lineNumber":184,"sourceCode":"      }\n\n      $server = $config[$key];\n\n      $partition = idx($server, 'partition');\n      if ($partition !== null) {\n        throw new Exception(\n          pht(\n            'Database \"%s\" is configured as a replica, but specifies a '.\n            '\"partition\". Only master databases may have a partition '.\n            '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])) {","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/cluster/PhabricatorDatabaseRefParser.php#L166-L202","documentation":"In a partitioned setup (more than one entry with `role => 'master'`), every replica must say which master it follows via the `master` key. The parser can only auto-select a master when exactly one exists (`head($master_keys)`); with multiple masters an implicit choice is ambiguous, so any replica lacking an explicit `master` key throws this error listing the valid master ref keys (host:port strings).","triggerScenarios":"Adding a second master to a previously single-master cluster: pre-existing replica entries that never needed a `master` key now fail because `$is_partitioned` becomes true. Also hit when a new replica entry is written from old pre-partitioning documentation.","commonSituations":"Scaling out from one master to two partitioned masters without updating replicas; config migrated between installs; documentation drift after a Phabricator upgrade.","solutions":["Add a `master` key to the failing replica entry and set it to one of the ref keys listed in the message — these are `host:port` strings of the masters (e.g. `master1.example.com:3306`), not the config array keys.","Copy the value verbatim from the 'Valid masters are' list to avoid host/port mismatches.","Confirm the master entry itself has `role => 'master'` and a `partition` block, then re-parse."],"exampleFix":"// before\n'db-replica-a' => array(\n  'host' => 'replica.example.com',\n  'role' => 'replica',\n),\n// after (second master added, so partitioned mode)\n'db-replica-a' => array(\n  'host' => 'replica.example.com',\n  'role' => 'replica',\n  'master' => 'master1.example.com:3306',\n),","handlingStrategy":"validation","validationCode":"function assertReplicasHaveMaster(array $config) {\n  $masters = 0;\n  foreach ($config as $server) {\n    if ($server['role'] === 'master') { $masters++; }\n  }\n  if ($masters < 2) { return; }\n  foreach ($config as $key => $server) {\n    if ($server['role'] !== 'master'\n        && !strlen((string)idx($server, 'master'))) {\n      throw new Exception(\n        'Replica '.$key.' needs an explicit \"master\" in a partitioned cluster.');\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When adding a second master, audit every replica in the same change and add `master => host:port` to each.","Keep the master's host:port stable, or update referencing replicas atomically in the same config edit.","Remember the `master` value is a host:port ref key, not the config array key — encode that in your config template."],"tags":["php","phabricator","config","database","replication","cluster","partition"],"backgroundTag":"database-cluster-misconfiguration","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}