-
Notifications
You must be signed in to change notification settings - Fork 728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replicate: add state switch #2313
Conversation
Signed-off-by: disksing <i@disksing.com>
server/replicate/replicate.go
Outdated
@@ -118,13 +132,16 @@ func (m *ModeManager) drSwitchToSyncRecover() error { | |||
defer m.Unlock() | |||
id, err := m.idAlloc.Alloc() | |||
if err != nil { | |||
log.Warn("failed to switch to sync_recover state", zap.String("replicate-mode", "dr_async"), zap.Error(err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be dr_sync
here?
server/replicate/replicate.go
Outdated
return err | ||
} | ||
m.drAutosync = dr | ||
log.Warn("switched to async state", zap.String("replicate-mode", "dr_async")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use log.Info
?
server/replicate/replicate.go
Outdated
return err | ||
} | ||
m.drAutosync = dr | ||
log.Warn("switched to sync_recover state", zap.String("replicate-mode", "dr_async")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use log.Info
?
server/replicate/replicate.go
Outdated
@@ -133,8 +150,90 @@ func (m *ModeManager) drSwitchToSync() error { | |||
defer m.Unlock() | |||
dr := drAutosyncStatus{State: drStateSync} | |||
if err := m.storage.SaveReplicateStatus(modeDRAutosync, dr); err != nil { | |||
log.Warn("failed to switch to sync state", zap.String("replicate-mode", "dr_async"), zap.Error(err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dr_async
-> dr_sync
server/replicate/replicate.go
Outdated
return err | ||
} | ||
m.drAutosync = dr | ||
log.Warn("switched to sync state", zap.String("replicate-mode", "dr_async")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
Signed-off-by: disksing <i@disksing.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest lgtm.
// Run starts the background job. | ||
func (m *ModeManager) Run(quit chan struct{}) { | ||
select { | ||
case <-time.After(idleTimeout): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why need to wait for an idle timeout? better to add a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/merge |
/run-all-tests |
Signed-off-by: disksing i@disksing.com
What problem does this PR solve?
Fix #2271
What is changed and how it works?
Check List
Tests
Code changes