Skip to content

fix: blue/green re-selects routing from latest status and matches endpoints by host and port - #1359

Closed
ritojoao wants to merge 1 commit into
aws:mainfrom
ritojoao:fix/bg-stale-status-and-endpoint-match
Closed

ritojoao wants to merge 1 commit into
aws:mainfrom
ritojoao:fix/bg-stale-status-and-endpoint-match

Conversation

@ritojoao

Copy link
Copy Markdown

Description

Fixes #1352. Two defects in the sync Blue/Green plugin:

1. Re-selection loop hangs after the switchover moves on. connect() and execute() re-selected the routing from self._bg_status, which was captured before the retry loop, instead of the latest published status. When a routing returned None (or an empty ValueContainer) and the switchover had already advanced, the same stale routing was picked again on every iteration and the call never returned. The loop now updates self._bg_status and re-selects from latest_status, and falls through to a direct connect/execute when no routing matches. This is what the async plugin already does.

2. Endpoint-scoped routings never match. BaseRouting.is_match compared the routing endpoint ("host" or "host:port", built by _get_host_and_port) with host_info.url, which always ends with /. It now compares with host_info.get_host_and_port().lower(), like getHostAndPort() in the JDBC wrapper. Same change in the async plugin.

Tests

  • tests/unit/test_blue_green_plugin.py: is_match by host:port and bare host (a trailing / no longer matches); connect re-selects from the latest status and falls through; connect picks the routing from the latest status; execute re-selects and falls through. get_status uses a bounded side_effect, so a regression fails instead of hanging.
  • tests/unit/test_aio_blue_green_plugin.py: the is_match test used "h:5432/" as the endpoint, which encoded the bug; changed to "h:5432" and added a bare-host case.
  • The new sync tests fail on main and pass with this change. flake8 and isort --check-only are clean on the touched files.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

…points by host and port

Two defects in the sync Blue/Green plugin (aws#1352):

- connect() and execute() re-selected the routing from self._bg_status,
  captured before the retry loop, instead of the latest published status.
  Once the switchover moved on, the old routing kept returning None and was
  picked again forever, so the call never returned. The loop now updates
  self._bg_status and re-selects from latest_status, falling through to a
  direct connect/execute when no routing matches, as the async plugin does.

- BaseRouting.is_match compared the routing endpoint ("host" or
  "host:port") with host_info.url, which ends with "/", so endpoint-scoped
  routings never matched. It now compares with get_host_and_port(), like
  the JDBC wrapper. Same fix in the async plugin.

Adds sync unit tests for both paths and updates the async is_match test,
which encoded the trailing "/".
@JuanLeee

Copy link
Copy Markdown
Contributor

Hi @ritojoao,

Thank you for contributing a fix for issue #1352! The fix was merge in #1360 and will be closing this pull request as a result. The fix will be available in the next release version, we will provide an update here once the new version is available.

Thank you!

@ritojoao

Copy link
Copy Markdown
Author

Hi @JuanLeee, thank you for the quick fix in #1360 and for letting me know. Closing this one makes sense. I appreciate the review and the patience, and I will look out for the next release.

@ritojoao ritojoao closed this Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blue/Green plugin: call hangs after switchover; IP substitution never applied

3 participants