Skip to content

Commit 63f2937

Browse files
craig[bot]michae2sumeerbholashghasemi
committed
156016: sql/*: load external statement hints from the hints cache r=DrewKimball a=michae2 **sql/\*: load external statement hints from the hints cache** When making a `sql.Statement`, call `MaybeGetStatementHints` to load any applicable external statement hints from the hint cache. We don't yet do anything with the hints once they're loaded, but we do save them in prepared statements. A few notable code paths are not yet loading hints from the hints cache: - SQL statements within UDFs and SPs - Views Informs: #153633 Release note: None --- **sql, sqltelemetry: add telemetry counter for external statement hints** Informs: #153633 Release note: None --- **sql/hints, builtins: add two more statement_hints_cache builtins** Add new builtins `crdb_internal.clear_statement_hints_cache` and `crdb_internal.await_statement_hints_cache` which will be useful for testing. The first builtin clears the hintCache, similar to `clear_query_plan_cache` and `clear_table_stats_cache`. (I debated whether this builtin should also set hintedHashes to nil and restart the changefeed, but that seems too different from `clear_table_stats_cache`.) The second builtin blocks until the hints cache rangefeed watcher has caught up with the present, which usually takes a couple of seconds. This is handy when we want to test a statement using the hint immediately after adding the hint to system.statement_hints. Informs: #153633 Release note: None --- **logictest: add tests for loading external statement hints** Test that we're loading external statement hints correctly. Informs: #153633 Release note: None 156303: kvserver: use Pebble snapshot for catchup scans r=stevendanna a=sumeerbhola The snapshot is used to create an iterator, which is recreated based on the storage.snapshot.recreate_iter_duration cluster setting, which defaults to 20s. This is mostly plumbing changes, except for catchup_scan.go. Fixes #133851 Epic: none Release note (ops change): The cluster setting storage.snapshot.recreate_iter_duration (default 20s) controls how frequently a long-lived engine iterator, backed by an engine snapshot, will be closed and recreated. Currently, it is only used for iterators used in rangefeed catchup scans. 156655: sql: update cluster version checks in ElementCreationMetadata r=shghasemi a=shghasemi This change adds `In_26_1OrLater` to the ElementCreationMetadata. It will be used in future commits to enable/disable new schema changer elements. It also removes `in_23_1OrLater` as it's no longer in use. Part of: #142918 Release note: None Co-authored-by: Michael Erickson <[email protected]> Co-authored-by: sumeerbhola <[email protected]> Co-authored-by: Shadi Ghasemitaheri <[email protected]>
4 parents 31d3354 + a49979e + 264bacc + fe42768 commit 63f2937

File tree

86 files changed

+1197
-653
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1197
-653
lines changed

pkg/backup/backupsink/file_sst_sink.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ func (s *FileSSTSink) copyPointKeys(ctx context.Context, dataSST []byte) (roachp
361361

362362
empty := true
363363
for iter.SeekGE(storage.MVCCKey{Key: keys.MinKey}); ; iter.Next() {
364-
if err := s.pacer.Pace(ctx); err != nil {
364+
if _, err := s.pacer.Pace(ctx); err != nil {
365365
return nil, err
366366
}
367367
if valid, err := iter.Valid(); !valid || err != nil {

pkg/backup/compaction_processor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ func compactSpanEntry(
422422
scratch = append(scratch, prefix...)
423423
iter := sstIter.iter
424424
for iter.SeekGE(trimmedStart); ; iter.NextKey() {
425-
if err := pacer.Pace(ctx); err != nil {
425+
if _, err := pacer.Pace(ctx); err != nil {
426426
return err
427427
}
428428
var key storage.MVCCKey

pkg/ccl/changefeedccl/batching_sink.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ func (s *batchingSink) runBatchingWorker(ctx context.Context) {
476476
// TODO(yevgeniy): rework this function: this function should simply
477477
// return an error, and not rely on "handleError".
478478
// It's hard to reason about this functions correctness otherwise.
479-
_ = s.pacer.Pace(ctx)
479+
_, _ = s.pacer.Pace(ctx)
480480

481481
switch r := req.(type) {
482482
case *rowEvent:

pkg/ccl/changefeedccl/event_processing.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ func (c *kvEventToRowConsumer) ConsumeEvent(ctx context.Context, ev kvevent.Even
343343
// Request CPU time to use for event consumption, block if this time is
344344
// unavailable. If there is unused CPU time left from the last call to
345345
// Pace, then use that time instead of blocking.
346-
if err := c.pacer.Pace(ctx); err != nil {
346+
if _, err := c.pacer.Pace(ctx); err != nil {
347347
return err
348348
}
349349

pkg/ccl/schemachangerccl/testdata/decomp/multiregion

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ ElementState:
230230
columnId: 1
231231
computeExpr: null
232232
elementCreationMetadata:
233-
in231OrLater: true
234233
in243OrLater: true
234+
in261OrLater: true
235235
familyId: 0
236236
isVirtual: false
237237
tableId: 110
@@ -259,8 +259,8 @@ ElementState:
259259
columnId: 2
260260
computeExpr: null
261261
elementCreationMetadata:
262-
in231OrLater: true
263262
in243OrLater: true
263+
in261OrLater: true
264264
familyId: 0
265265
isVirtual: false
266266
tableId: 110
@@ -288,8 +288,8 @@ ElementState:
288288
columnId: 4.294967292e+09
289289
computeExpr: null
290290
elementCreationMetadata:
291-
in231OrLater: true
292291
in243OrLater: true
292+
in261OrLater: true
293293
familyId: 0
294294
isVirtual: false
295295
tableId: 110
@@ -317,8 +317,8 @@ ElementState:
317317
columnId: 4.294967293e+09
318318
computeExpr: null
319319
elementCreationMetadata:
320-
in231OrLater: true
321320
in243OrLater: true
321+
in261OrLater: true
322322
familyId: 0
323323
isVirtual: false
324324
tableId: 110
@@ -346,8 +346,8 @@ ElementState:
346346
columnId: 4.294967294e+09
347347
computeExpr: null
348348
elementCreationMetadata:
349-
in231OrLater: true
350349
in243OrLater: true
350+
in261OrLater: true
351351
familyId: 0
352352
isVirtual: false
353353
tableId: 110
@@ -375,8 +375,8 @@ ElementState:
375375
columnId: 4.294967295e+09
376376
computeExpr: null
377377
elementCreationMetadata:
378-
in231OrLater: true
379378
in243OrLater: true
379+
in261OrLater: true
380380
familyId: 0
381381
isVirtual: false
382382
tableId: 110
@@ -624,8 +624,8 @@ ElementState:
624624
columnId: 1
625625
computeExpr: null
626626
elementCreationMetadata:
627-
in231OrLater: true
628627
in243OrLater: true
628+
in261OrLater: true
629629
familyId: 0
630630
isVirtual: false
631631
tableId: 109
@@ -653,8 +653,8 @@ ElementState:
653653
columnId: 2
654654
computeExpr: null
655655
elementCreationMetadata:
656-
in231OrLater: true
657656
in243OrLater: true
657+
in261OrLater: true
658658
familyId: 0
659659
isVirtual: false
660660
tableId: 109
@@ -682,8 +682,8 @@ ElementState:
682682
columnId: 4.294967292e+09
683683
computeExpr: null
684684
elementCreationMetadata:
685-
in231OrLater: true
686685
in243OrLater: true
686+
in261OrLater: true
687687
familyId: 0
688688
isVirtual: false
689689
tableId: 109
@@ -711,8 +711,8 @@ ElementState:
711711
columnId: 4.294967293e+09
712712
computeExpr: null
713713
elementCreationMetadata:
714-
in231OrLater: true
715714
in243OrLater: true
715+
in261OrLater: true
716716
familyId: 0
717717
isVirtual: false
718718
tableId: 109
@@ -740,8 +740,8 @@ ElementState:
740740
columnId: 4.294967294e+09
741741
computeExpr: null
742742
elementCreationMetadata:
743-
in231OrLater: true
744743
in243OrLater: true
744+
in261OrLater: true
745745
familyId: 0
746746
isVirtual: false
747747
tableId: 109
@@ -769,8 +769,8 @@ ElementState:
769769
columnId: 4.294967295e+09
770770
computeExpr: null
771771
elementCreationMetadata:
772-
in231OrLater: true
773772
in243OrLater: true
773+
in261OrLater: true
774774
familyId: 0
775775
isVirtual: false
776776
tableId: 109
@@ -1074,8 +1074,8 @@ ElementState:
10741074
columnId: 3
10751075
computeExpr: null
10761076
elementCreationMetadata:
1077-
in231OrLater: true
10781077
in243OrLater: true
1078+
in261OrLater: true
10791079
familyId: 0
10801080
isVirtual: false
10811081
tableId: 108
@@ -1104,8 +1104,8 @@ ElementState:
11041104
columnId: 1
11051105
computeExpr: null
11061106
elementCreationMetadata:
1107-
in231OrLater: true
11081107
in243OrLater: true
1108+
in261OrLater: true
11091109
familyId: 0
11101110
isVirtual: false
11111111
tableId: 108
@@ -1133,8 +1133,8 @@ ElementState:
11331133
columnId: 2
11341134
computeExpr: null
11351135
elementCreationMetadata:
1136-
in231OrLater: true
11371136
in243OrLater: true
1137+
in261OrLater: true
11381138
familyId: 0
11391139
isVirtual: false
11401140
tableId: 108
@@ -1162,8 +1162,8 @@ ElementState:
11621162
columnId: 4.294967292e+09
11631163
computeExpr: null
11641164
elementCreationMetadata:
1165-
in231OrLater: true
11661165
in243OrLater: true
1166+
in261OrLater: true
11671167
familyId: 0
11681168
isVirtual: false
11691169
tableId: 108
@@ -1191,8 +1191,8 @@ ElementState:
11911191
columnId: 4.294967293e+09
11921192
computeExpr: null
11931193
elementCreationMetadata:
1194-
in231OrLater: true
11951194
in243OrLater: true
1195+
in261OrLater: true
11961196
familyId: 0
11971197
isVirtual: false
11981198
tableId: 108
@@ -1220,8 +1220,8 @@ ElementState:
12201220
columnId: 4.294967294e+09
12211221
computeExpr: null
12221222
elementCreationMetadata:
1223-
in231OrLater: true
12241223
in243OrLater: true
1224+
in261OrLater: true
12251225
familyId: 0
12261226
isVirtual: false
12271227
tableId: 108
@@ -1249,8 +1249,8 @@ ElementState:
12491249
columnId: 4.294967295e+09
12501250
computeExpr: null
12511251
elementCreationMetadata:
1252-
in231OrLater: true
12531252
in243OrLater: true
1253+
in261OrLater: true
12541254
familyId: 0
12551255
isVirtual: false
12561256
tableId: 108

pkg/ccl/schemachangerccl/testdata/decomp/partitioning

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ ElementState:
161161
columnId: 1
162162
computeExpr: null
163163
elementCreationMetadata:
164-
in231OrLater: true
165164
in243OrLater: true
165+
in261OrLater: true
166166
familyId: 0
167167
isVirtual: false
168168
tableId: 104
@@ -190,8 +190,8 @@ ElementState:
190190
columnId: 2
191191
computeExpr: null
192192
elementCreationMetadata:
193-
in231OrLater: true
194193
in243OrLater: true
194+
in261OrLater: true
195195
familyId: 0
196196
isVirtual: false
197197
tableId: 104
@@ -219,8 +219,8 @@ ElementState:
219219
columnId: 3
220220
computeExpr: null
221221
elementCreationMetadata:
222-
in231OrLater: true
223222
in243OrLater: true
223+
in261OrLater: true
224224
familyId: 0
225225
isVirtual: false
226226
tableId: 104
@@ -248,8 +248,8 @@ ElementState:
248248
columnId: 4.294967292e+09
249249
computeExpr: null
250250
elementCreationMetadata:
251-
in231OrLater: true
252251
in243OrLater: true
252+
in261OrLater: true
253253
familyId: 0
254254
isVirtual: false
255255
tableId: 104
@@ -277,8 +277,8 @@ ElementState:
277277
columnId: 4.294967293e+09
278278
computeExpr: null
279279
elementCreationMetadata:
280-
in231OrLater: true
281280
in243OrLater: true
281+
in261OrLater: true
282282
familyId: 0
283283
isVirtual: false
284284
tableId: 104
@@ -306,8 +306,8 @@ ElementState:
306306
columnId: 4.294967294e+09
307307
computeExpr: null
308308
elementCreationMetadata:
309-
in231OrLater: true
310309
in243OrLater: true
310+
in261OrLater: true
311311
familyId: 0
312312
isVirtual: false
313313
tableId: 104
@@ -335,8 +335,8 @@ ElementState:
335335
columnId: 4.294967295e+09
336336
computeExpr: null
337337
elementCreationMetadata:
338-
in231OrLater: true
339338
in243OrLater: true
339+
in261OrLater: true
340340
familyId: 0
341341
isVirtual: false
342342
tableId: 104
@@ -666,8 +666,8 @@ ElementState:
666666
columnId: 1
667667
computeExpr: null
668668
elementCreationMetadata:
669-
in231OrLater: true
670669
in243OrLater: true
670+
in261OrLater: true
671671
familyId: 0
672672
isVirtual: false
673673
tableId: 105
@@ -695,8 +695,8 @@ ElementState:
695695
columnId: 2
696696
computeExpr: null
697697
elementCreationMetadata:
698-
in231OrLater: true
699698
in243OrLater: true
699+
in261OrLater: true
700700
familyId: 0
701701
isVirtual: false
702702
tableId: 105
@@ -724,8 +724,8 @@ ElementState:
724724
columnId: 4.294967292e+09
725725
computeExpr: null
726726
elementCreationMetadata:
727-
in231OrLater: true
728727
in243OrLater: true
728+
in261OrLater: true
729729
familyId: 0
730730
isVirtual: false
731731
tableId: 105
@@ -753,8 +753,8 @@ ElementState:
753753
columnId: 4.294967293e+09
754754
computeExpr: null
755755
elementCreationMetadata:
756-
in231OrLater: true
757756
in243OrLater: true
757+
in261OrLater: true
758758
familyId: 0
759759
isVirtual: false
760760
tableId: 105
@@ -782,8 +782,8 @@ ElementState:
782782
columnId: 4.294967294e+09
783783
computeExpr: null
784784
elementCreationMetadata:
785-
in231OrLater: true
786785
in243OrLater: true
786+
in261OrLater: true
787787
familyId: 0
788788
isVirtual: false
789789
tableId: 105
@@ -811,8 +811,8 @@ ElementState:
811811
columnId: 4.294967295e+09
812812
computeExpr: null
813813
elementCreationMetadata:
814-
in231OrLater: true
815814
in243OrLater: true
815+
in261OrLater: true
816816
familyId: 0
817817
isVirtual: false
818818
tableId: 105

pkg/kv/bulk/sst_batcher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ func (b *SSTBatcher) AddMVCCKeyLDR(ctx context.Context, key storage.MVCCKey, val
444444
// Keys must be added in order.
445445
func (b *SSTBatcher) AddMVCCKey(ctx context.Context, key storage.MVCCKey, value []byte) error {
446446
// Pace based on admission control before adding the key.
447-
if err := b.pacer.Pace(ctx); err != nil {
447+
if _, err := b.pacer.Pace(ctx); err != nil {
448448
return err
449449
}
450450

pkg/kv/kvclient/rangefeed/rangefeed_external_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,11 @@ func TestWithOnDeleteRange(t *testing.T) {
841841
// should be visible, because catchup scans do emit tombstones. The range
842842
// tombstone should be ordered after the initial point, but before the foo
843843
// catchup point, and the previous values should respect the range tombstones.
844+
//
845+
// NB: When RaceEnabled=true, the range key will be emitted multiple
846+
// times, since CatchUpSnapshot.CatchUpScan recreates the iterator at
847+
// every step. These duplications are harmless and are de-duped by
848+
// testEvents when printing.
844849
require.NoError(t, db.Put(ctx, makeKey(srv.Codec(), "covered"), "covered"))
845850
require.NoError(t, db.Put(ctx, makeKey(srv.Codec(), "foo"), "covered"))
846851
require.NoError(t, db.DelRangeUsingTombstone(ctx, makeKey(srv.Codec(), "a"), makeKey(srv.Codec(), "z")))

pkg/kv/kvserver/rangefeed/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ go_library(
4040
"//pkg/storage",
4141
"//pkg/storage/enginepb",
4242
"//pkg/storage/fs",
43+
"//pkg/util",
4344
"//pkg/util/admission",
4445
"//pkg/util/bufalloc",
4546
"//pkg/util/buildutil",

0 commit comments

Comments
 (0)