-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
kvserver: recompute stats after mvcc gc #83194
Conversation
6e4c39b
to
0aca337
Compare
bea7534
to
8557a29
Compare
@erikgrinaker I cleaned this up and added a test, do you want to take a look? |
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.
Thanks for handling this! Might deserve a brief release note?
Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status:complete! 0 of 0 LGTMs obtained (waiting on @lunevalex)
pkg/kv/kvserver/mvcc_gc_queue.go
line 616 at r1 (raw file):
scoreAfter := makeMVCCGCQueueScore( ctx, repl, repl.store.Clock().Now(), lastGC, conf.TTL(), canAdvanceGCThreshold)
We're reusing the old lastGC
and canAdvanceGCThreshold
here, so the score/decision isn't what it would be if the GC queue reprocessed it. That seems mostly beneficial, since it avoids issues with e.g. cooldown timers, but it might be worth calling out.
pkg/kv/kvserver/mvcc_gc_queue.go
line 627 at r1 (raw file):
// them then to spin the GC queue. if scoreAfter.ShouldQueue { log.Infof(ctx, "triggering stats re-computation")
Would be good to elaborate slightly here, and include the previous and current GC scores for debugging. Something like "GC still needed following GC, recomputing MVCC stats (old score %s; new score %s)". The score formatting is pretty verbose though, so see how it looks and consider dumping it on multiple lines or sth.
pkg/kv/kvserver/mvcc_gc_queue.go
line 635 at r1 (raw file):
err := repl.store.db.Run(ctx, &b) if err != nil { log.Errorf(ctx, "Failed to recompute stats with error=%s", err)
nit: start with lowercase.
8557a29
to
201cdaa
Compare
Touched cockroachdb#82920 There is at least one known issue in MVCC stats calculation and there maybe more. This could lead to the MVCC GC Queue spinning on ranges with bad stats. To prevent the queue from spinning it should recompute the stats if it detects that they are wrong. The easiest mechanism to do that is to check if the GC score wants to queue this range again after finishing GC, if it does it likely indicates something fishy with the stats. Release note: Change the MVCC GC queue to recompute MVCC stats on a range, if after doing a GC run it still thinks there is garbage in the range.
201cdaa
to
cda8806
Compare
TFTR! bors r+ |
Build succeeded: |
Touched #82920
There is at least one known issue in MVCC stats calculation and
there maybe more. This could lead to the MVCC GC Queue spinning on
ranges with bad stats. To prevent the queue from spinning it should
recompute the stats if it detects that they are wrong. The easiest
mechanism to do that is to check if the GC score wants to queue this
range again after finishing GC, if it does it likely indicates something
fishy with the stats.
Release note: Change the MVCC GC queue to recompute MVCC stats on a
range, if after doing a GC run it still thinks there is garbage in
the range.