Skip to content

Commit d591c19

Browse files
craig[bot]mgartnerxinhaoztbg
committed
149486: opt: enable optimizer_prefer_bounded_cardinality by default r=mgartner a=mgartner Fixes #64570 Release note (sql change): The session setting `optimizer_prefer_bounded_cardinality` is now enabled by default. 149498: go.mod, storage: bump pebble + enable multilevel compactions by default with a cluster setting r=xinhaoz a=xinhaoz ### 1: go.mod: bump Pebble to 20e2cbcd70de Changes: * [`20e2cbcd`](cockroachdb/pebble@20e2cbcd) db: support overriding value separation minimum-size by key span * [`50d7fd77`](cockroachdb/pebble@50d7fd77) pebble: add additional constraints to running multiLevel compactions * [`f810bcdf`](cockroachdb/pebble@f810bcdf) pebble: make MultiLevelCompactionHeuristic a function option Release note: none. Epic: none. ### 2: storage: enable multilevel compactions by default with a cluster setting Reenable multilevel compactions, with more constraints. ML compactions will run according to a write amp heuristic, along with the following rules: - At most 1 ML compaction is running at any time. - The db must have >= 2 maximum compaction slots. Closes: cockroachdb/pebble#4139 149659: asim: some more improvements r=tbg a=tbg - **state: add TestReplicaPlacement** - **state: rename ParseStoreWeights -> ParseReplicaPlacement** - **state: improve ReplicaPlacement parsing and stringer** - **testdata: rm example_replica_placement** Epic: CRDB-25222 Release note: none Co-authored-by: Marcus Gartner <[email protected]> Co-authored-by: Xin Hao Zhang <[email protected]> Co-authored-by: Tobias Grieger <[email protected]>
4 parents 880272d + 2019a42 + e8d6f70 + e489320 commit d591c19

Some content is hidden

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

67 files changed

+2712
-351
lines changed

