Skip to content

Conversation

@caffeinated92
Copy link
Collaborator

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 ChangeMasterOpt structs, reducing code duplication and improving maintainability. Additionally, a new RetryCount option is consistently set when changing masters, and error handling is slightly improved in the reseed path.

Key changes include:

Refactoring and Code Simplification:

  • Introduced helper methods (GetChangeMasterBaseOptForSlave, GetChangeMasterBaseOptForReplGroup, GetChangeMasterBaseOptForMxs) in cluster/cluster_get.go to centralize the creation of ChangeMasterOpt structs, replacing repetitive inline struct construction throughout the codebase.
  • Added new helper methods (pointSlaveToMasterWithMode, pointSlaveToMasterPositional, pointSlaveToMasterMxsNoGtid) to encapsulate logic for switching slaves to the new master, further reducing code duplication in SwitchSlavesToMaster.

Failover and Replication Improvements:

  • Updated all relevant code paths to use the new helper methods for constructing ChangeMasterOpt, ensuring consistent setting of options like RetryCount, SSL, and Channel when performing master changes during failover and reseeding. [1] [2] [3] [4] [5]
  • Added the RetryCount parameter to ChangeMasterOpt in all relevant places, allowing better control over replication retry behavior during failover operations. [1] [2] [3] [4]

Error Handling:

  • Improved error handling in the ReseedFromParentCluster method by ensuring an early return on error, rather than continuing execution. [1] [2]

Minor Cleanups:

  • Removed an unused import (strconv) from cluster/cluster_staging.go as a result of the refactoring.
  • Minor variable renaming for clarity (e.g., ms to sms) in MasterFailover.

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.

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.

Support for source_retry_count and master_retry_count in replication ?

2 participants