phacility/phabricator · critical · Exception
Multiple configured databases have the same internal key
Error message
Multiple configured databases have the same internal key, "%s". You may have listed a database multiple times.
What it means
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.
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.
Example fix
// before [ ["master" => true, "host" => "db1.internal", "port" => 3306], ["master" => false, "host" => "db1.internal", "port" => 3306] // duplicate key ] // after [ ["master" => true, "host" => "db1.internal", "port" => 3306], ["master" => false, "host" => "db1-replica.internal", "port" => 3306] ]
Defensive patterns
Strategy: validation
Validate before calling
// Detect duplicate host:port refs before deploy
$keys = array();
foreach ($cluster_database_config as $server) {
$key = idx($server, 'host').':'.idx($server, 'port', 3306);
if (isset($keys[$key])) {
// reject: same internal key listed twice
}
$keys[$key] = true;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Multiple masters (databases " " and " ") specify that they…
- Multiple masters (databases " " and " ") specify that they…
- This server is configured with multiple master databases…
- Configuration file specifies cluster peer
- Database " " is configured as a replica and specifies a…
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/f6d1ffe313403a77.
Report an issue: GitHub.
Appendix: source
Thrown at src/infrastructure/cluster/PhabricatorDatabaseRefParser.php:150
}
$ref->setApplicationMap($application_map);
}
} else {
// If we only have one master, make it the default.
foreach ($refs as $ref) {
if ($ref->getIsMaster()) {
$ref->setIsDefaultPartition(true);
}
}
}
$ref_map = array();
$master_keys = array();
foreach ($refs as $ref) {
$ref_key = $ref->getRefKey();
if (isset($ref_map[$ref_key])) {
throw new Exception(
pht(
'Multiple configured databases have the same internal '.
'key, "%s". You may have listed a database multiple times.',
$ref_key));
} else {
$ref_map[$ref_key] = $ref;
if ($ref->getIsMaster()) {
$master_keys[] = $ref_key;
}
}
}
foreach ($refs as $key => $ref) {
if ($ref->getIsMaster()) {
continue;
}
$server = $config[$key];View on GitHub (pinned to 5720a38cfe)