Fix recovery slot handling before pg_basebackup#1675
Open
aviralgarg05 wants to merge 2 commits intoapache:mainfrom
Open
Fix recovery slot handling before pg_basebackup#1675aviralgarg05 wants to merge 2 commits intoapache:mainfrom
aviralgarg05 wants to merge 2 commits intoapache:mainfrom
Conversation
There was a problem hiding this comment.
Hi, @aviralgarg05 welcome!🎊 Thanks for taking the effort to make our project better! 🙌 Keep making such awesome contributions!
yjhjstz
reviewed
Apr 10, 2026
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.
Fixes #1654
What does this PR do?
This PR fixes the recovery flow when the internal WAL replication slot does not already exist on the source segment.
Before this change, both
gpsegrecoveryandgpconfigurenewsegmentwould startpg_basebackupfirst and only retry with slot creation after the backup failed. In practice, that meant a full base backup could run for a long time and then fail at the end because the slot was missing.This change fixes that at the root:
pg_basebackupstartspg_basebackupattempt from both recovery pathsType of Change
Breaking Changes
None.
Test Plan
Tested with focused management-script unit coverage and repeated verification runs.
make installcheckmake -C src/test installcheck-cbdb-parallelCommands used:
python3 -m py_compile gpMgmt/sbin/gpsegrecovery.py gpMgmt/bin/gppylib/commands/pg.py gpMgmt/bin/lib/gpconfigurenewsegmentPYTHONPATH=/Users/aviralgarg/Everything/cloudberry/gpMgmt/bin:/Users/aviralgarg/Everything/cloudberry/gpMgmt/sbin:/Users/aviralgarg/Everything/cloudberry/gpMgmt/bin/lib python3.11 -m unittest -v gpMgmt.bin.gppylib.commands.test.unit.test_unit_pg_base_backup gpMgmt.bin.gppylib.test.unit.test_unit_gpsegrecoveryThe unit suite above was run multiple times and passed consistently.
Impact
Performance:
This avoids wasting time on a full
pg_basebackupthat was destined to fail only because the replication slot was missing. Recovery becomes more predictable and avoids unnecessary duplicate work.User-facing changes:
Recovery now fails less often in clusters where the internal replication slot has not been created yet, and it no longer relies on a second backup attempt to recover from that condition.
Dependencies:
No product dependencies were added.
Checklist
Additional Context
The fix is intentionally narrow and only touches the recovery paths involved in the reported issue:
gpMgmt/bin/gppylib/commands/pg.pygpMgmt/sbin/gpsegrecovery.pygpMgmt/bin/lib/gpconfigurenewsegmentI did not run the broader integration suites in this environment.
CI Skip Instructions
No CI skip requested.