DEPS.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,10 +1835,10 @@ def go_deps():
18351835
patches = [
18361836
"@com_github_cockroachdb_cockroach//build/patches:com_github_cockroachdb_pebble.patch",
18371837
],
1838-
sha256 = "877549371ab3baba36d81ba2e10be21179453709b8f3f105e21017f3f0f561b4",
1839-
strip_prefix = "github.com/cockroachdb/[email protected]20250701175647-a2947b4a9383",
1838+
sha256 = "23d6f7ca193051e5ba0317a0d6346f0e26ceb4965060fbc5b8cc6e16b7fda849",
1839+
strip_prefix = "github.com/cockroachdb/[email protected]20250703175825-20e2cbcd70de",
18401840
urls = [
1841-
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/pebble/com_github_cockroachdb_pebble-v0.0.0-20250701175647-a2947b4a9383.zip",
1841+
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/pebble/com_github_cockroachdb_pebble-v0.0.0-20250703175825-20e2cbcd70de.zip",
18421842
],
18431843
)
18441844
go_repository(

build/bazelutil/distdir_files.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ DISTDIR_FILES = {
357357
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/gostdlib/com_github_cockroachdb_gostdlib-v1.19.0.zip": "c4d516bcfe8c07b6fc09b8a9a07a95065b36c2855627cb3514e40c98f872b69e",
358358
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/logtags/com_github_cockroachdb_logtags-v0.0.0-20241215232642-bb51bb14a506.zip": "920068af09e3846d9ebb4e4a7787ff1dd10f3989c5f940ad861b0f6a9f824f6e",
359359
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/metamorphic/com_github_cockroachdb_metamorphic-v0.0.0-20231108215700-4ba948b56895.zip": "28c8cf42192951b69378cf537be5a9a43f2aeb35542908cc4fe5f689505853ea",
360-
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/pebble/com_github_cockroachdb_pebble-v0.0.0-20250701175647-a2947b4a9383.zip": "877549371ab3baba36d81ba2e10be21179453709b8f3f105e21017f3f0f561b4",
360+
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/pebble/com_github_cockroachdb_pebble-v0.0.0-20250703175825-20e2cbcd70de.zip": "23d6f7ca193051e5ba0317a0d6346f0e26ceb4965060fbc5b8cc6e16b7fda849",
361361
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/redact/com_github_cockroachdb_redact-v1.1.6.zip": "018eccb5fb9ca52d43ec9eaf213539d01c1f2b94e0e822406ebfb2e9321ef6cf",
362362
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/returncheck/com_github_cockroachdb_returncheck-v0.0.0-20200612231554-92cdbca611dd.zip": "ce92ba4352deec995b1f2eecf16eba7f5d51f5aa245a1c362dfe24c83d31f82b",
363363
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/stress/com_github_cockroachdb_stress-v0.0.0-20220803192808-1806698b1b7b.zip": "3fda531795c600daf25532a4f98be2a1335cd1e5e182c72789bca79f5f69fcc1",

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ require (
139139
github.com/cockroachdb/go-test-teamcity v0.0.0-20191211140407-cff980ad0a55
140140
github.com/cockroachdb/gostdlib v1.19.0
141141
github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506
142-
github.com/cockroachdb/pebble v0.0.0-20250701175647-a2947b4a9383
142+
github.com/cockroachdb/pebble v0.0.0-20250703175825-20e2cbcd70de
143143
github.com/cockroachdb/redact v1.1.6
144144
github.com/cockroachdb/returncheck v0.0.0-20200612231554-92cdbca611dd
145145
github.com/cockroachdb/stress v0.0.0-20220803192808-1806698b1b7b

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,8 @@ github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506 h1:ASDL+UJcILM
580580
github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506/go.mod h1:Mw7HqKr2kdtu6aYGn3tPmAftiP3QPX63LdK/zcariIo=
581581
github.com/cockroachdb/metamorphic v0.0.0-20231108215700-4ba948b56895 h1:XANOgPYtvELQ/h4IrmPAohXqe2pWA8Bwhejr3VQoZsA=
582582
github.com/cockroachdb/metamorphic v0.0.0-20231108215700-4ba948b56895/go.mod h1:aPd7gM9ov9M8v32Yy5NJrDyOcD8z642dqs+F0CeNXfA=
583-
github.com/cockroachdb/pebble v0.0.0-20250701175647-a2947b4a9383 h1:vaCj5U8yIg9ZFnuKBgFM5qvQIPNlA/IVmrKO7tYq6a8=
584-
github.com/cockroachdb/pebble v0.0.0-20250701175647-a2947b4a9383/go.mod h1:LLa+I2vZrOsrsy4QcuZ6wSXBNQll7erNg3GCr8NpE90=
583+
github.com/cockroachdb/pebble v0.0.0-20250703175825-20e2cbcd70de h1:PXtuqYSHdl6XuV+OueyfHwxgGJHVASj0wU4NfqYksmw=
584+
github.com/cockroachdb/pebble v0.0.0-20250703175825-20e2cbcd70de/go.mod h1:LLa+I2vZrOsrsy4QcuZ6wSXBNQll7erNg3GCr8NpE90=
585585
github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
586586
github.com/cockroachdb/redact v1.1.6 h1:zXJBwDZ84xJNlHl1rMyCojqyIxv+7YUpQiJLQ7n4314=
587587
github.com/cockroachdb/redact v1.1.6/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=

pkg/ccl/logictestccl/testdata/logic_test/explain_redact

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ scan q
296296
├── constraint: /1: ‹×›
297297
├── stats: [rows=333.333, distinct(1)=333.333, null(1)=0]
298298
├── cost: 378.02
299+
├── cost-flags: unbounded-cardinality
299300
├── key: (1)
300301
├── fd: (1)-->(2)
301302
├── distribution: test
@@ -309,6 +310,7 @@ scan q
309310
├── constraint: /1: ‹×›
310311
├── stats: [rows=333.333, distinct(1)=333.333, null(1)=0]
311312
├── cost: 378.02
313+
├── cost-flags: unbounded-cardinality
312314
├── key: (1)
313315
├── fd: (1)-->(2)
314316
├── distribution: test

pkg/ccl/logictestccl/testdata/logic_test/multi_region_remote_access_error

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ SELECT * FROM (SELECT 1, 'Hello, Dude!') vtab(account_id, message)
395395

396396
# A scalar subquery with no home region should fail.
397397
retry
398-
statement error pq: Query has no home region\. Try adding a filter on rbr\.crdb_region and/or on key column \(rbr\.account_id\)\. For more information, see https://www.cockroachlabs.com/docs/stable/cost-based-optimizer.html#control-whether-queries-are-limited-to-a-single-region
398+
statement error pq: Query has no home region. Try adding a LIMIT clause. For more information, see https://www.cockroachlabs.com/docs/stable/cost-based-optimizer.html#control-whether-queries-are-limited-to-a-single-region
399399
SELECT * FROM (SELECT (SELECT max(account_id) FROM messages_rbr rbr), 'Hello, Dude!') vtab(account_id, message)
400400
INNER LOOKUP JOIN messages_rbt rbt on vtab.account_id = rbt.account_id
401401

@@ -416,7 +416,7 @@ CREATE OR REPLACE FUNCTION rbr() RETURNS INT AS 'SELECT max(account_id) FROM mes
416416

417417
# A UDF with no home region should fail.
418418
retry
419-
statement error pq: Query has no home region\. Try adding a filter on messages_rbr\.crdb_region and/or on key column \(multi_region_test_db\.public\.messages_rbr\.account_id\)\. For more information, see https://www.cockroachlabs.com/docs/stable/cost-based-optimizer.html#control-whether-queries-are-limited-to-a-single-region
419+
statement error pq: Query has no home region. Try adding a LIMIT clause. For more information, see https://www.cockroachlabs.com/docs/stable/cost-based-optimizer.html#control-whether-queries-are-limited-to-a-single-region
420420
SELECT rbr()
421421

422422
# An EXISTS subquery with no home region should fail.
@@ -440,22 +440,22 @@ SELECT * FROM messages_rbr rbr, LATERAL
440440

441441
# An array scalar expression with no home region should fail.
442442
retry
443-
statement error pq: Query has no home region\. Try adding a filter on messages_rbr\.crdb_region and/or on key column \(multi_region_test_db\.public\.messages_rbr\.account_id\)\. For more information, see https://www.cockroachlabs.com/docs/stable/cost-based-optimizer.html#control-whether-queries-are-limited-to-a-single-region
443+
statement error pq: Query has no home region. Try adding a LIMIT clause. For more information, see https://www.cockroachlabs.com/docs/stable/cost-based-optimizer.html#control-whether-queries-are-limited-to-a-single-region
444444
SELECT ARRAY[rbr(),rbr()]
445445

446446
# An ALL subquery with no home region should fail.
447447
retry
448-
statement error pq: Query has no home region\. Try adding a filter on messages_rbr\.crdb_region and/or on key column \(messages_rbr\.account_id\)\. For more information, see https://www.cockroachlabs.com/docs/stable/cost-based-optimizer.html#control-whether-queries-are-limited-to-a-single-region
448+
statement error pq: Query has no home region. Try adding a LIMIT clause. For more information, see https://www.cockroachlabs.com/docs/stable/cost-based-optimizer.html#control-whether-queries-are-limited-to-a-single-region
449449
SELECT 1 WHERE 1 > ALL (SELECT max(account_id) FROM messages_rbr)
450450

451451
# An ANY subquery with no home region should fail.
452452
retry
453-
statement error pq: Query has no home region\. Try adding a filter on messages_rbr\.crdb_region and/or on key column \(messages_rbr\.account_id\)\. For more information, see https://www.cockroachlabs.com/docs/stable/cost-based-optimizer.html#control-whether-queries-are-limited-to-a-single-region
453+
statement error pq: Query has no home region. Try adding a LIMIT clause. For more information, see https://www.cockroachlabs.com/docs/stable/cost-based-optimizer.html#control-whether-queries-are-limited-to-a-single-region
454454
SELECT 1 WHERE 1 > ANY (SELECT max(account_id) FROM messages_rbr)
455455

456456
# A SOME subquery with no home region should fail.
457457
retry
458-
statement error pq: Query has no home region\. Try adding a filter on messages_rbr\.crdb_region and/or on key column \(messages_rbr\.account_id\)\. For more information, see https://www.cockroachlabs.com/docs/stable/cost-based-optimizer.html#control-whether-queries-are-limited-to-a-single-region
458+
statement error pq: Query has no home region. Try adding a LIMIT clause. For more information, see https://www.cockroachlabs.com/docs/stable/cost-based-optimizer.html#control-whether-queries-are-limited-to-a-single-region
459459
SELECT 1 WHERE 1 > ANY (SELECT max(account_id) FROM messages_rbr)
460460

461461
### Regression tests for issue #89875
@@ -1073,6 +1073,7 @@ project
10731073
├── immutable
10741074
├── stats: [rows=1]
10751075
├── cost: 4309.15778
1076+
├── cost-flags: unbounded-cardinality
10761077
├── key: ()
10771078
├── fd: ()-->(9)
10781079
├── distribution: ap-southeast-2
@@ -1083,6 +1084,7 @@ project
10831084
├── immutable
10841085
├── stats: [rows=1]
10851086
├── cost: 4309.13778
1087+
├── cost-flags: unbounded-cardinality
10861088
├── key: ()
10871089
├── fd: ()-->(3,9,11,13)
10881090
├── distribution: ap-southeast-2
@@ -1093,6 +1095,7 @@ project
10931095
│ ├── immutable
10941096
│ ├── stats: [rows=3333.33]
10951097
│ ├── cost: 4309.11778
1098+
│ ├── cost-flags: unbounded-cardinality
10961099
│ ├── fd: ()-->(13), (9)-->(11)
10971100
│ ├── limit hint: 1.00
10981101
│ ├── distribution: ap-southeast-2
@@ -1106,19 +1109,22 @@ project
11061109
│ │ │ └── t1.j:24 @> t2.j:3
11071110
│ │ ├── stats: [rows=3333.33, distinct(21)=1, null(21)=0, distinct(22)=964.524, null(22)=0, distinct(26)=1, null(26)=0]
11081111
│ │ ├── cost: 3837.19889
1112+
│ │ ├── cost-flags: unbounded-cardinality
11091113
│ │ ├── fd: ()-->(26)
11101114
│ │ ├── limit hint: 100.00
11111115
│ │ ├── distribution: ap-southeast-2
11121116
│ │ ├── project
11131117
│ │ │ ├── columns: "inverted_join_const_col_@13":21 t2.j:3
11141118
│ │ │ ├── stats: [rows=1000, distinct(21)=1, null(21)=0]
11151119
│ │ │ ├── cost: 1136.62333
1120+
│ │ │ ├── cost-flags: unbounded-cardinality
11161121
│ │ │ ├── fd: ()-->(21)
11171122
│ │ │ ├── distribution: ap-southeast-2
11181123
│ │ │ ├── scan json_arr2_rbt [as=t2]
11191124
│ │ │ │ ├── columns: t2.j:3
11201125
│ │ │ │ ├── stats: [rows=1000]
11211126
│ │ │ │ ├── cost: 1116.60333
1127+
│ │ │ │ ├── cost-flags: unbounded-cardinality
11221128
│ │ │ │ ├── distribution: ap-southeast-2
11231129
│ │ │ │ ├── prune: (3)
11241130
│ │ │ │ └── unfiltered-cols: (1-8)

pkg/ccl/logictestccl/testdata/logic_test/regional_by_row_query_behavior

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3654,6 +3654,7 @@ project
36543654
├── immutable
36553655
├── stats: [rows=0.366667]
36563656
├── cost: 45.3262257
3657+
├── cost-flags: unbounded-cardinality
36573658
├── fd: ()-->(2,5,21,24), (3)==(22), (22)==(3), (5)==(24), (24)==(5), (4)==(23), (23)==(4), (2)==(21), (21)==(2)
36583659
├── distribution: ap-southeast-2
36593660
├── prune: (2-5,12,21-24)
@@ -3663,6 +3664,7 @@ project
36633664
├── immutable
36643665
├── stats: [rows=0.366667, distinct(13)=0.366667, null(13)=0, distinct(14)=0.366667, null(14)=0, distinct(15)=0.366667, null(15)=0, distinct(20)=0.366667, null(20)=0, distinct(24)=0.366667, null(24)=0, distinct(25)=0.366667, null(25)=0]
36653666
├── cost: 45.302559
3667+
├── cost-flags: unbounded-cardinality
36663668
├── fd: ()-->(2,5,6,14,15,21,24,25), (1)-->(3,4), (20)-->(22,23), (1)==(13,20), (13)==(1,20), (20)==(1,13), (5)==(14,24), (14)==(5,24), (24)==(5,14), (6)==(15,25), (15)==(6,25), (25)==(6,15), (2)==(21), (21)==(2), (3)==(22), (22)==(3), (4)==(23), (23)==(4)
36673669
├── distribution: ap-southeast-2
36683670
├── lookup table distribution: ap-southeast-2,ca-central-1,us-east-1
@@ -3673,6 +3675,7 @@ project
36733675
│ ├── immutable
36743676
│ ├── stats: [rows=0.134444, distinct(1)=0.134444, null(1)=0, distinct(2)=0.134444, null(2)=0, distinct(3)=0.134444, null(3)=0, distinct(4)=0.134444, null(4)=0, distinct(5)=0.134444, null(5)=0, distinct(6)=0.134444, null(6)=0, distinct(20)=0.134444, null(20)=0, distinct(21)=0.134444, null(21)=0, distinct(22)=0.134444, null(22)=0, distinct(23)=0.134444, null(23)=0, distinct(24)=0.134444, null(24)=0, distinct(25)=0.134444, null(25)=0]
36753677
│ ├── cost: 34.9459129
3678+
│ ├── cost-flags: unbounded-cardinality
36763679
│ ├── key: (20)
36773680
│ ├── fd: ()-->(2,5,6,21,24,25), (1)-->(3,4), (20)-->(22,23), (1)==(20), (20)==(1), (2)==(21), (21)==(2), (3)==(22), (22)==(3), (4)==(23), (23)==(4), (5)==(24), (24)==(5), (6)==(25), (25)==(6)
36783681
│ ├── distribution: ap-southeast-2
@@ -3685,6 +3688,7 @@ project
36853688
│ │ ├── immutable
36863689
│ │ ├── stats: [rows=0.00366667, distinct(1)=0.00366667, null(1)=0, distinct(2)=0.00366667, null(2)=0, distinct(5)=0.00366667, null(5)=0, distinct(6)=0.00366667, null(6)=0, distinct(20)=0.00366667, null(20)=0, distinct(21)=0.00366667, null(21)=0, distinct(24)=0.00366667, null(24)=0, distinct(25)=0.00366667, null(25)=0, distinct(21,24,25)=0.00366667, null(21,24,25)=0]
36873690
│ │ ├── cost: 34.8283629
3691+
│ │ ├── cost-flags: unbounded-cardinality
36883692
│ │ ├── key: (20)
36893693
│ │ ├── fd: ()-->(2,5,6,21,24,25), (1)-->(3,4), (6)==(25), (25)==(6), (2)==(21), (21)==(2), (5)==(24), (24)==(5), (1)==(20), (20)==(1)
36903694
│ │ ├── distribution: ap-southeast-2
@@ -3697,6 +3701,7 @@ project
36973701
│ │ │ │ histogram(6)= 0 0.36667
36983702
│ │ │ │ <--- 'ap-southeast-2'
36993703
│ │ │ ├── cost: 33.2056672
3704+
│ │ │ ├── cost-flags: unbounded-cardinality
37003705
│ │ │ ├── key: (1)
37013706
│ │ │ ├── fd: ()-->(2,5,6), (1)-->(3,4)
37023707
│ │ │ ├── distribution: ap-southeast-2
@@ -3709,6 +3714,7 @@ project
37093714
│ │ │ │ histogram(6)= 0 0.36667
37103715
│ │ │ │ <--- 'ap-southeast-2'
37113716
│ │ │ ├── cost: 25.430667
3717+
│ │ │ ├── cost-flags: unbounded-cardinality
37123718
│ │ │ ├── key: (1)
37133719
│ │ │ ├── fd: ()-->(2,5,6)
37143720
│ │ │ ├── distribution: ap-southeast-2

pkg/kv/kvserver/asim/state/BUILD.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ go_test(
5555
"change_test.go",
5656
"config_loader_test.go",
5757
"liveness_test.go",
58+
"parser_replica_placement_test.go",
5859
"split_decider_test.go",
5960
"state_test.go",
6061
],
62+
data = glob(["testdata/**"]),
6163
embed = [":state"],
6264
deps = [
6365
"//pkg/kv/kvpb",
@@ -66,7 +68,9 @@ go_test(
6668
"//pkg/kv/kvserver/liveness/livenesspb",
6769
"//pkg/kv/kvserver/load",
6870
"//pkg/roachpb",
71+
"//pkg/testutils/datapathutils",
6972
"//pkg/util/hlc",
73+
"@com_github_cockroachdb_datadriven//:datadriven",
7074
"@com_github_stretchr_testify//require",
7175
],
7276
)

0 commit comments

Comments
 (0)