refactor change master and support for source/master retry count in replication #1282
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.
This pull request refactors and simplifies the logic for changing replication master connections in cluster failover and reseeding scenarios. The main improvements are the introduction of helper methods to generate
ChangeMasterOptstructs, reducing code duplication and improving maintainability. Additionally, a newRetryCountoption is consistently set when changing masters, and error handling is slightly improved in the reseed path.Key changes include:
Refactoring and Code Simplification:
GetChangeMasterBaseOptForSlave,GetChangeMasterBaseOptForReplGroup,GetChangeMasterBaseOptForMxs) incluster/cluster_get.goto centralize the creation ofChangeMasterOptstructs, replacing repetitive inline struct construction throughout the codebase.pointSlaveToMasterWithMode,pointSlaveToMasterPositional,pointSlaveToMasterMxsNoGtid) to encapsulate logic for switching slaves to the new master, further reducing code duplication inSwitchSlavesToMaster.Failover and Replication Improvements:
ChangeMasterOpt, ensuring consistent setting of options likeRetryCount,SSL, andChannelwhen performing master changes during failover and reseeding. [1] [2] [3] [4] [5]RetryCountparameter toChangeMasterOptin all relevant places, allowing better control over replication retry behavior during failover operations. [1] [2] [3] [4]Error Handling:
ReseedFromParentClustermethod by ensuring an early return on error, rather than continuing execution. [1] [2]Minor Cleanups:
strconv) fromcluster/cluster_staging.goas a result of the refactoring.mstosms) inMasterFailover.These changes collectively make the codebase easier to maintain and extend, while also improving the reliability and consistency of master failover and replication setup operations.