fix missing dbname for sync_replication_slots#908
fix missing dbname for sync_replication_slots#908thamerlan wants to merge 3 commits intoEnterpriseDB:masterfrom
Conversation
Preserve dbname from upstream conninfo when generating standby primary_conninfo. Previously, repmgr explicitly skipped the 'dbname' parameter when building primary_conninfo for standby nodes. This worked fine for all versions prior to PostgreSQL 17 because the replication protocol ignores dbname. However, in PostgreSQL 17+, the sync_replication_slots worker requires a valid dbname in the connection string. Without this change, standby nodes cannot use replication slots after failover or switchover. This patch preserves the dbname from the upstream node's conninfo, if present, without adding any defaults. This approach is fully backward-compatible with older PostgreSQL versions and does not affect the existing replication logic.
There was a problem hiding this comment.
Pull request overview
Updates repmgr’s standby primary_conninfo generation to preserve dbname from the upstream node’s conninfo so PostgreSQL 17+ sync_replication_slots can connect successfully after failover/switchover.
Changes:
- Stop skipping
dbnamewhen buildingprimary_conninfo. - Add logic intended to append
dbnameinto the generated connection string.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
repmgr-action-standby.c
Outdated
| if (strcmp(param_list->keywords[c], "dbname") == 0) | ||
| { | ||
| dbname_found = true; | ||
| appendPQExpBuffer(&conninfo_buf, " dbname=%s", param_list->values[c]); | ||
| continue; | ||
| } |
There was a problem hiding this comment.
The special-cased dbname handling appends the value with %s instead of using appendConnStrVal(), so dbnames containing spaces, quotes, or backslashes will produce an invalid primary_conninfo string. It also unconditionally adds a leading space and bypasses the normal spacing logic. Prefer letting dbname go through the same generic path as other keywords (i.e., stop skipping it and remove this special-case), or at least build it with appendConnStrVal() and consistent spacing.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Preserve dbname from upstream conninfo when generating standby primary_conninfo.
Previously, repmgr explicitly skipped the 'dbname' parameter when building primary_conninfo for standby nodes. This worked fine for all versions prior to PostgreSQL 17 because the replication protocol ignores dbname.
However, in PostgreSQL 17+, the sync_replication_slots worker requires a valid dbname in the connection string. Without this change, standby nodes cannot use replication slots after failover or switchover.
This patch preserves the dbname from the upstream node's conninfo, if present, without adding any defaults. This approach is fully backward-compatible with older PostgreSQL versions and does not affect the existing replication logic.