Skip to content

[blue-green] Allow PgBouncer redirect with mismatched replicas#1515

Open
vitabaks wants to merge 2 commits intomainfrom
upgrade-replica-count-mismatch
Open

[blue-green] Allow PgBouncer redirect with mismatched replicas#1515
vitabaks wants to merge 2 commits intomainfrom
upgrade-replica-count-mismatch

Conversation

@vitabaks
Copy link
Copy Markdown
Member

@vitabaks vitabaks commented Apr 14, 2026

Upgrade: make PgBouncer redirection tolerant to differing replica counts.

  • Changed the pre-check in pgbouncer_redirect.yml from a hard fail to a run_once debug notice so mismatched replica counts won't abort the playbook.
  • Implemented deterministic mapping of source->target replicas using index modulo target count with a fallback to the target primary when no replicas exist.

Upgrade: make PgBouncer redirection tolerant to differing replica counts.

- Changed the pre-check in pgbouncer_redirect.yml from a hard fail to a run_once debug notice so mismatched replica counts won't abort the playbook.
- Implemented deterministic mapping of source->target replicas using index modulo target count with a fallback to the target primary when no replicas exist (added target_hosts_for_replicas and updated target_secondary_host calculation).
- Added explanatory comments.
- Updated README to reference patroni_standby_cluster and to document deterministic mapping/fallback behavior.
@vitabaks vitabaks self-assigned this Apr 14, 2026
@vitabaks vitabaks added enhancement Improvement of the current functionality automation Automation functionality using Ansible labels Apr 14, 2026
Ensure the index used to pick target_secondary_host is an integer by applying the Jinja int filter to source_idx. This avoids type errors or incorrect modulo behavior when source_idx is a string (e.g. from inventory), guaranteeing correct selection from target_hosts_for_replicas.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation Automation functionality using Ansible enhancement Improvement of the current functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant