Skip to content
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

fix(engine) Jump out of the loop when err is nil #19649

Closed
wants to merge 2 commits into from

Conversation

zddr
Copy link

@zddr zddr commented Sep 27, 2020

close #19841
Add judgment logic

  • CHANGELOG.md updated with a link to the PR (not the Issue)
  • Well-formatted commit messages
  • Rebased/mergeable
  • Tests pass
  • http/swagger.yml updated (if modified Go structs or API)
  • Feature flagged (if modified API)
  • Documentation updated or issue created (provide link to issue/pr)
  • Signed CLA (if not already signed)

@zddr zddr changed the title Resolve duplicate execution of CreateSnapshot Solve the problem of repeatedly executing CreateSnapshot Sep 27, 2020
@zddr zddr changed the title Solve the problem of repeatedly executing CreateSnapshot fix(engine) Jump out of the loop when err is nil Oct 28, 2020
@zddr
Copy link
Author

zddr commented Oct 28, 2020

@stuartcarnie

Comment on lines 920 to 922
if err != nil {
if err == nil {
break
} else if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the improvement!

The else if err != nil is unnecessary with your change and possibly clearer as:

switch {
case err == nil:
	break LOOP
case errors.Is(err, ErrSnapshotInProgress):
	backoff := time.Duration(math.Pow(32, float64(i))) * time.Millisecond
	time.Sleep(backoff)
default:
	return err
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I've changed it

Copy link
Contributor

@stuartcarnie stuartcarnie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch, however, @benbjohnson might want to look, as he may be actively working in this area.

@lesam
Copy link
Contributor

lesam commented Sep 7, 2021

Fixed a while ago in #20527, closing this one.

@lesam lesam closed this Sep 7, 2021
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.

The createsnapshot() of backup() will be executed repeatedly when err is nil
3 participants