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

retry: fix retry.WithMaxAttempt to deal with opt.Closer properly #47063

Merged
merged 1 commit into from
Apr 6, 2020

Conversation

otan
Copy link
Contributor

@otan otan commented Apr 6, 2020

In beac4a53e0e2e2236eb5957f67abc1bf476ad1b6, we introduced
stopper.ShouldQuiesce() to the retry.Closer so that server shutdowns
also shut down in-process retries to the temp schema cleaner.

However, when stopper.ShouldQuiesce() is called, the error that gets
wrapped in errors.Wrap is nil (as ctx.Err() is nil), and as such we
return with no error set. This causes potentially bugs afterwards as
users of the functions expected errors when this happens and not to
continue silently.

This PR bridges that gap by always wrapping an error around cases where
WithMaxAttempt is aborted by a context attempt.

Resolves #47057.

Release note: None.

@blathers-crl
Copy link

blathers-crl bot commented Apr 6, 2020

Welcome back, creator. Thank you for testing me.

My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI.

I have added a few people who may be able to assist in reviewing:

🦉 Hoot! I am a Blathers, a bot for CockroachDB. I am experimental - my owner is otan.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@otan otan requested review from rohany and a team and removed request for cockroach-teamcity April 6, 2020 05:32
@blathers-crl
Copy link

blathers-crl bot commented Apr 6, 2020

❌ The GitHub CI (Cockroach) build has failed on 20923a8c.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. I am experimental - my owner is otan.

@otan otan force-pushed the fix_retry_glitch branch 2 times, most recently from 4149bdc to c5c88cd Compare April 6, 2020 06:06
@knz
Copy link
Contributor

knz commented Apr 6, 2020

Woah good catch!

@tbg this may be of interest.
@otan @andreimatei I think this might explain #47011 - what do you think?

pkg/util/retry/retry_test.go Outdated Show resolved Hide resolved
@tbg
Copy link
Member

tbg commented Apr 6, 2020

Yikes, good catch @otan.

@tbg
Copy link
Member

tbg commented Apr 6, 2020

Does this affect release-20.1?

beac4a5 is about the temporary object cleaner which I think caused the delay, so I'm hopeful that fixes that, too.

@otan
Copy link
Contributor Author

otan commented Apr 6, 2020 via email

In `beac4a53e0e2e2236eb5957f67abc1bf476ad1b6`, we introduced
stopper.ShouldQuiesce() to the retry.Closer so that server shutdowns
also shut down in-process retries to the temp schema cleaner.

However, when stopper.ShouldQuiesce() is called, the error that gets
wrapped in `errors.Wrap` is nil (as ctx.Err() is nil), and as such we
return with no error set. This causes potentially bugs afterwards as
users of the functions expected errors when this happens and not to
continue silently.

This PR bridges that gap by always wrapping an error around cases where
WithMaxAttempt is aborted by a context attempt.

Resolves cockroachdb#47057.

Release note: None.
@otan otan force-pushed the fix_retry_glitch branch from c5c88cd to c1df412 Compare April 6, 2020 14:23
@otan
Copy link
Contributor Author

otan commented Apr 6, 2020

Does this affect release-20.1?

The original fix does (in the form of slow shutdowns), so when I backport it I will backport this PR along with it.

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

thanks!

@otan
Copy link
Contributor Author

otan commented Apr 6, 2020

bors r=knz

@RaduBerinde
Copy link
Member

@knz I encountered this pattern before - if err1 == nil { return err2 } else { return Wrap() }. I think it would be useful to have an errors helper for this, perhaps something that takes a variable list of errors (some of which can be nil) and returns a single error. Or perhaps make Wrap specially handle a nil input.

@knz
Copy link
Contributor

knz commented Apr 6, 2020

You may be thinking about errors.CombineErrors(err1, err2)

@RaduBerinde
Copy link
Member

Oh, TIL, thanks!

@craig
Copy link
Contributor

craig bot commented Apr 6, 2020

Build succeeded

@craig craig bot merged commit 80da27b into cockroachdb:master Apr 6, 2020
@andreimatei
Copy link
Contributor

Yeah, I'm a big fan of errors.CombineErrors(). Real fine function.

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.

server: TestBootstrapNewStore failed
6 participants