Skip to content

Commit de064de

Browse files
craig[bot]kyle-a-wongannrpomstevendannayuzefovich
committed
142927: builtins,workloadindexrec: Add fingerprint id to workload_index_recs … r=kyle-a-wong a=kyle-a-wong …builtin Adds another column to the workload_index_recs builtin that contains an array of fingerprint ids that the recommended indexes were originally recommended for. Resolves: #141947 Epic: CRDB-42980 Release note (sql change): Changes the return type of the workload_index_recs builtin to be two columns. The first column, "index_rec", remains a string type that contains the index recommndation. The second column, "fingerprint_ids", is new and has the "byte[]" type. 143523: sql: validate undesired zone configs for secondary tenants r=annrpom a=annrpom ### sql: add setting for constraint validation for secondary tenants This patch adds a cluster setting, ``sql.zone_configs.max_replicas_per_region, that helps prevent virtual clusters from setting undesired zone configs. This setting defines the max number of replicas that can be configured for a single region (0 for unlimited). Epic: none Informs: #142856 Release note: None --- ### sql: add setting to validate privs for secondary tenants This patch adds a cluster setting, `sql.zone_configs.default_range_modifiable_by_non_root.enabled`, to help prevent virtual clusters from setting undesired zone configs. This settings determines if non-root users on these clusters should be restricted from modifying the `default` range. Other named ranges are not allowed to be modified as a secondary tenant. Epic: none Fixes: #142856 Release note: None 143578: kvserver: don't generate large writes during lock durability upgrade r=arulajmani a=stevendanna Since this is still a best-effort feature for the time being, we want to protect against writing too many locks during transfer or merge requests. Epic: none Release note: None 143825: roachtest/pg_regress: accept recent diff r=yuzefovich a=yuzefovich **roachtest/pg_regress: adjust runner to remove table IDs** I've seen a particular unimplemented error result in the diffs churn because it includes table IDs which can change between run, for some reason. Let's just remove the table ID from the error. **roachtest/pg_regress: accept recent diff** Fixes: #143940. Release note: None Co-authored-by: Kyle Wong <[email protected]> Co-authored-by: Annie Pompa <[email protected]> Co-authored-by: Steven Danna <[email protected]> Co-authored-by: Yahor Yuzefovich <[email protected]>
5 parents 78e2a2e + 378efc8 + 6b64383 + c5527eb + b70ee72 commit de064de

37 files changed

+1558
-1059
lines changed

