Skip to content

Commit 0aae430

Browse files
craig[bot]ajstormkev-caomw5h
committed
144594: roachtest: add TPC-C 1000 WH nowait test r=tbg a=ajstorm We currently have a TPC-C nowait test in roachperf, but it's a one warehouse test, which isn't very realistic. This commit adds a more realistic test where we won't be contending on a single warehouse. Epic: none Release note: none 144642: backup: compaction dist sql processor now handles errors correctly r=msbutler a=kev-cao Previously, when one of the processor nodes in the backup compaction dist SQL plan ran into an error, the compaction job would continue on, blissfully unaware of the error. This would result in faulty job successes. This patch fixes the coordinator node so that errors from other nodes is properly handled and surfaced. Epic: None Release note: None 144702: schemachanger: when taking a vector index offline, notify client r=rafiss a=mw5h A previous patch disabled mutations on vector indexes if sql_safe_updates was enabled. This patch send the associated error message as a notice even if sql_safe_updates is disabled, so there are no surprises. Informs: #144443 Release note (sql change): CREATE VECTOR INDEX and ALTER PRIMARY KEY will now send a notice that vector indexes will be offline during the change operation when sql_safe_updates is disabled. Co-authored-by: Adam Storm <[email protected]> Co-authored-by: Kevin Cao <[email protected]> Co-authored-by: Matt White <[email protected]>
4 parents c62e1ba + 6f1f2ba + 3bcdb42 + e6a2064 commit 0aae430

File tree

7 files changed

+59
-22
lines changed

7 files changed

+59
-22
lines changed

pkg/backup/compaction_dist.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func runCompactionPlan(
130130

131131
evalCtxCopy := execCtx.ExtendedEvalContext().Copy()
132132
dsp.Run(ctx, planCtx, nil /* txn */, plan, recv, evalCtxCopy, nil /* finishedSetupFn */)
133-
return nil
133+
return rowResultWriter.Err()
134134
}
135135

136136
// createCompactionPlan creates an un-finalized physical plan that will

pkg/cmd/roachtest/tests/tpcc.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,25 @@ func registerTPCC(r registry.Registry) {
740740
},
741741
})
742742

