-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Don't abort restore if master is unreachable #5254
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -232,7 +232,12 @@ func (agent *ActionAgent) startReplication(ctx context.Context, pos mysql.Positi | |
| defer remoteCancel() | ||
| posStr, err := tmc.MasterPosition(remoteCtx, ti.Tablet) | ||
| if err != nil { | ||
| return vterrors.Wrap(err, "can't get master replication position") | ||
| // It is possible that though MasterAlias is set, the master tablet is unreachable | ||
| // Log a warning and let tablet restore in that case | ||
| // If we had instead considered this fatal, all tablets would crash-loop | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we change one of the e2e test cases to take the master down before restoring one of the tablets? Would that have caught this?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was able to reproduce with a unit test, and verified that the fix works. |
||
| // until a master appears, which would make it impossible to elect a master. | ||
| log.Warningf("Can't get master replication position after restore: %v", err) | ||
| return nil | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't leave a line comment down there, so leaving it here. The loop on line 248 seems like it will hot-loop indefinitely if replication never starts. Could we add a 1s delay between retries, and check if the context has been cancelled before each iteration?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. Done. |
||
| } | ||
| masterPos, err := mysql.DecodePosition(posStr) | ||
| if err != nil { | ||
|
|
@@ -241,6 +246,9 @@ func (agent *ActionAgent) startReplication(ctx context.Context, pos mysql.Positi | |
|
|
||
| if !pos.Equal(masterPos) { | ||
| for { | ||
| if err := ctx.Err(); err != nil { | ||
| return err | ||
| } | ||
| status, err := agent.MysqlDaemon.SlaveStatus() | ||
| if err != nil { | ||
| return vterrors.Wrap(err, "can't get slave status") | ||
|
|
@@ -249,6 +257,7 @@ func (agent *ActionAgent) startReplication(ctx context.Context, pos mysql.Positi | |
| if !newPos.Equal(pos) { | ||
| break | ||
| } | ||
| time.Sleep(1 * time.Second) | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
Do these new entries persist after
go mod tidy? I don't quite understand what's happening, but I've noticed thegotool adding some things that we don't actually need.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.
I hadn't intended to commit a new
go.mod:(But this one diff does persist after
go mod tidy