Replace deprecated rpl_semi_sync_master/slave with rpl_semi_sync_sour…#892
Draft
shunki-fujita wants to merge 3 commits into
Draft
Replace deprecated rpl_semi_sync_master/slave with rpl_semi_sync_sour…#892shunki-fujita wants to merge 3 commits into
shunki-fujita wants to merge 3 commits into
Conversation
7431096 to
37fc649
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request migrates MOCO's semi-synchronous replication from deprecated MySQL master/slave plugin terminology to the new source/replica terminology for MySQL 9.x compatibility. The changes introduce runtime plugin detection to maintain backward compatibility with existing clusters using legacy plugins while supporting new installations with modern plugin names.
Changes:
- Added
SemiSyncNamestype andDetectSemiSyncNames()function to dynamically detect installed semi-sync plugin variant - Refactored all semi-sync variable references to use dynamic naming based on detected plugin type
- Renamed struct fields to use source/replica terminology (e.g.,
SemiSyncMasterEnabled→SemiSyncSourceEnabled)
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/dbop/semisync.go | New file implementing plugin detection logic and name mappings for both legacy and new plugin variants |
| pkg/dbop/types.go | Renamed GlobalVariables and GlobalStatus struct fields to source/replica terminology with aliased db tags |
| pkg/dbop/operator.go | Integrated plugin detection during operator initialization with fallback to new names on error |
| pkg/dbop/status.go | Refactored queries to dynamically build SQL using detected plugin variable names |
| pkg/dbop/replication.go | Updated ConfigureReplica and ConfigurePrimary to use dynamic variable names via fmt.Sprintf |
| pkg/dbop/test_util.go | Updated test helper to install new plugin names and added detection call in test operator creation |
| pkg/dbop/status_test.go | Updated test assertions to use new struct field names |
| pkg/dbop/replication_test.go | Updated test assertions to use new struct field names |
| clustering/status.go | Updated to use renamed GlobalStatus field |
| clustering/operations.go | Updated to use renamed GlobalVariables fields |
| clustering/mock_test.go | Updated mock implementation to use new field names |
| clustering/manager_test.go | Updated test assertions to use new field names |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ce/replica Migrate semi-synchronous replication from the deprecated master/slave plugins to the new source/replica plugins for MySQL 9.x compatibility. Key changes: - Add SemiSyncNames type and DetectSemiSyncNames() to dynamically detect which semi-sync plugin is installed via information_schema.plugins - Make all semi-sync variable references dynamic (SET GLOBAL, SELECT) based on the detected plugin type - Rename struct fields: SemiSyncMasterEnabled -> SemiSyncSourceEnabled, SemiSyncSlaveEnabled -> SemiSyncReplicaEnabled, WaitForSlaveCount -> WaitForReplicaCount - Update test helpers to install new plugin names Existing clusters with legacy plugins continue to work because the controller detects the installed plugin at runtime. Migration happens when moco-agent re-initializes plugins on Pod restart. Ref: #847 Signed-off-by: shunki-fujita <shunki-fujita@cybozu.co.jp>
…lugins Propagate the error from DetectSemiSyncNames in the operator factory and close the connection on failure, so the reconciler retries instead of silently falling back to NewSemiSyncNames when information_schema returns an error. The silent fallback would target nonexistent variables on a legacy-plugin cluster and turn a transient query failure into persistent SET GLOBAL failures. Change SemiSyncNames returns from *SemiSyncNames to SemiSyncNames so the operator field cannot be nil and callers cannot accidentally mutate the package-level constants through the returned pointer. Emit a warning via logr when DetectSemiSyncNames finds a semi-sync plugin that is registered but not ACTIVE (DISABLED / INACTIVE / DELETED). The system variables for non-ACTIVE plugins are not exposed by MySQL, so later SET/SELECT against them will fail; surfacing the state at detection time aids debugging. The warning is intentionally not emitted when both plugins are absent, which is the normal state of a freshly-created instance whose moco-agent has not yet installed the plugins. Signed-off-by: shunki-fujita <shunki-fujita@cybozu.co.jp>
Treat DetectSemiSyncNames errors the same way as Resolver failures: log and return a NopOperator instead of propagating. GatherStatus aborts the whole reconcile cycle on a New() error, while per-instance GetStatus errors are tolerated, so a single replica being briefly unreachable during pod restart, network blips, or failover should not stop the reconciler from making progress on the rest of the cluster. Signed-off-by: shunki-fujita <shunki-fujita@cybozu.co.jp>
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.
…ce/replica
Migrate semi-synchronous replication from the deprecated master/slave plugins to the new source/replica plugins for MySQL 9.x compatibility.
Key changes:
Existing clusters with legacy plugins continue to work because the controller detects the installed plugin at runtime. Migration happens when moco-agent re-initializes plugins on Pod restart.
Ref: #847 cybozu-go/moco-agent#117