-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: flow control throttling replica operations #15802
Conversation
Can the call to Review status: 0 of 4 files reviewed at latest revision, 2 unresolved discussions. pkg/storage/client_raft_test.go, line 1685 at r1 (raw file):
Nice test! pkg/storage/client_raft_test.go, line 1696 at r1 (raw file):
I'm guessing that you needed to disable the raft log queue because the truncations it was generating was fouling up the counting below. Might want to add a comment to that effect. Or whatever the real reason is. Comments from Reviewable |
@tamird This is another PR that I'd be interested in seeing the impact on performance benchmarks. Review status: 0 of 4 files reviewed at latest revision, 2 unresolved discussions. Comments from Reviewable |
Reviewed 4 of 4 files at r1. pkg/storage/replica.go, line 816 at r1 (raw file):
Another thread could be blocked in Comments from Reviewable |
pkg/storage/client_raft_test.go
Outdated
// blocked. | ||
incArgs := incrementArgs([]byte("k"), 1) | ||
for i := 0; i < quota; i++ { | ||
if _, err := client.SendWrapped(context.Background(), repl1, incArgs); err != nil { |
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.
Couldn't this already block if some other moving part in the system gets a proposal in?
Indeed. Good stuff, @irfansharif! Reviewed 4 of 4 files at r1. pkg/storage/client_raft_test.go, line 1696 at r1 (raw file): Previously, petermattis (Peter Mattis) wrote…
also, consider doing this by iterating through the stores:
pkg/storage/client_raft_test.go, line 1707 at r1 (raw file):
This assumes that replica 1 is the leader. Could you make that more explicit? I think this test may end up flaky under stress. You might also consider using a more descriptive variable name here, perhaps pkg/storage/client_raft_test.go, line 1743 at r1 (raw file):
It is not permitted to call pkg/storage/client_raft_test.go, line 1748 at r1 (raw file):
there's no need for this local, it can be inlined below pkg/storage/client_raft_test.go, line 1751 at r1 (raw file):
pkg/storage/quota_pool.go, line 17 at r1 (raw file):
where did this code come from? pkg/storage/quota_pool.go, line 58 at r1 (raw file):
how come this constant is in this file, while it is only used elsewhere? pkg/storage/quota_pool.go, line 64 at r1 (raw file):
Can you help me understand this structure? It looks like there's always a numeric value parked in this channel, which is read and written under lock -- why do we need a channel at all? Is it just for composition with context cancellation? The pattern is unusual enough that I think it'd benefit from a comment. Comments from Reviewable |
aabef51
to
f1be1fe
Compare
Thanks! Will be following this up with another PR with quota acquisitions based on the size of the raft log entry itself instead of the unary acquisitions as it is currently. Note to self re: Tobi's driveby comment we might want to delay proposer evaluation until after acquiring quota, but if we're doing size based quota acquisitions we'd need the 'size' of the evaluation. Review status: 1 of 4 files reviewed at latest revision, 11 unresolved discussions, some commit checks pending. pkg/storage/client_raft_test.go, line 1685 at r1 (raw file): Previously, petermattis (Peter Mattis) wrote…
Thanks! pkg/storage/client_raft_test.go, line 1696 at r1 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done (both). pkg/storage/client_raft_test.go, line 1707 at r1 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/client_raft_test.go, line 1734 at r1 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
yes, at the time of writing the only possible moving parts that could do this are node liveness heartbeats and raft log truncations. This will be revisited once quota acquisitions are based on raft log entry sizes (in bytes). At the interest of keeping the PR small I've added a comment to this affect so to add size based quota in a follow up PR. pkg/storage/client_raft_test.go, line 1743 at r1 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/client_raft_test.go, line 1748 at r1 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/client_raft_test.go, line 1751 at r1 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/quota_pool.go, line 17 at r1 (raw file): Previously, tamird (Tamir Duberstein) wrote…
grpc-go, added a comment for future readers. pkg/storage/quota_pool.go, line 58 at r1 (raw file): Previously, tamird (Tamir Duberstein) wrote…
nit: the constant is only used with the the quota pool defined below, thought it best to keep it in the same place. pkg/storage/quota_pool.go, line 64 at r1 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Added a comment. Yes, it helps with composition with context cancellation but also makes for clean acquisition given we're essentially using it as a counting semaphore. pkg/storage/replica.go, line 816 at r1 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Done. Comments from Reviewable |
One more drive-by comment: there's also a risk in this (PR's) change in that now there's more "waiting" downstream of the command queue. If you already know you're going to take proposal quota, it would make sense to do so before entering the command queue in a future change. That way, you could have thousands of writers blocked on the quota, without negatively impacting other ops that can go ahead (reads). |
ee921a6
to
b809275
Compare
What is the impact of merging this as-is without this follow up work? Perhaps we want to include that here - it doesn't seem likely to me that this stuff will rot in the interim, though I could be convinced otherwise. Reviewed 3 of 3 files at r2. pkg/storage/client_raft_test.go, line 1707 at r1 (raw file): Previously, irfansharif (irfan sharif) wrote…
Heh, we have a utility function for this already.
pkg/storage/client_raft_test.go, line 1730 at r2 (raw file):
consider avoiding hardcoding
pkg/storage/client_raft_test.go, line 1748 at r2 (raw file):
add an empty comment line above here to preserve the paragraph separation:
pkg/storage/client_raft_test.go, line 1752 at r2 (raw file):
ditto pkg/storage/client_raft_test.go, line 1766 at r2 (raw file):
I think this should be:
pkg/storage/client_raft_test.go, line 1773 at r2 (raw file):
This should be pkg/storage/quota_pool.go, line 58 at r1 (raw file): Previously, irfansharif (irfan sharif) wrote…
Understood, but I think it might be better to put it in the file where it is used, in the interest of reducing context switches. pkg/storage/quota_pool.go, line 73 at r2 (raw file):
consider adding an empty comment line above. pkg/storage/quota_pool.go, line 120 at r2 (raw file):
I don't think it's appropriate to say that raft leadership changed here; this structure doesn't know anything about raft, all it knows is that it was closed. You might say that at the caller, though. pkg/storage/quota_pool.go, line 129 at r2 (raw file):
move inside the conditional? pkg/storage/replica.go, line 820 at r2 (raw file):
you could move this inside the nil check, and make the Comments from Reviewable |
Having looked at this change a little bit together with @irfansharif last night, I'm nervous about acquiring the quota on the client's goroutine but releasing it on application. There are various error conditions which prevent a proposal from going into Raft in the first place (reproposals, etc). What would be lost if the proposal quota were released in the clients goroutine as well? That way, you'd get a simple defer and less error-prone guarantees required between processRaft and the client goroutine. You would release quota an iota later, but I don't see that there's a big issue with that. Or maybe I'm completely missing the point. Review status: all files reviewed at latest revision, 16 unresolved discussions, some commit checks failed. pkg/storage/helpers_test.go, line 264 at r2 (raw file):
You should drain the old pool if there is one, I think. pkg/storage/replica.go, line 813 at r2 (raw file):
is Comments from Reviewable |
Ah yeah, completely missed the point, as @irfansharif kindly reminded me. We figured out that the current code isn't really a sound way of doing things: the goroutine that handles This off-by-one only happens with 3+ replicas:
|
94f4e65
to
e7cdb1b
Compare
No impact, should be fine. I worked on the proposal size based quota acquisition reimplementing
Yup, ran into this failure for contentious workloads (
I've addressed this by returning acquired quota before the early Review status: 0 of 4 files reviewed at latest revision, 16 unresolved discussions, all commit checks successful. pkg/storage/helpers_test.go, line 264 at r2 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done, good hygiene. pkg/storage/quota_pool.go, line 73 at r2 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/quota_pool.go, line 120 at r2 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/quota_pool.go, line 129 at r2 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/replica.go, line 813 at r2 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/storage/replica.go, line 820 at r2 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. Comments from Reviewable |
Additionally PTAL at Review status: 0 of 4 files reviewed at latest revision, 16 unresolved discussions, all commit checks successful. pkg/storage/client_raft_test.go, line 1707 at r1 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/client_raft_test.go, line 1730 at r2 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/client_raft_test.go, line 1748 at r2 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/client_raft_test.go, line 1752 at r2 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/client_raft_test.go, line 1766 at r2 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/client_raft_test.go, line 1773 at r2 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. Comments from Reviewable |
e5ad92b
to
188b45d
Compare
I'll review this afternoon. |
Review status: 0 of 4 files reviewed at latest revision, 15 unresolved discussions, some commit checks failed. pkg/storage/replica.go, line 2619 at r3 (raw file):
@tschottdorf Do you recall why we need to hold Comments from Reviewable |
Reviewed 4 of 4 files at r3. pkg/storage/client_raft_test.go, line 1773 at r3 (raw file):
why can't you just pkg/storage/client_raft_test.go, line 1791 at r3 (raw file):
I think you still want to check the error here:
pkg/storage/client_raft_test.go, line 1793 at r3 (raw file):
no need for the pkg/storage/replica.go, line 832 at r3 (raw file):
is there any interesting information to be gained by giving pkg/storage/replica.go, line 885 at r3 (raw file):
There's something wrong with this sentence. pkg/storage/replica.go, line 2620 at r3 (raw file):
it may be clearer to call it pkg/storage/replica.go, line 2636 at r3 (raw file):
this pattern seems very fragile. I think you might want to wrap this bit in a Comments from Reviewable |
188b45d
to
eef96a3
Compare
Review status: 2 of 4 files reviewed at latest revision, 11 unresolved discussions. pkg/storage/client_raft_test.go, line 1773 at r3 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Whoops, left over from before using pkg/storage/client_raft_test.go, line 1791 at r3 (raw file): Previously, tamird (Tamir Duberstein) wrote…
yup, Done. pkg/storage/client_raft_test.go, line 1793 at r3 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/replica.go, line 832 at r3 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Not really, not that I can think of at least. pkg/storage/replica.go, line 885 at r3 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Fixed. pkg/storage/replica.go, line 2620 at r3 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/replica.go, line 2636 at r3 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done (named return, checking the error in a defer). Comments from Reviewable |
Reviewed 2 of 2 files at r4. pkg/storage/client_raft_test.go, line 1773 at r3 (raw file): Previously, irfansharif (irfan sharif) wrote…
ah, it's a different type. we try to name those variables pkg/storage/client_raft_test.go, line 1791 at r4 (raw file):
here too, if you decide to rename. pkg/storage/replica.go, line 2559 at r4 (raw file):
nit: you're not using the name Comments from Reviewable |
@irfansharif sorry, should've been clearer: I'm fine with use of approximate quota. |
f52cc89
to
f32229f
Compare
Reviewed 2 of 5 files at r18, 5 of 5 files at r19. pkg/storage/quota_pool.go, line 154 at r19 (raw file):
s/to notified/to be notified/ pkg/storage/quota_pool.go, line 158 at r19 (raw file):
Why do we fill up the channel instead of setting it to nil or removing it from the slice completely? Both sides of this operation are carried out under the lock. pkg/storage/quota_pool.go, line 243 at r19 (raw file):
This loop appears three times; how about a Comments from Reviewable |
(please add the approximate quota in the RangeInfo so that it shows up in _status/ranges/local). Excited to see this go in! Reviewed 8 of 8 files at r20, 1 of 1 files at r21, 5 of 5 files at r22, 2 of 2 files at r23, 7 of 7 files at r24. pkg/storage/quota_pool_test.go, line 275 at r19 (raw file): Previously, irfansharif (irfan sharif) wrote…
Yeah, don't think I have a real point there. Thinking was that before you weren't ever exceeding the available quota, so less of the internal quota pool code was exercised. Comments from Reviewable |
Cc @BramGruneir. Approximate quota should be added to the range debug page. Review status: all files reviewed at latest revision, 13 unresolved discussions, some commit checks failed. Comments from Reviewable |
nit: looks like the last 4 commits should be squashed into one, wdyt? Apologies for the volume of comments, I missed a few revisions of this work. Excited to see it nearing completion! Reviewed 1 of 1 files at r6, 10 of 10 files at r10, 7 of 7 files at r14, 3 of 5 files at r15, 8 of 8 files at r20, 1 of 5 files at r22, 7 of 7 files at r24. pkg/storage/client_raft_test.go, line 1775 at r24 (raw file):
does this second call return the same value as the first? might want to extract a local (as you do below) pkg/storage/client_test.go, line 194 at r20 (raw file):
can you use the anonymous struct pattern?
Also, does this need to be a RWMutex, or can it just be a plain mutex? pkg/storage/helpers_test.go, line 260 at r24 (raw file):
lease holder of raft leader? pkg/storage/helpers_test.go, line 275 at r24 (raw file):
raft leader? pkg/storage/quota_pool.go, line 16 at r24 (raw file):
consider separating this from the above header, since this isn't part of our license - it really explains the following header. pkg/storage/quota_pool.go, line 69 at r24 (raw file):
are all members protected by this mutex? can this use the anonymous struct pattern?
pkg/storage/quota_pool.go, line 72 at r24 (raw file):
too many phrasings pkg/storage/quota_pool.go, line 73 at r24 (raw file):
by a pkg/storage/quota_pool.go, line 76 at r24 (raw file):
double space also, can we avoid the term "thread"? either a "waiter", a "channel", or a "goroutine" pkg/storage/quota_pool.go, line 155 at r24 (raw file):
you don't reset the timer here, so this will only ever fire once. I think you can do without If you did want to reset the timer here, note that the value sent on pkg/storage/quota_pool.go, line 161 at r24 (raw file):
to be notified pkg/storage/quota_pool.go, line 165 at r24 (raw file):
nit (throughout): note that some editors will eagerly re-wrap this unless you add an empty comment line above this line. pkg/storage/quota_pool.go, line 184 at r24 (raw file):
I think you can simply this to avoid the extra Unlock and return (applies in all 3 places, I think):
pkg/storage/quota_pool_test.go, line 86 at r24 (raw file):
throughout: how come buffered? pkg/storage/quota_pool_test.go, line 88 at r24 (raw file):
throughout: might be easier to just always send the error and check it at the receiver since you are checking it at the receiver anyhow.
pkg/storage/replica.go, line 868 at r24 (raw file):
this comment is now misplaced (it should come after these assertions) pkg/storage/replica.go, line 874 at r24 (raw file):
might be good to include the unexpected value in all of these assertions. possibly nothing to log here, but the others are numeric and possibly useful. pkg/storage/replica.go, line 886 at r24 (raw file):
how can pkg/storage/replica.go, line 898 at r24 (raw file):
this looks like an assertion, but it's randomly a different style than the ones above. How about:
pkg/storage/replica.go, line 950 at r24 (raw file):
delta seems redundant with numReleases. can we just have one? pkg/storage/replica.go, line 956 at r24 (raw file):
Perhaps this can be:
the pkg/storage/replica.go, line 2758 at r24 (raw file):
when is it possible for this to be nil? pkg/storage/replica.go, line 2985 at r24 (raw file):
nit: no need for the func here, you can write pkg/storage/replica_test.go, line 6259 at r24 (raw file):
nit: looks like an errant addition pkg/storage/replica_test.go, line 6799 at r24 (raw file):
how come it's ok to proceed if repl.mu.commandSizes is nil? pkg/storage/replica_test.go, line 6800 at r24 (raw file):
can you add a comment explaining why this has to happen before pkg/storage/replica_test.go, line 6803 at r24 (raw file):
nit: called in one place; perhaps better to inline it? Comments from Reviewable |
f32229f
to
4aa1893
Compare
Done.
I don't mind, less work for me. I'll still keep the separate commit messages however given how many things change across the commits. Thank you all for your reviews!! Review status: 2 of 14 files reviewed at latest revision, 40 unresolved discussions. pkg/storage/client_raft_test.go, line 1775 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/client_test.go, line 194 at r20 (raw file):
Done.
We were using pkg/storage/helpers_test.go, line 260 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/helpers_test.go, line 275 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/quota_pool.go, line 154 at r19 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Done. pkg/storage/quota_pool.go, line 158 at r19 (raw file): Previously, bdarnell (Ben Darnell) wrote…
We cannot remove it from the slice because it's position may have changed since we first added it to the queue (it may have moved further ahead in the queue of previous acquisitions ran to completion/got cancelled).
All we've done is set our local variable to
where the
Which works too but I find one cleaner than the other. Additionally when setting pkg/storage/quota_pool.go, line 243 at r19 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Done. pkg/storage/quota_pool.go, line 16 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Sure. pkg/storage/quota_pool.go, line 69 at r24 (raw file):
Not exactly, we also use the mutex to guarantee only one pkg/storage/quota_pool.go, line 72 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/quota_pool.go, line 73 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done, this is why I failed the ELPE :( pkg/storage/quota_pool.go, line 76 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/quota_pool.go, line 155 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/quota_pool.go, line 161 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/quota_pool.go, line 165 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/quota_pool.go, line 184 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
pulled this out into a separate pkg/storage/quota_pool_test.go, line 86 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Unnecessary, removed. pkg/storage/quota_pool_test.go, line 88 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/replica.go, line 868 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/replica.go, line 874 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/replica.go, line 886 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
ah, artifact. Good eye, only happens if we're becoming a follower. pkg/storage/replica.go, line 898 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/replica.go, line 950 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/replica.go, line 956 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/replica.go, line 2758 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
when it's not the leader replica. pkg/storage/replica.go, line 2985 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/replica_test.go, line 6259 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/replica_test.go, line 6799 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
it won't, in this specific test there's only one replica therefore pkg/storage/replica_test.go, line 6800 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Removed entirely. pkg/storage/replica_test.go, line 6803 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Removed entirely. Comments from Reviewable |
Review status: 2 of 14 files reviewed at latest revision, 33 unresolved discussions, some commit checks pending. pkg/storage/quota_pool.go, line 158 at r19 (raw file):
Yes, I was assuming we'd iterate over the queue to find its current position.
I don't think the pointer is necessary. We don't need to overwrite our local variable, just the one in the queue:
Yes, but it's already all happening under the lock. (If you were able to move some of this out of the lock, that would be a reason to use the non-standard "fill up the channel" pattern) Comments from Reviewable |
Reviewed 12 of 12 files at r25. Comments from Reviewable |
Note that keeping the commits separate isn't free either - there was a fair amount of churn in this PR, and keeping these commits separate will make it much harder to dig through the git history if that's ever needed (and experience suggests it will be needed). Reviewed 1 of 12 files at r8, 12 of 12 files at r25. pkg/storage/helpers_test.go, line 275 at r24 (raw file): Previously, irfansharif (irfan sharif) wrote…
nit: you write "leaseholder" here but "lease holder" above. pkg/storage/quota_pool.go, line 76 at r24 (raw file): Previously, irfansharif (irfan sharif) wrote…
heh, the word thread still appears dozens of times in this PR. pkg/storage/quota_pool_test.go, line 96 at r25 (raw file):
I think you can do a direct comparison here against pkg/storage/quota_pool_test.go, line 97 at r25 (raw file):
you should include the unexpected error received in this string. pkg/storage/quota_pool_test.go, line 132 at r25 (raw file):
ditto pkg/storage/quota_pool_test.go, line 164 at r25 (raw file):
ditto pkg/storage/replica.go, line 2758 at r24 (raw file): Previously, irfansharif (irfan sharif) wrote…
Ah, of course. pkg/storage/replica.go, line 951 at r25 (raw file):
this is casting uint64 to int64, then you cast int to int64 to match, and then you cast this back to uint64 when you add it to Comments from Reviewable |
Review status: all files reviewed at latest revision, 19 unresolved discussions, all commit checks successful. pkg/storage/helpers_test.go, line 275 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/quota_pool.go, line 158 at r19 (raw file):
I see. Not that I've verified this experimentally but I imagine the case where a large command causes a backlog of acquisitions queued up, subsequent cancellations (say due to timeouts for example, I assume this is a thing) could potentially mean looping over a large number of entries, all the while holding the lock (we're modifying pkg/storage/quota_pool.go, line 76 at r24 (raw file): Previously, tamird (Tamir Duberstein) wrote…
whoops, done. pkg/storage/quota_pool_test.go, line 96 at r25 (raw file): Previously, tamird (Tamir Duberstein) wrote…
ah, didn't know this was a thing. Done. pkg/storage/quota_pool_test.go, line 97 at r25 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/quota_pool_test.go, line 132 at r25 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/quota_pool_test.go, line 164 at r25 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/replica.go, line 951 at r25 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done, an apparently it's not necessary. TIL. Comments from Reviewable |
ebcbdc5
to
b4df264
Compare
Just nits at this point, thanks for addressing my comments! as far as I'm concerned. Reviewed 4 of 4 files at r26. pkg/storage/quota_pool.go, line 236 at r26 (raw file):
double space >.< pkg/storage/quota_pool_test.go, line 132 at r25 (raw file): Previously, irfansharif (irfan sharif) wrote…
Doesn't look done (include the unexpected error) pkg/storage/quota_pool_test.go, line 29 at r26 (raw file):
bunch of occurrences of "thread" in this file, too. pkg/storage/quota_pool_test.go, line 97 at r26 (raw file):
pkg/storage/quota_pool_test.go, line 165 at r26 (raw file):
Comments from Reviewable |
Use another mutex to protect access to multiTestContext.nodeIDtoAddr. Reusing the same mutex guarding mtc.{senders,stores,nodeLivenesses} leads to deadlocks due to inconsistent lock ordering. Consider multiTestContext.FirstRange() - We acquire a read lock on mtc.mu when iterating over mtc.senders - Internally we call Replica.Desc() thus acquiring a read lock on Replica.mu. (lock ordering: multiTestContext.mu, Replica.mu) Consider the case where we want to check for "healthy" RPC connections to follower replicas when handling raft.Ready - We acquire a lock on Replica.mu to handle raft.Ready - We call Replica.store.cfg.Transport.resolver(replica.NodeID). The default resolver function for multiTestContext is mtc.getNodeIDAddress, which accesses the mtc.nodeIDtoAddr map and consequently acquires a read lock on mtc.mu. (lock ordering: Replica.mu, multiTestContext.mu) The non-test implementation of Transport and the corresponding resolver does not have this lock ordering issue.
b4df264
to
4a6a11f
Compare
The leader maintains a pool of "proposal quota". Before proposing a Raft command, we acquire proposal quota equal to the size of the command. When all of the healthy followers have committed the entry, quota equal to the size of the corresponding command is returned to the pool. We maintain on Replica a map associating storagebase.CmdIDKey to the corresponding command size. Downstream of raft we extract the same storagebase.CmdIDKey from the command and append the command size to quotaReleaseQueue. This queue is subsequently used to return quota back to the pool once all the followers have caught up. We only consider "healthy" followers to be those that have "healthy" RPC connections when determining if a unit of quota should be returned to the pool.
4a6a11f
to
1b4ebeb
Compare
Reviewed 13 of 13 files at r28. Comments from Reviewable |
thanks again tamir! rebased to two commits like asked for. Review status: all files reviewed at latest revision, 16 unresolved discussions, all commit checks successful. pkg/storage/quota_pool.go, line 236 at r26 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/quota_pool_test.go, line 132 at r25 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/quota_pool_test.go, line 29 at r26 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/quota_pool_test.go, line 97 at r26 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. pkg/storage/quota_pool_test.go, line 165 at r26 (raw file): Previously, tamird (Tamir Duberstein) wrote…
Done. Comments from Reviewable |
This was an oversight introduced in cockroachdb#15802, the `undoQuotaAcquisition` was intended to be used for all proposal errors but we seem to have skipped the very first one. It seems to have been a relic of the earlier structure where in the event of proposal errors the acquired quota was released within `Replica.propose` itself, and not left to the caller. Fixes (hopefully) cockroachdb#17826.
Revisiting #13869.
The leader maintains a pool of "proposal quota". Before proposing a Raft
command, we acquire proposal quota equal to the size of the
command. When all of the healthy followers have committed the entry,
quota equal to the size of the corresponding command is returned to the
pool. We maintain on Replica a map associating
storagebase.CmdIDKe
y tothe corresponding command size. Downstream of raft we extract the same
storagebase.CmdIDKey
from the command and append the command size toquotaReleaseQueue. This queue is subsequently used to return quota back
to the pool once all the followers have caught up.
We only consider "healthy" followers to be those that have "healthy" RPC
connections when determining if a unit of quota should be returned to the
pool.
cc @bdarnell.