{"record":{"id":"f6d1ffe313403a77","repo":"phacility/phabricator","slug":"multiple-configured-databases-have-the-same-intern","errorCode":null,"errorMessage":"Multiple configured databases have the same internal key, \"%s\". You may have listed a database multiple times.","messagePattern":"Multiple configured databases have the same internal key, \"(.+?)\"\\. You may have listed a database multiple times\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"src/infrastructure/cluster/PhabricatorDatabaseRefParser.php","lineNumber":150,"sourceCode":"        }\n\n        $ref->setApplicationMap($application_map);\n      }\n    } else {\n      // If we only have one master, make it the default.\n      foreach ($refs as $ref) {\n        if ($ref->getIsMaster()) {\n          $ref->setIsDefaultPartition(true);\n        }\n      }\n    }\n\n    $ref_map = array();\n    $master_keys = array();\n    foreach ($refs as $ref) {\n      $ref_key = $ref->getRefKey();\n      if (isset($ref_map[$ref_key])) {\n        throw new Exception(\n          pht(\n            'Multiple configured databases have the same internal '.\n            'key, \"%s\". You may have listed a database multiple times.',\n            $ref_key));\n      } else {\n        $ref_map[$ref_key] = $ref;\n        if ($ref->getIsMaster()) {\n          $master_keys[] = $ref_key;\n        }\n      }\n    }\n\n    foreach ($refs as $key => $ref) {\n      if ($ref->getIsMaster()) {\n        continue;\n      }\n\n      $server = $config[$key];","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/cluster/PhabricatorDatabaseRefParser.php#L132-L168","documentation":"Every configured database ref gets an internal key (derived from host:port). While building the ref map, the parser throws if two refs produce the same key, which almost always means the same server is listed more than once in cluster.databases.","triggerScenarios":"Two entries in cluster.databases with the same host and port (e.g. a master block and a copied block meant to be a replica where the host was never changed); the same server listed under different roles.","commonSituations":"Setting up a replica by duplicating the master config and forgetting to change 'host'; adding a second application database on the same MySQL instance with an identical address; config merges producing a duplicated block.","solutions":["Give every entry a unique host:port combination; for the intended replica, point it at the replica's real host.","Remove accidentally duplicated blocks from cluster.databases.","Run 'bin/config get cluster.databases' and eyeball for repeated addresses before reloading."],"exampleFix":"// before\n[\n  [\"master\" => true, \"host\" => \"db1.internal\", \"port\" => 3306],\n  [\"master\" => false, \"host\" => \"db1.internal\", \"port\" => 3306] // duplicate key\n]\n\n// after\n[\n  [\"master\" => true, \"host\" => \"db1.internal\", \"port\" => 3306],\n  [\"master\" => false, \"host\" => \"db1-replica.internal\", \"port\" => 3306]\n]","handlingStrategy":"validation","validationCode":"// Detect duplicate host:port refs before deploy\n$keys = array();\nforeach ($cluster_database_config as $server) {\n  $key = idx($server, 'host').':'.idx($server, 'port', 3306);\n  if (isset($keys[$key])) {\n    // reject: same internal key listed twice\n  }\n  $keys[$key] = true;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When adding a replica, change the 'host' (not just 'master' => false) so the ref key stays unique.","Search cluster.databases for repeated addresses after any copy-paste edit.","Prefer generating database cluster config from a template with per-node variables."],"tags":["phabricator","database","cluster","config-validation","duplicate-entry"],"backgroundTag":"duplicate-config-entry","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}