-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix abort/retry interaction #1655
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 |
|---|---|---|
|
|
@@ -160,10 +160,21 @@ func (this *Migrator) retryOperation(operation func() error, notFatalHint ...boo | |
| // sleep after previous iteration | ||
| RetrySleepFn(1 * time.Second) | ||
| } | ||
| // Check for abort/context cancellation before each retry | ||
| if abortErr := this.checkAbort(); abortErr != nil { | ||
| return abortErr | ||
| } | ||
| err = operation() | ||
| if err == nil { | ||
| return nil | ||
| } | ||
| // Check if this is an unrecoverable error (data consistency issues won't resolve on retry) | ||
| if strings.Contains(err.Error(), "warnings detected") { | ||
| if len(notFatalHint) == 0 { | ||
| _ = base.SendWithContext(this.migrationContext.GetContext(), this.migrationContext.PanicAbort, err) | ||
| } | ||
| return err | ||
|
Comment on lines
+172
to
+176
|
||
| } | ||
| // there's an error. Let's try again. | ||
| } | ||
| if len(notFatalHint) == 0 { | ||
|
|
@@ -190,10 +201,21 @@ func (this *Migrator) retryOperationWithExponentialBackoff(operation func() erro | |
| if i != 0 { | ||
| RetrySleepFn(time.Duration(interval) * time.Second) | ||
| } | ||
| // Check for abort/context cancellation before each retry | ||
| if abortErr := this.checkAbort(); abortErr != nil { | ||
| return abortErr | ||
|
Comment on lines
202
to
+206
|
||
| } | ||
| err = operation() | ||
| if err == nil { | ||
| return nil | ||
| } | ||
| // Check if this is an unrecoverable error (data consistency issues won't resolve on retry) | ||
| if strings.Contains(err.Error(), "warnings detected") { | ||
| if len(notFatalHint) == 0 { | ||
| _ = base.SendWithContext(this.migrationContext.GetContext(), this.migrationContext.PanicAbort, err) | ||
| } | ||
| return err | ||
|
Comment on lines
+213
to
+217
|
||
| } | ||
| } | ||
| if len(notFatalHint) == 0 { | ||
| // Use helper to prevent deadlock if listenOnPanicAbort already exited | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ERROR warnings detected in statement 1 of 1 | ||
| ERROR warnings detected in statement |
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.
checkAbort()is called only after the backoff sleep. If the migration context has already been cancelled/aborted, this loop will still sleep the full interval before returning, which can significantly delay shutdown (especially in exponential backoff scenarios). Consider checkingcheckAbort()before sleeping, and/or making the sleep itself context-aware (e.g., select onctx.Done()vs a timer) so cancellation interrupts the wait.