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

storage: simplify quota pool deallocation for failed proposals #26979

Merged

Conversation

nvanbenschoten
Copy link
Member

This change simplifies the process of releasing quota back into the
quota pool on failed proposals. It does so by pushing all quota
management into Raft instead of having the request's goroutine
try to determine whether it needs to release quota based on the
error in the proposal result. Quota management used to only be
handled by Raft for successful proposals.

In doing so, the change removes a case where quota could be double
freed: proposals that apply and then return an error. This isn't
particularly important though, because this pattern is never
used anymore.

Besides being a simplification, this is important for #26599 because
transaction pipelining depends on requests pushing proposals into
Raft and then returning immediately. In that model (asyncConsensus)
the request's goroutine is not around to release quota resources on
failed proposals.

Release note: None

This change simplifies the process of releasing quota back into the
quota pool on failed proposals. It does so by pushing all quota
management into Raft instead of having the request's goroutine
try to determine whether it needs to release quota based on the
error in the proposal result. Quota management used to only be
handled by Raft for successful proposals.

In doing so, the change removes a case where quota could be double
freed: proposals that apply and then return an error. This isn't
particularly important though, because this pattern is never
used anymore.

Besides being a simplification, this is important for cockroachdb#26599 because
transaction pipelining depends on requests pushing proposals into
Raft and then returning immediately. In that model (asyncConsensus)
the request's goroutine is not around to release quota resources on
failed proposals.

Release note: None
@nvanbenschoten nvanbenschoten requested review from tbg and a team June 26, 2018 14:45
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@bdarnell
Copy link
Contributor

:lgtm:


Reviewed 4 of 4 files at r1.
Review status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)


Comments from Reviewable

@nvanbenschoten
Copy link
Member Author

@tschottdorf if possible I'd appreciate one more set of eyes who also reviewed the original quota pool change to take a look at this. This stuff is a little hairy to touch, especially because the lifetime of quota reservations aren't exactly the same as that of local proposals (per your comment here, which was in response to a question I also had).

@tbg
Copy link
Member

tbg commented Jun 28, 2018

:lgtm:


Reviewed 4 of 4 files at r1.
Review status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale)


pkg/storage/replica.go, line 2813 at r1 (raw file):

	log.Event(ctx, "applied timestamp cache")

	ch, tryAbandon, undoQuotaAcquisition, pErr := r.propose(ctx, lease, ba, endCmds, spans)

Quite happy to see this go.


Comments from Reviewable

@nvanbenschoten
Copy link
Member Author

TFTRs!

bors r+

@craig
Copy link
Contributor

craig bot commented Jun 28, 2018

Build failed (retrying...)

@craig
Copy link
Contributor

craig bot commented Jun 28, 2018

Build failed (retrying...)

@benesch
Copy link
Contributor

benesch commented Jun 29, 2018

Spurious failures due to general TeamCity brokenness.

bors r+

@craig
Copy link
Contributor

craig bot commented Jun 29, 2018

Timed out (retrying...)

@craig
Copy link
Contributor

craig bot commented Jun 29, 2018

Build failed (retrying...)

craig bot pushed a commit that referenced this pull request Jun 29, 2018
26979: storage: simplify quota pool deallocation for failed proposals r=benesch a=nvanbenschoten

This change simplifies the process of releasing quota back into the
quota pool on failed proposals. It does so by pushing all quota
management into Raft instead of having the request's goroutine
try to determine whether it needs to release quota based on the
error in the proposal result. Quota management used to only be
handled by Raft for successful proposals.

In doing so, the change removes a case where quota could be double
freed: proposals that apply and then return an error. This isn't
particularly important though, because this pattern is never
used anymore.

Besides being a simplification, this is important for #26599 because
transaction pipelining depends on requests pushing proposals into
Raft and then returning immediately. In that model (asyncConsensus)
the request's goroutine is not around to release quota resources on
failed proposals.

Release note: None

Co-authored-by: Nathan VanBenschoten <[email protected]>
@craig
Copy link
Contributor

craig bot commented Jun 29, 2018

Build succeeded

@craig craig bot merged commit 2850bae into cockroachdb:master Jun 29, 2018
@nvanbenschoten nvanbenschoten deleted the nvanbenschoten/quotaPoolRefactor branch July 11, 2018 16:45
Copy link
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained


pkg/storage/replica.go, line 850 at r1 (raw file):

	r.mu.AssertHeld()
	pr := proposalResult{
		Err:           roachpb.NewError(roachpb.NewAmbiguousResultError("removing replica")),

Moving the error allocation out of the loop was the cause of #31535. Super subtle that this innocuous change would cause a race.

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.

6 participants