docs/generated/sql/functions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,9 +1554,9 @@ the locality flag on node startup. Returns an error if no region is set.</p>
15541554
</span></td><td>Immutable</td></tr>
15551555
<tr><td><a name="unnest"></a><code>unnest(input: anyelement[]) &rarr; anyelement</code></td><td><span class="funcdesc"><p>Returns the input array as a set of rows</p>
15561556
</span></td><td>Immutable</td></tr>
1557-
<tr><td><a name="workload_index_recs"></a><code>workload_index_recs() &rarr; <a href="string.html">string</a></code></td><td><span class="funcdesc"><p>Returns set of index recommendations</p>
1557+
<tr><td><a name="workload_index_recs"></a><code>workload_index_recs() &rarr; tuple{string AS index_rec, bytes[] AS fingerprint_ids}</code></td><td><span class="funcdesc"><p>Returns index recommendations and the fingerprint ids that the indexes will impact</p>
15581558
</span></td><td>Immutable</td></tr>
1559-
<tr><td><a name="workload_index_recs"></a><code>workload_index_recs(timestamptz: <a href="timestamp.html">timestamptz</a>) &rarr; <a href="string.html">string</a></code></td><td><span class="funcdesc"><p>Returns set of index recommendations</p>
1559+
<tr><td><a name="workload_index_recs"></a><code>workload_index_recs(timestamptz: <a href="timestamp.html">timestamptz</a>) &rarr; tuple{string AS index_rec, bytes[] AS fingerprint_ids}</code></td><td><span class="funcdesc"><p>Returns index recommendations and the fingerprint ids that the indexes will impact</p>
15601560
</span></td><td>Immutable</td></tr></tbody>
15611561
</table>
15621562

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# LogicTest: multiregion-9node-3region-3azs-tenant
2+
# tenant-cluster-setting-override-opt: sql.virtual_cluster.feature_access.multiregion.enabled=true
3+
4+
statement ok
5+
CREATE DATABASE db PRIMARY REGION "us-east-1"
6+
7+
statement ok
8+
ALTER DATABASE db ADD REGION "ca-central-1"
9+
10+
statement ok
11+
SET override_multi_region_zone_config = true
12+
13+
statement ok
14+
ALTER DATABASE db CONFIGURE ZONE USING constraints = '{+region=us-east-1: 4}', voter_constraints = '{+region=us-east-1: 3}'
15+
16+
subtest constrained_replicas
17+
18+
user root
19+
20+
statement ok
21+
SET CLUSTER SETTING sql.zone_configs.max_replicas_per_region = 10
22+
23+
user host-cluster-root
24+
25+
# Ensure that the override from the system tenant takes precedence over anything
26+
# set from within the application tenant.
27+
statement ok
28+
ALTER TENANT ALL SET CLUSTER SETTING sql.zone_configs.max_replicas_per_region = 4
29+
30+
user root
31+
32+
# Our setting should not affect non-constraint related zone config updates.
33+
statement ok
34+
ALTER DATABASE db CONFIGURE ZONE USING gc.ttlseconds = 1
35+
36+
statement error pgcode 23514 constraint for "us-east-1" exceeds the configured maximum of 4 replicas
37+
ALTER DATABASE db CONFIGURE ZONE USING constraints = '{+region=us-east-1: 5}'
38+
39+
statement ok
40+
ALTER DATABASE db CONFIGURE ZONE USING constraints = '{+region=us-east-1: 1, +region=ca-central-1: 1}', voter_constraints = '{+region=us-east-1: 3}'
41+
42+
statement error pgcode 23514 voter constraint for "us-east-1" exceeds the configured maximum of 4 replicas
43+
ALTER DATABASE db CONFIGURE ZONE USING voter_constraints = '{+region=us-east-1: 5}'
44+
45+
user host-cluster-root
46+
47+
statement ok
48+
ALTER TENANT ALL SET CLUSTER SETTING sql.zone_configs.max_replicas_per_region = 3
49+
50+
user root
51+
52+
statement ok
53+
ALTER DATABASE db CONFIGURE ZONE USING gc.ttlseconds = 1
54+
55+
statement ok
56+
ALTER DATABASE db CONFIGURE ZONE USING constraints = '{+region=us-east-1: 3, +region=ca-central-1: 1}', voter_constraints = '{+region=us-east-1: 2}'
57+
58+
# Ensure that prohibited constraints don't trigger a validation error.
59+
statement ok
60+
ALTER DATABASE test CONFIGURE ZONE USING num_replicas = 4, constraints = '{-region=us-east-1: 4}'
61+
62+
subtest end
63+
64+
subtest privileged_range
65+
66+
statement ok
67+
ALTER RANGE default CONFIGURE ZONE USING num_replicas = 10
68+
69+
user host-cluster-root
70+
71+
statement ok
72+
ALTER TENANT ALL SET CLUSTER SETTING sql.zone_configs.default_range_modifiable_by_non_root.enabled = false
73+
74+
user root
75+
76+
statement ok
77+
ALTER RANGE default CONFIGURE ZONE USING num_replicas = 10
78+
79+
statement ok
80+
SET ROLE admin
81+
82+
statement error pgcode 42501 only root users are allowed to modify the default range
83+
ALTER RANGE default CONFIGURE ZONE USING num_replicas = 10
84+
85+
subtest end

