{"record":{"id":"c822b776e3afe1b0","repo":"phacility/phabricator","slug":"database-s-is-configured-as-a-replica-and-speci","errorCode":null,"errorMessage":"Database \"%s\" is configured as a replica and specifies a master (\"%s\"), but that master is not a valid master. Valid masters are: %s.","messagePattern":"Database \"(.+?)\" is configured as a replica and specifies a master \\(\"(.+?)\"\\), but that master is not a valid master\\. Valid masters are: (.+?)\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"src/infrastructure/cluster/PhabricatorDatabaseRefParser.php","lineNumber":203,"sourceCode":"            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\n      $master_ref = $ref_map[$master_key];\n      $ref->setMasterRef($ref_map[$master_key]);\n      $master_ref->addReplicaRef($ref);\n    }\n\n    return array_values($refs);\n  }\n\n}","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/cluster/PhabricatorDatabaseRefParser.php#L185-L221","documentation":"A replica names its master with the `master` key, but that value does not resolve to a ref in the map the parser built. Ref keys are `host:port` strings (see PhabricatorDatabaseRef::getRefKey), so the `master` value must exactly match a configured master's host and port — pointing it at a config array key or a bare hostname fails.","triggerScenarios":"`master` in a replica entry is a typo'd host:port, uses the config array key instead of the host:port ref key, omits the port when the master sets a non-default one, or references another replica rather than a master.","commonSituations":"Renaming hosts or moving the master to a new port and forgetting dependent replicas; assuming `master` takes the array key from the config example; copy-paste between environments with different hostnames.","solutions":["Set the replica's `master` value to one of the ref keys listed in the message's 'Valid masters are' list, verbatim (format `host:port`, e.g. `db1.example.com:3306`).","If the master uses a non-default port, include it in both the master's `port` and the replica's `master` value.","Re-run `bin/config get cluster.database` to confirm the strings match exactly (case, port, punctuation)."],"exampleFix":"// before\n'db-replica-a' => array(\n  'host' => 'replica.example.com',\n  'role' => 'replica',\n  'master' => 'db-master-a',\n),\n// after (master value is the master's host:port ref key)\n'db-replica-a' => array(\n  'host' => 'replica.example.com',\n  'role' => 'replica',\n  'master' => 'master.example.com:3306',\n),","handlingStrategy":"validation","validationCode":"function assertReplicaMasterKeysValid(array $config) {\n  $master_keys = array();\n  foreach ($config as $key => $server) {\n    if ($server['role'] === 'master') {\n      $ref = idx($server, 'port')\n        ? $server['host'].':'.$server['port']\n        : $server['host'];\n      $master_keys[$ref] = true;\n    }\n  }\n  foreach ($config as $key => $server) {\n    if ($server['role'] === 'master') { continue; }\n    $master = idx($server, 'master');\n    if ($master !== null && empty($master_keys[$master])) {\n      throw new Exception(\n        'Replica '.$key.' names unknown master \"'.$master.'\". '.\n        'Valid: '.implode(', ', array_keys($master_keys)));\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat `master` values as host:port ref keys — generate them from the master entry's host/port fields rather than hand-typing.","When renaming a master host or changing its port, grep cluster.database for the old ref key and update every replica in the same change.","Keep an install-wide inventory mapping replica → master ref key so audits are mechanical."],"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"}