@@ -519,16 +519,8 @@ func TestLogicalStreamIngestionAdvancePTS(t *testing.T) {
519
519
defer log .Scope (t ).Close (t )
520
520
521
521
ctx := context .Background ()
522
- clusterArgs := base.TestClusterArgs {
523
- ServerArgs : base.TestServerArgs {
524
- DefaultTestTenant : base .TestControlsTenantsExplicitly ,
525
- Knobs : base.TestingKnobs {
526
- JobsTestingKnobs : jobs .NewTestingKnobsWithShortIntervals (),
527
- },
528
- },
529
- }
530
522
531
- server , s , dbA , dbB := setupLogicalTestServer (t , ctx , clusterArgs , 1 )
523
+ server , s , dbA , dbB := setupLogicalTestServer (t , ctx , testClusterBaseClusterArgs , 1 )
532
524
defer server .Stopper ().Stop (ctx )
533
525
534
526
dbA .Exec (t , "INSERT INTO tab VALUES (1, 'hello')" )
@@ -779,16 +771,8 @@ func TestFilterRangefeedInReplicationStream(t *testing.T) {
779
771
skip .UnderRace (t , "multi cluster/node config exhausts hardware" )
780
772
781
773
ctx := context .Background ()
782
- clusterArgs := base.TestClusterArgs {
783
- ServerArgs : base.TestServerArgs {
784
- DefaultTestTenant : base .TestControlsTenantsExplicitly ,
785
- Knobs : base.TestingKnobs {
786
- JobsTestingKnobs : jobs .NewTestingKnobsWithShortIntervals (),
787
- },
788
- },
789
- }
790
774
791
- server , s , dbs , _ := setupServerWithNumDBs (t , ctx , clusterArgs , 1 , 3 )
775
+ server , s , dbs , _ := setupServerWithNumDBs (t , ctx , testClusterBaseClusterArgs , 1 , 3 )
792
776
defer server .Stopper ().Stop (ctx )
793
777
794
778
dbA , dbB , dbC := dbs [0 ], dbs [1 ], dbs [2 ]
@@ -1154,18 +1138,9 @@ func TestLogicalJobResiliency(t *testing.T) {
1154
1138
1155
1139
skip .WithIssue (t , 131184 )
1156
1140
1157
- clusterArgs := base.TestClusterArgs {
1158
- ServerArgs : base.TestServerArgs {
1159
- DefaultTestTenant : base .TestControlsTenantsExplicitly ,
1160
- Knobs : base.TestingKnobs {
1161
- JobsTestingKnobs : jobs .NewTestingKnobsWithShortIntervals (),
1162
- },
1163
- },
1164
- }
1165
-
1166
1141
ctx := context .Background ()
1167
1142
1168
- server , s , dbA , dbB := setupLogicalTestServer (t , ctx , clusterArgs , 3 )
1143
+ server , s , dbA , dbB := setupLogicalTestServer (t , ctx , testClusterBaseClusterArgs , 3 )
1169
1144
defer server .Stopper ().Stop (ctx )
1170
1145
1171
1146
dbBURL := replicationtestutils .GetExternalConnectionURI (t , s , s , serverutils .DBName ("b" ))
@@ -1252,17 +1227,7 @@ func TestMultipleSourcesIntoSingleDest(t *testing.T) {
1252
1227
1253
1228
ctx := context .Background ()
1254
1229
1255
- clusterArgs := base.TestClusterArgs {
1256
- ServerArgs : base.TestServerArgs {
1257
- DefaultTestTenant : base .TestControlsTenantsExplicitly ,
1258
- Knobs : base.TestingKnobs {
1259
- JobsTestingKnobs : jobs .NewTestingKnobsWithShortIntervals (),
1260
- DistSQL : & execinfra.TestingKnobs {},
1261
- },
1262
- },
1263
- }
1264
-
1265
- server , s , runners , dbNames := setupServerWithNumDBs (t , ctx , clusterArgs , 1 , 3 )
1230
+ server , s , runners , dbNames := setupServerWithNumDBs (t , ctx , testClusterBaseClusterArgs , 1 , 3 )
1266
1231
defer server .Stopper ().Stop (ctx )
1267
1232
1268
1233
PGURLs := GetPGURLs (t , s , dbNames )
@@ -1315,15 +1280,6 @@ func TestThreeWayReplication(t *testing.T) {
1315
1280
1316
1281
ctx := context .Background ()
1317
1282
1318
- clusterArgs := base.TestClusterArgs {
1319
- ServerArgs : base.TestServerArgs {
1320
- DefaultTestTenant : base .TestControlsTenantsExplicitly ,
1321
- Knobs : base.TestingKnobs {
1322
- JobsTestingKnobs : jobs .NewTestingKnobsWithShortIntervals (),
1323
- },
1324
- },
1325
- }
1326
-
1327
1283
verifyExpectedRowAllServers := func (
1328
1284
t * testing.T , runners []* sqlutils.SQLRunner , expectedRows [][]string , dbNames []string ,
1329
1285
) {
@@ -1349,7 +1305,7 @@ func TestThreeWayReplication(t *testing.T) {
1349
1305
}
1350
1306
1351
1307
numDBs := 3
1352
- server , s , runners , dbNames := setupServerWithNumDBs (t , ctx , clusterArgs , 1 , numDBs )
1308
+ server , s , runners , dbNames := setupServerWithNumDBs (t , ctx , testClusterBaseClusterArgs , 1 , numDBs )
1353
1309
defer server .Stopper ().Stop (ctx )
1354
1310
1355
1311
PGURLs := GetPGURLs (t , s , dbNames )
@@ -1415,17 +1371,8 @@ func TestTombstoneUpdate(t *testing.T) {
1415
1371
1416
1372
ctx := context .Background ()
1417
1373
1418
- clusterArgs := base.TestClusterArgs {
1419
- ServerArgs : base.TestServerArgs {
1420
- DefaultTestTenant : base .TestControlsTenantsExplicitly ,
1421
- Knobs : base.TestingKnobs {
1422
- JobsTestingKnobs : jobs .NewTestingKnobsWithShortIntervals (),
1423
- },
1424
- },
1425
- }
1426
-
1427
1374
numDBs := 3
1428
- server , s , runners , dbNames := setupServerWithNumDBs (t , ctx , clusterArgs , 1 , numDBs )
1375
+ server , s , runners , dbNames := setupServerWithNumDBs (t , ctx , testClusterBaseClusterArgs , 1 , numDBs )
1429
1376
defer server .Stopper ().Stop (ctx )
1430
1377
PGURLs := GetPGURLs (t , s , dbNames )
1431
1378
@@ -1477,16 +1424,7 @@ func TestForeignKeyConstraints(t *testing.T) {
1477
1424
1478
1425
ctx := context .Background ()
1479
1426
1480
- clusterArgs := base.TestClusterArgs {
1481
- ServerArgs : base.TestServerArgs {
1482
- DefaultTestTenant : base .TestControlsTenantsExplicitly ,
1483
- Knobs : base.TestingKnobs {
1484
- JobsTestingKnobs : jobs .NewTestingKnobsWithShortIntervals (),
1485
- },
1486
- },
1487
- }
1488
-
1489
- server , s , dbA , _ := setupLogicalTestServer (t , ctx , clusterArgs , 1 )
1427
+ server , s , dbA , _ := setupLogicalTestServer (t , ctx , testClusterBaseClusterArgs , 1 )
1490
1428
defer server .Stopper ().Stop (ctx )
1491
1429
1492
1430
dbBURL := replicationtestutils .GetExternalConnectionURI (t , s , s , serverutils .DBName ("b" ))
@@ -1782,14 +1720,7 @@ func TestLogicalStreamIngestionJobWithFallbackUDF(t *testing.T) {
1782
1720
skip .WithIssue (t , 129569 , "flakey test" )
1783
1721
1784
1722
ctx := context .Background ()
1785
- server , s , dbA , dbB := setupLogicalTestServer (t , ctx , base.TestClusterArgs {
1786
- ServerArgs : base.TestServerArgs {
1787
- DefaultTestTenant : base .TestControlsTenantsExplicitly ,
1788
- Knobs : base.TestingKnobs {
1789
- JobsTestingKnobs : jobs .NewTestingKnobsWithShortIntervals (),
1790
- },
1791
- },
1792
- }, 1 )
1723
+ server , s , dbA , dbB := setupLogicalTestServer (t , ctx , testClusterBaseClusterArgs , 1 )
1793
1724
defer server .Stopper ().Stop (ctx )
1794
1725
1795
1726
lwwFunc := `CREATE OR REPLACE FUNCTION repl_apply(action STRING, proposed tab, existing tab, prev tab, existing_mvcc_timestamp DECIMAL, existing_origin_timestamp DECIMAL, proposed_mvcc_timestamp DECIMAL)
@@ -2072,17 +2003,9 @@ func TestUserPrivileges(t *testing.T) {
2072
2003
defer log .Scope (t ).Close (t )
2073
2004
2074
2005
ctx := context .Background ()
2075
- clusterArgs := base.TestClusterArgs {
2076
- ServerArgs : base.TestServerArgs {
2077
- DefaultTestTenant : base .TestControlsTenantsExplicitly ,
2078
- Knobs : base.TestingKnobs {
2079
- JobsTestingKnobs : jobs .NewTestingKnobsWithShortIntervals (),
2080
- },
2081
- },
2082
- }
2083
2006
rng , _ := randutil .NewPseudoRand ()
2084
2007
2085
- server , s , dbA , dbB := setupLogicalTestServer (t , ctx , clusterArgs , 1 )
2008
+ server , s , dbA , dbB := setupLogicalTestServer (t , ctx , testClusterBaseClusterArgs , 1 )
2086
2009
defer server .Stopper ().Stop (ctx )
2087
2010
2088
2011
dbBURL := replicationtestutils .GetExternalConnectionURI (t , s , s , serverutils .DBName ("b" ))
@@ -2224,16 +2147,8 @@ func TestLogicalReplicationSchemaChanges(t *testing.T) {
2224
2147
defer log .Scope (t ).Close (t )
2225
2148
2226
2149
ctx := context .Background ()
2227
- clusterArgs := base.TestClusterArgs {
2228
- ServerArgs : base.TestServerArgs {
2229
- DefaultTestTenant : base .TestControlsTenantsExplicitly ,
2230
- Knobs : base.TestingKnobs {
2231
- JobsTestingKnobs : jobs .NewTestingKnobsWithShortIntervals (),
2232
- },
2233
- },
2234
- }
2235
2150
2236
- server , s , dbA , dbB := setupLogicalTestServer (t , ctx , clusterArgs , 1 )
2151
+ server , s , dbA , dbB := setupLogicalTestServer (t , ctx , testClusterBaseClusterArgs , 1 )
2237
2152
defer server .Stopper ().Stop (ctx )
2238
2153
2239
2154
// Add some stuff to tables in prep for schema change testing.
@@ -2312,16 +2227,8 @@ func TestUserDefinedTypes(t *testing.T) {
2312
2227
skip .UnderDuress (t , "this needs to be multi-node but that tends to be too slow for duressed builds" )
2313
2228
2314
2229
ctx := context .Background ()
2315
- clusterArgs := base.TestClusterArgs {
2316
- ServerArgs : base.TestServerArgs {
2317
- DefaultTestTenant : base .TestControlsTenantsExplicitly ,
2318
- Knobs : base.TestingKnobs {
2319
- JobsTestingKnobs : jobs .NewTestingKnobsWithShortIntervals (),
2320
- },
2321
- },
2322
- }
2323
2230
2324
- server , s , dbA , dbB := setupLogicalTestServer (t , ctx , clusterArgs , 3 )
2231
+ server , s , dbA , dbB := setupLogicalTestServer (t , ctx , testClusterBaseClusterArgs , 3 )
2325
2232
defer server .Stopper ().Stop (ctx )
2326
2233
2327
2234
dbBURL := replicationtestutils .GetExternalConnectionURI (t , s , s , serverutils .DBName ("b" ))
@@ -2484,6 +2391,40 @@ func TestMismatchColIDs(t *testing.T) {
2484
2391
jobutils .WaitForJobToPause (t , sqlA , jobID )
2485
2392
}
2486
2393
2394
+ func TestPartialIndexes (t * testing.T ) {
2395
+ defer leaktest .AfterTest (t )()
2396
+ skip .UnderDeadlock (t )
2397
+ defer log .Scope (t ).Close (t )
2398
+
2399
+ ctx := context .Background ()
2400
+
2401
+ server , s , dbA , dbB := setupLogicalTestServer (t , ctx , testClusterBaseClusterArgs , 1 )
2402
+ defer server .Stopper ().Stop (ctx )
2403
+
2404
+ dbA .Exec (t , "SET CLUSTER SETTING logical_replication.consumer.immediate_mode_writer = 'sql'" )
2405
+
2406
+ dbBURL := replicationtestutils .GetExternalConnectionURI (t , s , s , serverutils .DBName ("b" ))
2407
+
2408
+ dbA .Exec (t , "CREATE TABLE foo (pk INT PRIMARY KEY, pi INT, payload STRING)" )
2409
+ dbA .Exec (t , "CREATE INDEX idx ON foo (pi) WHERE pk > 0" )
2410
+ dbB .Exec (t , "CREATE TABLE b.foo (pk INT PRIMARY KEY, pi INT, payload STRING)" )
2411
+ dbB .Exec (t , "CREATE INDEX idx ON b.foo (pi) WHERE pk < 0" )
2412
+ dbB .Exec (t , "INSERT INTO foo VALUES (1, 2, 'hello')" )
2413
+ dbB .Exec (t , "INSERT INTO foo VALUES (-1, -2, 'world')" )
2414
+
2415
+ var jobAID jobspb.JobID
2416
+ dbA .QueryRow (t , "CREATE LOGICAL REPLICATION STREAM FROM TABLE foo ON $1 INTO TABLE foo" , dbBURL .String ()).Scan (& jobAID )
2417
+ now := s .Clock ().Now ()
2418
+ WaitUntilReplicatedTime (t , now , dbA , jobAID )
2419
+
2420
+ dbA .CheckQueryResultsRetry (t , "SELECT * FROM foo WHERE pi = 2" , [][]string {{"1" , "2" , "hello" }})
2421
+ dbA .CheckQueryResultsRetry (t , "SELECT * FROM foo WHERE pi = -2" , [][]string {{"-1" , "-2" , "world" }})
2422
+
2423
+ // Check for partial indexes when using legacy kv writer.
2424
+ dbA .Exec (t , "SET CLUSTER SETTING logical_replication.consumer.immediate_mode_writer = 'legacy-kv'" )
2425
+ dbA .ExpectErr (t , "cannot create logical replication stream: table foo has a partial index idx" , "CREATE LOGICAL REPLICATION STREAM FROM TABLE foo ON $1 INTO TABLE foo" , dbBURL .String ())
2426
+ }
2427
+
2487
2428
// TestLogicalReplicationCreationChecks verifies that we check that the table
2488
2429
// schemas are compatible when creating the replication stream.
2489
2430
func TestLogicalReplicationCreationChecks (t * testing.T ) {
@@ -2492,16 +2433,8 @@ func TestLogicalReplicationCreationChecks(t *testing.T) {
2492
2433
defer log .Scope (t ).Close (t )
2493
2434
2494
2435
ctx := context .Background ()
2495
- clusterArgs := base.TestClusterArgs {
2496
- ServerArgs : base.TestServerArgs {
2497
- DefaultTestTenant : base .TestControlsTenantsExplicitly ,
2498
- Knobs : base.TestingKnobs {
2499
- JobsTestingKnobs : jobs .NewTestingKnobsWithShortIntervals (),
2500
- },
2501
- },
2502
- }
2503
2436
2504
- server , s , dbA , dbB := setupLogicalTestServer (t , ctx , clusterArgs , 1 )
2437
+ server , s , dbA , dbB := setupLogicalTestServer (t , ctx , testClusterBaseClusterArgs , 1 )
2505
2438
defer server .Stopper ().Stop (ctx )
2506
2439
2507
2440
dbBURL := replicationtestutils .GetExternalConnectionURI (t , s , s , serverutils .DBName ("b" ))
@@ -2543,15 +2476,9 @@ func TestLogicalReplicationCreationChecks(t *testing.T) {
2543
2476
dbA .Exec (t , "ALTER TABLE tab ALTER PRIMARY KEY USING COLUMNS (pk, composite_col)" )
2544
2477
expectErr (t , "tab" , `cannot create logical replication stream: table tab has a primary key column \(composite_col\) with composite encoding` )
2545
2478
replicationtestutils .WaitForAllProducerJobsToFail (t , dbB )
2546
-
2547
- // Check for partial indexes.
2548
2479
dbA .Exec (t , "ALTER TABLE tab ALTER PRIMARY KEY USING COLUMNS (pk)" )
2549
- dbA .Exec (t , "CREATE INDEX partial_idx ON tab(composite_col) WHERE pk > 0" )
2550
- expectErr (t , "tab" , "cannot create logical replication stream: table tab has a partial index partial_idx" )
2551
- replicationtestutils .WaitForAllProducerJobsToFail (t , dbB )
2552
2480
2553
2481
// Check for hash sharded indexes.
2554
- dbA .Exec (t , "DROP INDEX partial_idx" )
2555
2482
dbA .Exec (t , "CREATE INDEX hash_idx ON tab(pk) USING HASH WITH (bucket_count = 4)" )
2556
2483
dbB .Exec (t , "CREATE INDEX hash_idx ON b.tab(pk) USING HASH WITH (bucket_count = 4)" )
2557
2484
expectErr (t , "tab" , "tab has a virtual computed column crdb_internal_pk_shard_4 that is a key of index hash_idx" )
0 commit comments