pkg/ccl/logictestccl/tests/multiregion-9node-3region-3azs-tenant/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ go_test(
99
"//pkg/ccl/logictestccl:testdata", # keep
1010
],
1111
exec_properties = {"test.Pool": "large"},
12-
shard_count = 17,
12+
shard_count = 18,
1313
tags = ["cpu:4"],
1414
deps = [
1515
"//pkg/base",

pkg/ccl/logictestccl/tests/multiregion-9node-3region-3azs-tenant/generated_test.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/cmd/roachtest/testdata/pg_regress/alter_table.diffs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/alter_table.out -
16301630
-ERROR: column "test" is in a primary key
16311631
+ERROR: column "test" is in a primary index
16321632
alter table atacc1 drop constraint "atacc1_pkey";
1633-
+ERROR: relation "atacc1" (1984): unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
1633+
+ERROR: relation "atacc1": unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
16341634
+HINT: You have attempted to use a feature that is not yet implemented.
16351635
+See: https://go.crdb.dev/issue-v/48026/_version_
16361636
alter table atacc1 alter column test drop not null;
@@ -5404,7 +5404,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/alter_table.out -
54045404
DELETE FROM old_system_table WHERE othercol = 'somedata';
54055405
TRUNCATE old_system_table;
54065406
ALTER TABLE old_system_table DROP CONSTRAINT new_system_table_pkey;
5407-
+ERROR: relation "old_system_table" (2082): unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
5407+
+ERROR: relation "old_system_table": unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
54085408
+HINT: You have attempted to use a feature that is not yet implemented.
54095409
+See: https://go.crdb.dev/issue-v/48026/_version_
54105410
ALTER TABLE old_system_table DROP COLUMN othercol;

pkg/cmd/roachtest/testdata/pg_regress/create_view.diffs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/create_view.out -
119119
-ERROR: cannot drop constraint view_base_table_pkey on table view_base_table because other objects depend on it
120120
-DETAIL: view key_dependent_view depends on constraint view_base_table_pkey on table view_base_table
121121
-HINT: Use DROP ... CASCADE to drop the dependent objects too.
122-
+ERROR: relation "view_base_table" (325): unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
122+
+ERROR: relation "view_base_table": unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
123123
+HINT: You have attempted to use a feature that is not yet implemented.
124124
+See: https://go.crdb.dev/issue-v/48026/_version_
125125
CREATE VIEW key_dependent_view_no_cols AS

pkg/cmd/roachtest/testdata/pg_regress/functional_deps.diffs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/functional_deps.o
112112
-ERROR: cannot drop constraint articles_pkey on table articles because other objects depend on it
113113
-DETAIL: view fdv1 depends on constraint articles_pkey on table articles
114114
-HINT: Use DROP ... CASCADE to drop the dependent objects too.
115-
+ERROR: relation "articles" (1613): unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
115+
+ERROR: relation "articles": unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
116116
+HINT: You have attempted to use a feature that is not yet implemented.
117117
+See: https://go.crdb.dev/issue-v/48026/_version_
118118
DROP VIEW fdv1;
@@ -125,14 +125,14 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/functional_deps.o
125125
-ERROR: cannot drop constraint articles_pkey on table articles because other objects depend on it
126126
-DETAIL: view fdv2 depends on constraint articles_pkey on table articles
127127
-HINT: Use DROP ... CASCADE to drop the dependent objects too.
128-
+ERROR: relation "articles" (1613): unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
128+
+ERROR: relation "articles": unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
129129
+HINT: You have attempted to use a feature that is not yet implemented.
130130
+See: https://go.crdb.dev/issue-v/48026/_version_
131131
ALTER TABLE articles_in_category DROP CONSTRAINT articles_in_category_pkey RESTRICT; --fail
132132
-ERROR: cannot drop constraint articles_in_category_pkey on table articles_in_category because other objects depend on it
133133
-DETAIL: view fdv2 depends on constraint articles_in_category_pkey on table articles_in_category
134134
-HINT: Use DROP ... CASCADE to drop the dependent objects too.
135-
+ERROR: relation "articles_in_category" (1614): unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
135+
+ERROR: relation "articles_in_category": unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
136136
+HINT: You have attempted to use a feature that is not yet implemented.
137137
+See: https://go.crdb.dev/issue-v/48026/_version_
138138
DROP VIEW fdv2;
@@ -145,7 +145,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/functional_deps.o
145145
-ERROR: cannot drop constraint articles_pkey on table articles because other objects depend on it
146146
-DETAIL: view fdv3 depends on constraint articles_pkey on table articles
147147
-HINT: Use DROP ... CASCADE to drop the dependent objects too.
148-
+ERROR: relation "articles" (1613): unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
148+
+ERROR: relation "articles": unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
149149
+HINT: You have attempted to use a feature that is not yet implemented.
150150
+See: https://go.crdb.dev/issue-v/48026/_version_
151151
DROP VIEW fdv3;
@@ -155,7 +155,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/functional_deps.o
155155
-ERROR: cannot drop constraint articles_pkey on table articles because other objects depend on it
156156
-DETAIL: view fdv4 depends on constraint articles_pkey on table articles
157157
-HINT: Use DROP ... CASCADE to drop the dependent objects too.
158-
+ERROR: relation "articles" (1613): unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
158+
+ERROR: relation "articles": unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
159159
+HINT: You have attempted to use a feature that is not yet implemented.
160160
+See: https://go.crdb.dev/issue-v/48026/_version_
161161
DROP VIEW fdv4;
@@ -165,7 +165,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/functional_deps.o
165165
(0 rows)
166166

167167
ALTER TABLE articles DROP CONSTRAINT articles_pkey RESTRICT;
168-
+ERROR: relation "articles" (1613): unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
168+
+ERROR: relation "articles": unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
169169
+HINT: You have attempted to use a feature that is not yet implemented.
170170
+See: https://go.crdb.dev/issue-v/48026/_version_
171171
EXECUTE foo; -- fail

0 commit comments

Comments
 (0)