Repository navigation
Conversation
reconfigure() tries to connect again until the mirrors are promoted. When the connection fails, the except block closes conn. But when the first connection fails, conn has no value yet: UnboundLocalError: local variable 'conn' referenced before assignment The error goes out of the retry loop, so gprecoverseg and gpstart stop and do not wait for the promotion. In later tries, conn is the closed connection of the previous try. Set conn to None before each try, and close it only if it is set. Now test_unit_segment_reconfigurer passes 3 of 3, instead of 1. Greenplum fixed this as part of the change to psycopg2 (b5920e061b4). That change does not apply to Cloudberry, which still uses PyGreSQL. Backpatch-through: REL_2_STABLE Assisted-by: Claude Code (cherry picked from commit 394e7c5)
Check that a failed reconnect does not close the previous connection again. Assert the timeout message after catching the exception.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of 394e7c5.
Reset the connection before each retry and close it only if the connection succeeded. This prevents
UnboundLocalErroron the first failed connection and avoids closing a previous connection twice.Test Plan
test_unit_segment_reconfigurer.py: 1/4 passed before the fix and 4/4 after it, on macOS and Linux. The new test catches a double close after a SQL error followed by a failed reconnect.gprecoversegand rebalance tests had the same 4 failures out of 11 on both revisions.Checklist