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
sql: use a new ClearRange RPC to improve DROP|TRUNCATE efficiency #20601
sql: use a new ClearRange RPC to improve DROP|TRUNCATE efficiency #20601
Conversation
@vivekmenezes @tschottdorf I definitely need you both to review this. @petermattis if you have time. |
Actually, scratch that. @petermattis need your review on this as well for the C++ changes. |
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.
I recommend a SHOW KV TRACE FOR ...
SQL logic test to confirm the change is observable in traces.
pkg/sql/tablewriter.go
Outdated
// would not set the GC deadline, but would still expect the data | ||
// to remain historically queryable until the zone's TTL expires. | ||
if td.tableDesc().GCDeadline == 0 { | ||
log.VEventf(ctx, 2, "backwards-compatible DelRange %s - %s", resume.Key, resume.EndKey) |
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.
Not sure the string "backwards-compatible" is needed / useful.
At any rate you need to update the condition in sql/show_trace.go
((p *planner) ShowTrace
) accordingly.
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.
Reverted the "backwards-compatible" bit.
pkg/sql/tablewriter.go
Outdated
if timeutil.Since(timeutil.Unix(0, td.tableDesc().GCDeadline)) < 0 { | ||
panic(fmt.Sprintf("not past the GC deadline: %s", td.tableDesc())) | ||
} | ||
log.VEventf(ctx, 2, "ClearRange %s - %s", resume.Key, resume.EndKey) |
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.
And this needs to be added to (p *planner) ShowTrace
too.
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.
Added to ShowTrace
. Unfortunately it's really difficult to see either of these because both are run through an asynchronous pathway which doesn't show up SHOW KV TRACE...
.
a784359
to
191f724
Compare
Reviewed 18 of 20 files at r1, 3 of 3 files at r2. pkg/roachpb/method.go, line 41 at r2 (raw file):
pkg/sql/drop_table.go, line 315 at r2 (raw file):
Let's complete this by commenting on why we can't use the GCDeadline mechanism for interleaved tables. Soon enough, we're going to want to when we detect pkg/sql/drop_table.go, line 325 at r2 (raw file):
Consider pkg/sql/drop_table.go, line 325 at r2 (raw file):
Do we make sure that this isn't overridden anywhere? pkg/sql/tablewriter.go, line 789 at r2 (raw file):
"eventually".. how eventual? After RocksDB compactions? pkg/storage/batcheval/cmd_clear_range.go, line 73 at r2 (raw file):
It makes things a bit easier to skim pkg/storage/batcheval/cmd_clear_range.go, line 99 at r2 (raw file):
nit: should we just move this to the block above? Seems like we're effectively checking the same condition twice. Comments from Reviewable |
Review status: all files reviewed at latest revision, 9 unresolved discussions, some commit checks failed. pkg/roachpb/method.go, line 41 at r2 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Done. pkg/sql/drop_table.go, line 315 at r2 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Done. pkg/sql/drop_table.go, line 325 at r2 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Done. pkg/sql/drop_table.go, line 325 at r2 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
What do you mean overridden? pkg/sql/tablewriter.go, line 789 at r2 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
I cleaned this up. No sense here in commenting on compaction. pkg/storage/batcheval/cmd_clear_range.go, line 73 at r2 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Done. pkg/storage/batcheval/cmd_clear_range.go, line 99 at r2 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Done. Comments from Reviewable |
191f724
to
23cc697
Compare
Review status: 17 of 21 files reviewed at latest revision, 3 unresolved discussions, some commit checks failed. pkg/sql/drop_table.go, line 325 at r2 (raw file): Previously, spencerkimball (Spencer Kimball) wrote…
Is it possible to set a GCDeadline on a table descriptor and then set a later deadline on the same descriptor? I'd expect the same mechanism that prevents us from dropping a table twice would also ensure that this isn't possible, but I'd like to be sure. Comments from Reviewable |
Review status: 17 of 21 files reviewed at latest revision, 5 unresolved discussions, some commit checks failed. pkg/sql/tablewriter.go, line 810 at r3 (raw file):
We may want to add a similar TODO here as the one you've added before (Ugh, this is also a bit chaotic. There is now a slow, fast, and faster path in two functions, for which the path is chosen by two conditions that are far apart. I don't have any good suggestions for how to prevent that. Making 3 different delete functions and consolidating the conditions into helpers in this file doesn't seem like a great alternative, so I'm not asking for anything here.) pkg/sql/tablewriter.go, line 925 at r3 (raw file):
We should be able to use I don't know if a user can query from an index AOST after it has been dropped. If they can, we'll have to also do a similar GCDeadline on an IndexDescriptor. If they can't, then this should be a simple change. Comments from Reviewable |
Review status: 17 of 21 files reviewed at latest revision, 9 unresolved discussions, some commit checks failed. pkg/roachpb/api.proto, line 249 at r3 (raw file):
What bad things will happen if a pkg/sql/drop_table.go, line 325 at r2 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Also, it is probably worth a bit of paranoia and ensure that pkg/sql/schema_changer.go, line 1068 at r3 (raw file):
This might be increasing pkg/sql/tablewriter.go, line 836 at r3 (raw file):
This will fail in mixed-version clusters. I think we need to protect this code path with a version upgrade check. pkg/storage/batcheval/cmd_clear_range.go, line 50 at r3 (raw file):
Is there anything else we can do to enforce "correct" usage? For example, can we check the timestamp cache to verify user-keys have not be accessed recently. Comments from Reviewable |
Review status: 17 of 21 files reviewed at latest revision, 9 unresolved discussions, some commit checks failed. Comments from Reviewable |
Review status: 17 of 21 files reviewed at latest revision, 9 unresolved discussions, some commit checks failed. pkg/sql/schema_changer.go, line 1068 at r3 (raw file): Previously, petermattis (Peter Mattis) wrote…
I think this should be fine. If this wasn't a drop table mutation, it would have an impact. Any future mutations would be delayed until after this time. Basically, when a gossip update for a table descriptor occurs or a schema change finishes, a timer is reset ( Comments from Reviewable |
23cc697
to
1088dca
Compare
Review status: 17 of 21 files reviewed at latest revision, 9 unresolved discussions, some commit checks failed. pkg/roachpb/api.proto, line 249 at r3 (raw file): Previously, petermattis (Peter Mattis) wrote…
However, the above points are irrelevant. I've added a comment here indicating that this method must only be called on key spans which are guaranteed to be inactive and will never see future writes. pkg/sql/drop_table.go, line 325 at r2 (raw file): Previously, petermattis (Peter Mattis) wrote…
@nvanbenschoten Yes, it is not possible. A table cannot be dropped twice and this is the only code path which updates The TTL which we use to GC is advisory and subject to change for any range in the system. Readers which might have been counting on historical reads at some timestamp, which is suddenly past an aggressively reduced TTL, will get GC threshold error, which is the correct outcome. @petermattis that should never be a problem because of table leases. I expect many operators to set a table or databases TTL to 0 and then drop. pkg/sql/schema_changer.go, line 1068 at r3 (raw file): Previously, lego (Joey Pereira) wrote…
Should be fine. Each one of these schema changers for a table is run independently based on the shortest execAfter deadline amongst the pending changers. Separately, the pkg/sql/tablewriter.go, line 810 at r3 (raw file): Previously, lego (Joey Pereira) wrote…
This code will remain the same, even after we support this faster path with interleaved tables. The point of this isn't to deal with interleaved tables, but with the migration between cockroach Yes, this supporting legacy cruft gets ugly. I've moved this into a new method named ...and lo and behold making this change reminds me that this requires a new feature version, requiring the full cluster to upgrade in order to make use of this new faster drop/truncate path. So thank you for complaining. pkg/sql/tablewriter.go, line 836 at r3 (raw file): Previously, petermattis (Peter Mattis) wrote…
Done. pkg/sql/tablewriter.go, line 925 at r3 (raw file): Previously, lego (Joey Pereira) wrote…
Adding a TODO. I've spent too long already this weekend understanding a small bit of SQL land. Probably best to get some miles on this fast path before diving into index truncation. My guess is that we'll need to do the same thing as with tables because I don't see any reason we'd be disallowed from reading from indexes historically. But take that with a grain of salt. pkg/storage/batcheval/cmd_clear_range.go, line 50 at r3 (raw file): Previously, petermattis (Peter Mattis) wrote…
Not sure what the threshold would be when examining the timestamp cache. In any case, I'm not too worried about concurrent reads because we update the GC threshold value – we should correctly return an error for any subsequent reads which arrive after the Comments from Reviewable |
Review status: 16 of 22 files reviewed at latest revision, 9 unresolved discussions, some commit checks pending. pkg/sql/tablewriter.go, line 925 at r3 (raw file): Previously, spencerkimball (Spencer Kimball) wrote…
👏 kudos for becoming a SQL intern for the weekend! :) Comments from Reviewable |
1088dca
to
ea05c19
Compare
Review status: 15 of 23 files reviewed at latest revision, 8 unresolved discussions, some commit checks pending. pkg/sql/tablewriter.go, line 925 at r3 (raw file): Previously, lego (Joey Pereira) wrote…
It's been very rewarding! I still want to tackle the task of post-hoc adjustments to the gc deadline in order to allow operators to free up the space faster if that becomes an issue. Comments from Reviewable |
Reviewed 14 of 20 files at r1, 1 of 3 files at r2, 1 of 4 files at r3, 7 of 7 files at r4. pkg/roachpb/api.proto, line 258 at r4 (raw file):
Document this field. Why is it different from the timestamp at which the command executes? pkg/settings/cluster/cockroach_versions.go, line 104 at r4 (raw file):
@solongordon 's #20587 is also creating this version; whichever one commits second will have to change to 1.1-6. pkg/sql/tablewriter.go, line 820 at r4 (raw file):
Why is it GCThreshold in ClearRangeRequest and GCDeadline in the table descriptor? GCThreshold and GCDeadline sound awfully similar; if they're not the same they should have names that indicate their meanings. (Isn't GCDeadline really GCAfter?) pkg/storage/batcheval/cmd_clear_range.go, line 104 at r4 (raw file):
According to comments in clearRangeData, it's bad to call ClearRange for small amounts of data, so it falls back to individual deletions in this case. Do we need to do the same here? Comments from Reviewable |
In master...tschottdorf:experiment/fastdrops I made I think you're secretly using a txn, because of this code func (td *tableDeleter) init(txn *client.Txn) error {
td.txn = txn
td.b = txn.NewBatch()
return nil
} the batch of which you are then using. On the plus side, looking at the range-spanning-enforcement code if ba.Txn == nil && ba.IsPossibleTransaction() && ba.ReadConsistency != roachpb.INCONSISTENT {
// TODO(nvanbenschoten): if this becomes an issue for RangeLookup
// scans, we could look into changing IsPossibleTransaction for
// ScanRequest/ReverseScanRequest to detect RangeLookups.
responseCh <- response{pErr: roachpb.NewError(&roachpb.OpRequiresTxnError{})}
return
} it seems that this would do the right thing, since Basically LGTM, though some work is left to do in the comments. Review status: all files reviewed at latest revision, 21 unresolved discussions, all commit checks successful. pkg/roachpb/method.go, line 45 at r4 (raw file):
pkg/sql/drop_table.go, line 318 at r4 (raw file):
nit: double space pkg/sql/drop_table.go, line 326 at r4 (raw file):
pkg/sql/drop_test.go, line 53 at r4 (raw file):
Also should be a line down, inside the pkg/sql/drop_test.go, line 67 at r4 (raw file):
NYC, but don't we auto-generate an pkg/sql/schema_changer.go, line 1068 at r3 (raw file):
+1. I brought this up in a past review in which I touched this code and the impression I got was that this could easily go away (or be reduced to basically nothing). I think there's some interaction with synchronous schema changes which we don't want picked up by the async method here? @vivekmenezes would know. pkg/sql/schema_changer_test.go, line 2512 at r4 (raw file):
nit: remove trailing dot pkg/sql/tablewriter.go, line 812 at r4 (raw file):
pkg/sql/tablewriter.go, line 820 at r4 (raw file): Previously, bdarnell (Ben Darnell) wrote…
I'm not quite sure whether setting I think the right thing to do is to not send a pkg/sql/tablewriter.go, line 930 at r4 (raw file):
Seems worth doing this sooner rather than later. Does doing that change anything in the design of (the SQL parts of) this feature? Would we just add a similar deadline on the index descriptor? pkg/storage/batcheval/cmd_clear_range.go, line 59 at r4 (raw file):
Check that there's no Txn. pkg/storage/batcheval/cmd_clear_range.go, line 76 at r4 (raw file):
I'd prefer if you set the zeroes on pkg/storage/batcheval/cmd_clear_range.go, line 78 at r4 (raw file):
Stats yoga always makes me suspicious. Change this code to assert that both are equal in race builds, i.e. something like fast := desc.StartKey.Equal(args.Key) && desc.EndKey.Equal(args.EndKey)
var subtractStats enginepb.MVCCStats
var assertStats enginepb.MVCCStats
if fast {
subtractStats := cArgs.EvalCtx.GetMVCCStats()
subTractStats.SysCount, subtractStats.SysBytes = 0, 0 // no changes
if util.RaceEnabled {
assertStats = subtractStats
}
}
if !fast || util.RaceEnabled {
/* do the iterator thing without actually subtracting */
}
if util.RaceEnabled {
if !assertStats.Equal(subtractStats) {
log.Fatalf(ctx, "fast-path MVCCStats computation gave wrong result: diff(fast, slow) = %s", pretty.Diff(assertStats, subtractStats))
}
}
cArgs.Stats.Subtract(subtractStats) pkg/storage/batcheval/cmd_clear_range.go, line 94 at r4 (raw file):
You'd use pkg/storage/batcheval/cmd_clear_range.go, line 104 at r4 (raw file): Previously, bdarnell (Ben Darnell) wrote…
I think simple thresholding might work well here. If Comments from Reviewable |
Review status: all files reviewed at latest revision, 21 unresolved discussions, all commit checks successful. pkg/sql/schema_changer.go, line 1068 at r3 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Yeah the 6 minute interval is pretty arbitrary. It was put in to allow the synchronous path to grab the schema change lease before anyone else #20488 has been filed Comments from Reviewable |
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.
Nicely done! My main comment is to not change the TableDescriptor at all and use ModificationTime + TTL to know when to delete the data.
// the timestamp after which the table's contents will be cleared | ||
// from the cluster. In nanoseconds since the epoch. | ||
optional int64 gc_deadline = 29 [(gogoproto.nullable) = false, | ||
(gogoproto.customname) = "GCDeadline"]; |
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.
There isn't a need for this. What you can do is use the ModificationTime on the table and ClearRange when (!UpVersion && CurrentTime > ModificationTime +TTL)
// instead of the standard delay. | ||
if table.Dropped() && table.GCDeadline != 0 { | ||
schemaChanger.execAfter = timeutil.Unix(0, table.GCDeadline) | ||
} |
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.
this is safe to do!
pkg/sql/tablewriter.go
Outdated
td.b.AddRawRequest(crr) | ||
if _, err := td.finalize(ctx, traceKV); err != nil { | ||
return resume, err | ||
} |
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.
Is this expected to be fast? The reason I ask is because we don't want it getting in the way of user traffic.
@@ -889,6 +927,8 @@ func (td *tableDeleter) deleteIndexFast( | |||
if traceKV { | |||
log.VEventf(ctx, 2, "DelRange %s - %s", resume.Key, resume.EndKey) | |||
} | |||
// TODO(vivekmenezes): adapt index deletion to use the same GC | |||
// deadline / ClearRange fast path that table deletion uses. |
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.
noted!
ea05c19
to
2fd63e3
Compare
Yes, we're definitely using a txn. Are you saying we shouldn't because it's just confusing semantics as Review status: all files reviewed at latest revision, 25 unresolved discussions, all commit checks successful. pkg/roachpb/api.proto, line 258 at r4 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Actually I think that suggestion is better. I'm removing gc_threshold from the proto. pkg/roachpb/method.go, line 45 at r4 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/settings/cluster/cockroach_versions.go, line 104 at r4 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Blegh pkg/sql/drop_table.go, line 318 at r4 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/sql/drop_table.go, line 326 at r4 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/sql/drop_test.go, line 53 at r4 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/sql/drop_test.go, line 67 at r4 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/sql/schema_changer.go, line 1069 at r4 (raw file): Previously, vivekmenezes wrote…
Thanks for weighing in. pkg/sql/schema_changer_test.go, line 2512 at r4 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/sql/tablewriter.go, line 812 at r4 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/sql/tablewriter.go, line 820 at r4 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
I've removed pkg/sql/tablewriter.go, line 825 at r4 (raw file): Previously, vivekmenezes wrote…
The expectation is that this will be very fast. pkg/sql/tablewriter.go, line 930 at r4 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
I think it would be analogous, but I haven't looked into the index descriptor code carefully to see if that's true. I agree we should do this asap. @vivekmenezes, who's plate should we put this on? pkg/sql/tablewriter.go, line 931 at r4 (raw file): Previously, vivekmenezes wrote…
Done. pkg/sql/sqlbase/structured.proto, line 632 at r4 (raw file): Previously, vivekmenezes wrote…
The pkg/storage/batcheval/cmd_clear_range.go, line 59 at r4 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/storage/batcheval/cmd_clear_range.go, line 76 at r4 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/storage/batcheval/cmd_clear_range.go, line 78 at r4 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. Good idea. pkg/storage/batcheval/cmd_clear_range.go, line 94 at r4 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/storage/batcheval/cmd_clear_range.go, line 104 at r4 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done and added a unittest to verify. Comments from Reviewable |
672815c
to
0e37895
Compare
Review status: 15 of 28 files reviewed at latest revision, 25 unresolved discussions, all commit checks successful. pkg/sql/tablewriter.go, line 930 at r4 (raw file): Previously, spencerkimball (Spencer Kimball) wrote…
You can put it on my plate once you've merged this change I'll send you a PR for this change. I suspect I'll just Clear the index data rather than wait on it. One problem with waiting is that the current schema changer processes schema changes one at a time, and so waiting will hold up all other schema changes on the table. Since the index is derived data there isn't a great danger in clearing out the index. Comments from Reviewable |
Review status: 15 of 28 files reviewed at latest revision, 22 unresolved discussions, all commit checks successful. pkg/sql/sqlbase/structured.proto, line 632 at r4 (raw file): Previously, spencerkimball (Spencer Kimball) wrote…
I'm okay with keeping it in. Not a big deal really Comments from Reviewable |
@tschottdorf does this still require additional review? |
Review status: 15 of 28 files reviewed at latest revision, 19 unresolved discussions, some commit checks failed. pkg/sql/drop_test.go, line 217 at r5 (raw file):
Do you still need this? Would be good to see that a 0 TTL drops the table right away even in the real world where this knob isn't set. pkg/sql/drop_test.go, line 595 at r5 (raw file):
Do you still need this? Would be good to see that a 0 TTL drops the table right away even in the real world where this knob isn't set. pkg/sql/tablewriter.go, line 930 at r4 (raw file): Previously, vivekmenezes wrote…
I filed #20696 to track this. I think it needs a bit of discussion due to time travel complications with this approach. Not insurmountable, but out of scope for this PR. pkg/storage/batcheval/cmd_clear_range.go, line 104 at r5 (raw file):
pkg/storage/batcheval/cmd_clear_range.go, line 106 at r5 (raw file):
Don't return pkg/storage/batcheval/cmd_clear_range.go, line 135 at r5 (raw file):
You need to also declare a full range-local span for this method to make this statement true. You implicitly do because you declare pkg/storage/batcheval/cmd_clear_range.go, line 155 at r5 (raw file):
a cop-mutation? pkg/storage/batcheval/cmd_clear_range_test.go, line 64 at r5 (raw file):
nit: pkg/storage/batcheval/cmd_clear_range_test.go, line 129 at r5 (raw file):
Comments from Reviewable |
Review status: 15 of 28 files reviewed at latest revision, 19 unresolved discussions, some commit checks failed. pkg/settings/cluster/cockroach_versions.go, line 104 at r4 (raw file): Previously, spencerkimball (Spencer Kimball) wrote…
Sorry, guess I won the race here. Comments from Reviewable |
Previously, dropping or truncating a table would result in significant write amplification as each key in the table was individually tombstoned, and then individually deleted on eventual GC. This change adds a new field to the table descriptor indicating a GC deadline, after which the contents of the table will be deleted using a new KV ClearRange API call. This efficiently uses the lower level storage rocksdb::DeleteRange, which creates a range tombstone across a key span, usually the entire range. The ClearRange API call also updates the range's last GC timestamp to prevent historical reads from incorrectly returning empty results when reading subsequent to a ClearRange. A dropped table's GC deadline is now visible in the `crdb_internal.tables` table. Release note (sql change): dramatic improvement in efficiency when `DROP|TRUNCATE TABLE` is used.
0e37895
to
bad7f47
Compare
Review status: 8 of 28 files reviewed at latest revision, 19 unresolved discussions. pkg/settings/cluster/cockroach_versions.go, line 104 at r4 (raw file): Previously, solongordon wrote…
Done. pkg/sql/drop_test.go, line 217 at r5 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
We still need the knob for other schema changes which are tested. I've removed it here. pkg/sql/drop_test.go, line 595 at r5 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Removed this instance as well. pkg/sql/sqlbase/structured.proto, line 632 at r4 (raw file): Previously, vivekmenezes wrote…
Done. pkg/storage/batcheval/cmd_clear_range.go, line 104 at r5 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/storage/batcheval/cmd_clear_range.go, line 106 at r5 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/storage/batcheval/cmd_clear_range.go, line 135 at r5 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
But range-local stats are counted only as pkg/storage/batcheval/cmd_clear_range.go, line 155 at r5 (raw file): Nicely done. pkg/storage/batcheval/cmd_clear_range_test.go, line 64 at r5 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/storage/batcheval/cmd_clear_range_test.go, line 129 at r5 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. Comments from Reviewable |
🎉 Reviewed 12 of 20 files at r1, 1 of 3 files at r2, 2 of 7 files at r4, 13 of 13 files at r5, 11 of 11 files at r6. pkg/storage/batcheval/cmd_clear_range.go, line 106 at r5 (raw file): Previously, spencerkimball (Spencer Kimball) wrote…
Not done. Comments from Reviewable |
Release note: None
pkg/storage/batcheval/cmd_clear_range.go, line 106 at r5 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Shoot. Sending another PR. Comments from Reviewable |
storage: fix a missed comment from #20601
Previously, dropping or truncating a table would result in
significant write amplification as each key in the table was
individually tombstoned, and then individually deleted on
eventual GC.
This change adds a new field to the table descriptor indicating
a GC deadline, after which the contents of the table will be deleted
using a new KV ClearRange API call. This efficiently uses the lower
level storage rocksdb::DeleteRange, which creates a range tombstone
across a key span, usually the entire range.
The ClearRange API call also updates the range's last GC timestamp
to prevent historical reads from incorrectly returning empty results
when reading subsequent to a ClearRange.
A dropped table's GC deadline is now visible in the
crdb_internal.tables
table.Release note (sql change): dramatic improvement in efficiency when
DROP|TRUNCATE TABLE
is used.