743+
r.Add(registry.TestSpec{
744+
Name: "tpcc-nowait/w=1000/nodes=5/cpu=16",
745+
Owner: registry.OwnerTestEng,
746+
Benchmark: true,
747+
Cluster: r.MakeClusterSpec(6, spec.CPU(16), spec.WorkloadNode()),
748+
CompatibleClouds: registry.AllExceptAzure,
749+
Suites: registry.Suites(registry.Nightly),
750+
TestSelectionOptOutSuites: registry.Suites(registry.Nightly),
751+
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
752+
runTPCC(ctx, t, t.L(), c, tpccOptions{
753+
Warehouses: 1000,
754+
Duration: 10 * time.Minute,
755+
ExtraRunArgs: "--wait=false --tolerate-errors --workers=200",
756+
SetupType: usingImport,
757+
DisableDefaultScheduledBackup: true,
758+
})
759+
},
760+
})
761+
743762
r.Add(registry.TestSpec{
744763
Name: "tpcc-nowait/nodes=3/w=1",
745764
Owner: registry.OwnerTestEng,

pkg/sql/alter_primary_key.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ func (p *planner) AlterPrimaryKey(
5555
alterPrimaryKeyLocalitySwap *alterPrimaryKeyLocalitySwap,
5656
) error {
5757
// Check if sql_safe_updates is enabled and the table has vector indexes
58-
if p.EvalContext().SessionData().SafeUpdates {
59-
for _, idx := range tableDesc.AllIndexes() {
60-
if idx.GetType() == idxtype.VECTOR {
61-
return pgerror.DangerousStatementf("ALTER PRIMARY KEY on a table with vector indexes will disable writes to the table while the index is being rebuilt")
62-
}
58+
if len(tableDesc.VectorIndexes()) > 0 {
59+
if p.EvalContext().SessionData().SafeUpdates {
60+
return pgerror.DangerousStatementf("ALTER PRIMARY KEY on a table with vector indexes will disable writes to the table while the index is being rebuilt")
61+
} else {
62+
p.BufferClientNotice(ctx, pgnotice.Newf("ALTER PRIMARY KEY on a table with vector indexes will disable writes to the table while the index is being rebuilt"))
6363
}
6464
}
6565

pkg/sql/create_index.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,12 @@ func (p *planner) CreateIndex(ctx context.Context, n *tree.CreateIndex) (planNod
6060
}
6161

6262
// Check if sql_safe_updates is enabled and this is a vector index
63-
if n.Type == idxtype.VECTOR && p.EvalContext().SessionData().SafeUpdates {
64-
return nil, pgerror.DangerousStatementf("CREATE VECTOR INDEX will disable writes to the table while the index is being built")
63+
if n.Type == idxtype.VECTOR {
64+
if p.EvalContext().SessionData().SafeUpdates {
65+
return nil, pgerror.DangerousStatementf("CREATE VECTOR INDEX will disable writes to the table while the index is being built")
66+
} else {
67+
p.BufferClientNotice(ctx, pgnotice.Newf("CREATE VECTOR INDEX will disable writes to the table while the index is being built"))
68+
}
6569
}
6670

6771
_, tableDesc, err := p.ResolveMutableTableDescriptor(

pkg/sql/logictest/testdata/logic_test/vector_index

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ ALTER TABLE simple ALTER PRIMARY KEY USING COLUMNS (b)
2626
statement ok
2727
SET sql_safe_updates = false
2828

29-
statement ok
29+
statement notice CREATE VECTOR INDEX will disable writes to the table while the index is being built
3030
CREATE VECTOR INDEX ON simple (vec1)
3131

32+
statement notice ALTER PRIMARY KEY on a table with vector indexes will disable writes to the table while the index is being rebuilt
33+
ALTER TABLE simple ALTER PRIMARY KEY USING COLUMNS (b)
34+
3235
# Alternate syntax.
33-
statement ok
36+
statement notice CREATE VECTOR INDEX will disable writes to the table while the index is being built
3437
CREATE INDEX ON simple USING cspann (vec1 ASC);
3538

3639
query TT
@@ -40,9 +43,10 @@ simple CREATE TABLE public.simple (
4043
a INT8 NOT NULL,
4144
b INT8 NOT NULL,
4245
vec1 VECTOR(3) NULL,
43-
CONSTRAINT simple_pkey PRIMARY KEY (a ASC),
46+
CONSTRAINT simple_pkey PRIMARY KEY (b ASC),
4447
VECTOR INDEX simple_vec1_idx (vec1),
4548
VECTOR INDEX simple_vec1_idx1 (vec1),
49+
UNIQUE INDEX simple_a_key (a ASC),
4650
VECTOR INDEX simple_vec1_idx2 (vec1),
4751
FAMILY fam_0_a_vec1_b (a, vec1, b)
4852
)
@@ -68,7 +72,7 @@ CREATE TABLE alt_syntax (
6872
FAMILY (a, vec1)
6973
)
7074

71-
statement ok
75+
statement notice CREATE VECTOR INDEX will disable writes to the table while the index is being built
7276
CREATE VECTOR INDEX another_index ON alt_syntax (vec1)
7377

7478
query TT
@@ -403,7 +407,7 @@ INSERT INTO backfill_test VALUES
403407
(2, 'jill', 20, '[4.0, 5.0, 6.0]', '[6.0, 5.0, 4.0]'),
404408
(3, 'ash', 30, '[7.0, 8.0, 9.0]', '[9.0, 8.0, 7.0]');
405409

406-
statement ok
410+
statement notice CREATE VECTOR INDEX will disable writes to the table while the index is being built
407411
CREATE VECTOR INDEX ON backfill_test (enc)
408412

409413
query ITITT
@@ -455,7 +459,7 @@ SELECT * FROM backfill_test@backfill_test_enc_idx ORDER BY enc <-> '[1.0, 2.0, 3
455459
3 ash 30 [7,8,9] [9,8,7]
456460
6 ash 60 [7.5,8,9] [9,8,7.5]
457461

458-
statement ok
462+
statement notice CREATE VECTOR INDEX will disable writes to the table while the index is being built
459463
CREATE VECTOR INDEX ON backfill_test (username, prefix_enc)
460464

461465
query ITITT

pkg/sql/schemachanger/scbuild/internal/scbuildstmt/alter_table_alter_primary_key.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/cockroachdb/cockroach/pkg/sql/paramparse"
2020
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode"
2121
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
22+
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgnotice"
2223
"github.com/cockroachdb/cockroach/pkg/sql/privilege"
2324
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scerrors"
2425
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb"
@@ -60,14 +61,19 @@ func alterPrimaryKey(
6061
b BuildCtx, tn *tree.TableName, tbl *scpb.Table, stmt tree.Statement, t alterPrimaryKeySpec,
6162
) {
6263
// Check if sql_safe_updates is enabled and the table has a vector index
63-
if b.EvalCtx().SessionData().SafeUpdates {
64-
tableElts := b.QueryByID(tbl.TableID).Filter(notFilter(absentTargetFilter))
65-
scpb.ForEachSecondaryIndex(tableElts, func(_ scpb.Status, _ scpb.TargetStatus, idx *scpb.SecondaryIndex) {
66-
if idx.Type == idxtype.VECTOR {
64+
tableElts := b.QueryByID(tbl.TableID).Filter(notFilter(absentTargetFilter))
65+
noticeSent := false
66+
scpb.ForEachSecondaryIndex(tableElts, func(_ scpb.Status, _ scpb.TargetStatus, idx *scpb.SecondaryIndex) {
67+
if idx.Type == idxtype.VECTOR {
68+
if b.EvalCtx().SessionData().SafeUpdates {
6769
panic(pgerror.DangerousStatementf("ALTER PRIMARY KEY on a table with vector indexes will disable writes to the table while the index is being rebuilt"))
70+
} else if !noticeSent {
71+
noticeSender := b.EvalCtx().ClientNoticeSender
72+
noticeSender.BufferClientNotice(b, pgnotice.Newf("ALTER PRIMARY KEY on a table with vector indexes will disable writes to the table while the index is being rebuilt"))
73+
noticeSent = true
6874
}
69-
})
70-
}
75+
}
76+
})
7177

7278
// Panic on certain forbidden `ALTER PRIMARY KEY` cases (e.g. one of
7379
// the new primary key column is a virtual column). See the comments

pkg/sql/schemachanger/scbuild/internal/scbuildstmt/create_index.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ import (
4444
// CreateIndex implements CREATE INDEX.
4545
func CreateIndex(b BuildCtx, n *tree.CreateIndex) {
4646
// Check if sql_safe_updates is enabled and this is a vector index
47-
if n.Type == idxtype.VECTOR && b.EvalCtx().SessionData().SafeUpdates {
48-
panic(pgerror.DangerousStatementf("CREATE VECTOR INDEX will disable writes to the table while the index is being built"))
47+
if n.Type == idxtype.VECTOR {
48+
if b.EvalCtx().SessionData().SafeUpdates {
49+
panic(pgerror.DangerousStatementf("CREATE VECTOR INDEX will disable writes to the table while the index is being built"))
50+
} else {
51+
b.EvalCtx().ClientNoticeSender.BufferClientNotice(b, pgnotice.Newf("CREATE VECTOR INDEX will disable writes to the table while the index is being built"))
52+
}
4953
}
5054

5155
b.IncrementSchemaChangeCreateCounter("index")

0 commit comments

Comments
 (0)