Skip to content

Commit 529ffb8

Browse files
craig[bot]yuzefovichdhartunianfqazirickystewart
committed
156306: changefeedccl: enable a couple of tests with test tenant r=yuzefovich a=yuzefovich Fixes: #98816 Informs: #142799 Release note: None 156317: insights: skip contention test under duress r=alyshanjahani-crl a=dhartunian Resolves: #155838 Resolves: #155962 Epic: None Release note: None 156387: catalog/lease: address deadlock with locked lease timestamps r=fqazi a=fqazi Previously, when locked lease timestamps were used, we held the descriptor state while acquiring close timestamp handles. This could lead to a deadlock, since in other code paths we acquire the close timestamp handle first. To address this, this patch avoids holding the descriptor state lock longer than necessary. Fixes: #156177 Release note: None 156388: cliccl: fix FIPS-readiness check r=rail a=rickystewart The logic here is flipped. Release note: none Epic: DEVINF-1477 Co-authored-by: Yahor Yuzefovich <[email protected]> Co-authored-by: David Hartunian <[email protected]> Co-authored-by: Faizan Qazi <[email protected]> Co-authored-by: Ricky Stewart <[email protected]>
5 parents de81162 + f73ef47 + 953b515 + 9d024ef + d2b19ef commit 529ffb8

File tree

7 files changed

+39
-51
lines changed

7 files changed

+39
-51
lines changed

pkg/ccl/changefeedccl/alter_changefeed_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestAlterChangefeedAddTargetPrivileges(t *testing.T) {
5757
ctx := context.Background()
5858

5959
s, db, _ := serverutils.StartServer(t, base.TestServerArgs{
60-
DefaultTestTenant: base.TODOTestTenantDisabled,
60+
DefaultTestTenant: base.TestDoesNotWorkWithSecondaryTenantsButWeDontKnowWhyYet(142799),
6161
Knobs: base.TestingKnobs{
6262
JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(),
6363
DistSQL: &execinfra.TestingKnobs{

pkg/ccl/changefeedccl/changefeed_test.go

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,7 +2621,7 @@ func TestChangefeedExternalIODisabled(t *testing.T) {
26212621
}
26222622
ctx := context.Background()
26232623
s, db, _ := serverutils.StartServer(t, base.TestServerArgs{
2624-
DefaultTestTenant: base.TODOTestTenantDisabled,
2624+
DefaultTestTenant: base.TestDoesNotWorkWithSecondaryTenantsButWeDontKnowWhyYet(142799),
26252625
ExternalIODirConfig: base.ExternalIODirConfig{
26262626
DisableOutbound: true,
26272627
},
@@ -4067,7 +4067,7 @@ func TestChangefeedCreateAuthorizationWithChangefeedPriv(t *testing.T) {
40674067

40684068
ctx := context.Background()
40694069
s, db, _ := serverutils.StartServer(t, base.TestServerArgs{
4070-
DefaultTestTenant: base.TODOTestTenantDisabled,
4070+
DefaultTestTenant: base.TestDoesNotWorkWithSecondaryTenantsButWeDontKnowWhyYet(142799),
40714071
Knobs: base.TestingKnobs{
40724072
JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(),
40734073
DistSQL: &execinfra.TestingKnobs{
@@ -8384,9 +8384,7 @@ func TestChangefeedHandlesDrainingNodes(t *testing.T) {
83848384

83858385
tc := serverutils.StartCluster(t, 4, base.TestClusterArgs{
83868386
ServerArgs: base.TestServerArgs{
8387-
// Test uses SPLIT AT, which isn't currently supported for
8388-
// secondary tenants. Tracked with #76378.
8389-
DefaultTestTenant: base.TODOTestTenantDisabled,
8387+
DefaultTestTenant: base.TestDoesNotWorkWithSecondaryTenantsButWeDontKnowWhyYet(142799),
83908388
UseDatabase: "test",
83918389
Knobs: knobs,
83928390
ExternalIODir: sinkDir,
@@ -8549,9 +8547,7 @@ func TestChangefeedHandlesRollingRestart(t *testing.T) {
85498547
return perNode
85508548
}(),
85518549
ServerArgs: base.TestServerArgs{
8552-
// Test uses SPLIT AT, which isn't currently supported for
8553-
// secondary tenants. Tracked with #76378.
8554-
DefaultTestTenant: base.TODOTestTenantDisabled,
8550+
DefaultTestTenant: base.TestDoesNotWorkWithSecondaryTenantsButWeDontKnowWhyYet(142799),
85558551
},
85568552
})
85578553
defer tc.Stopper().Stop(context.Background())
@@ -8707,9 +8703,7 @@ func TestChangefeedTimelyResolvedTimestampUpdatePostRollingRestart(t *testing.T)
87078703
base.TestClusterArgs{
87088704
ServerArgsPerNode: perServerKnobs,
87098705
ServerArgs: base.TestServerArgs{
8710-
// Test uses SPLIT AT, which isn't currently supported for
8711-
// secondary tenants. Tracked with #76378.
8712-
DefaultTestTenant: base.TODOTestTenantDisabled,
8706+
DefaultTestTenant: base.TestDoesNotWorkWithSecondaryTenantsButWeDontKnowWhyYet(142799),
87138707
},
87148708
ReusableListenerReg: listenerReg,
87158709
})
@@ -8802,9 +8796,7 @@ func TestChangefeedPropagatesTerminalError(t *testing.T) {
88028796
ServerArgsPerNode: perServerKnobs,
88038797
ReplicationMode: base.ReplicationManual,
88048798
ServerArgs: base.TestServerArgs{
8805-
// Test uses SPLIT AT, which isn't currently supported for
8806-
// secondary tenants. Tracked with #76378.
8807-
DefaultTestTenant: base.TODOTestTenantDisabled,
8799+
DefaultTestTenant: base.TestDoesNotWorkWithSecondaryTenantsButWeDontKnowWhyYet(142799),
88088800
},
88098801
})
88108802
defer tc.Stopper().Stop(context.Background())
@@ -11309,7 +11301,7 @@ func TestChangefeedExecLocality(t *testing.T) {
1130911301
const nodes = 4
1131011302
args := base.TestClusterArgs{
1131111303
ServerArgs: base.TestServerArgs{
11312-
DefaultTestTenant: base.TODOTestTenantDisabled, // need nodelocal and splits.
11304+
DefaultTestTenant: base.TestDoesNotWorkWithSecondaryTenantsButWeDontKnowWhyYet(142799),
1131311305
},
1131411306
ServerArgsPerNode: map[int]base.TestServerArgs{},
1131511307
}

pkg/ccl/changefeedccl/parquet_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,16 @@ func TestParquetRows(t *testing.T) {
4848
skip.UnderStress(t)
4949

5050
ctx := context.Background()
51-
s, db, _ := serverutils.StartServer(t, base.TestServerArgs{
52-
// TODO(#98816): cdctest.GetHydratedTableDescriptor does not work with tenant dbs.
53-
// Once it is fixed, this flag can be removed.
54-
DefaultTestTenant: base.TODOTestTenantDisabled,
55-
})
56-
defer s.Stopper().Stop(ctx)
51+
srv, db, _ := serverutils.StartServer(t, base.TestServerArgs{})
52+
defer srv.Stopper().Stop(ctx)
53+
s := srv.ApplicationLayer()
54+
55+
sysDB := sqlutils.MakeSQLRunner(srv.SystemLayer().SQLConn(t))
56+
sysDB.Exec(t, "SET CLUSTER SETTING kv.rangefeed.enabled = true")
5757

5858
maxRowGroupSize := int64(4)
5959

6060
sqlDB := sqlutils.MakeSQLRunner(db)
61-
sqlDB.Exec(t, "SET CLUSTER SETTING kv.rangefeed.enabled = true")
6261

6362
newDecimal := func(s string) *tree.DDecimal {
6463
d, _, _ := apd.NewFromString(s)
@@ -264,7 +263,7 @@ func TestParquetRows(t *testing.T) {
264263
}
265264

266265
func makeRangefeedReaderAndDecoder(
267-
t *testing.T, s serverutils.TestServerInterface,
266+
t *testing.T, s serverutils.ApplicationLayerInterface,
268267
) (func(t testing.TB) *kvpb.RangeFeedValue, func(), cdcevent.Decoder) {
269268
tableDesc := cdctest.GetHydratedTableDescriptor(t, s.ExecutorConfig(), "foo")
270269
popRow, cleanup := cdctest.MakeRangeFeedValueReader(t, s.ExecutorConfig(), tableDesc)

pkg/ccl/changefeedccl/scheduled_changefeed_test.go

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"context"
1010
gosql "database/sql"
1111
"fmt"
12-
"net/url"
1312
"strconv"
1413
"strings"
1514
"testing"
@@ -304,8 +303,7 @@ func TestCreateChangefeedScheduleChecksPermissionsDuringDryRun(t *testing.T) {
304303
defer log.Scope(t).Close(t)
305304

306305
ctx := context.Background()
307-
s, db, _ := serverutils.StartServer(t, base.TestServerArgs{
308-
DefaultTestTenant: base.TODOTestTenantDisabled,
306+
srv, db, _ := serverutils.StartServer(t, base.TestServerArgs{
309307
Knobs: base.TestingKnobs{
310308
JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(),
311309
DistSQL: &execinfra.TestingKnobs{
@@ -320,25 +318,20 @@ func TestCreateChangefeedScheduleChecksPermissionsDuringDryRun(t *testing.T) {
320318
},
321319
},
322320
})
323-
defer s.Stopper().Stop(ctx)
324-
rootDB := sqlutils.MakeSQLRunner(db)
325-
rootDB.Exec(t, `SET CLUSTER SETTING kv.rangefeed.enabled = true`)
321+
defer srv.Stopper().Stop(ctx)
322+
s := srv.ApplicationLayer()
323+
324+
sysDB := sqlutils.MakeSQLRunner(srv.SystemLayer().SQLConn(t))
325+
sysDB.Exec(t, "SET CLUSTER SETTING kv.rangefeed.enabled = true")
326+
327+
sqlDB := sqlutils.MakeSQLRunner(db)
326328
enableEnterprise := utilccl.TestingDisableEnterprise()
327329
enableEnterprise()
328330

329-
rootDB.Exec(t, `CREATE TABLE table_a (i int)`)
330-
rootDB.Exec(t, `CREATE USER testuser WITH PASSWORD 'test'`)
331+
sqlDB.Exec(t, `CREATE TABLE table_a (i int)`)
332+
sqlDB.Exec(t, `CREATE USER testuser WITH PASSWORD 'test'`)
331333

332-
pgURL := url.URL{
333-
Scheme: "postgres",
334-
User: url.UserPassword("testuser", "test"),
335-
Host: s.SQLAddr(),
336-
}
337-
db2, err := gosql.Open("postgres", pgURL.String())
338-
if err != nil {
339-
t.Fatal(err)
340-
}
341-
defer db2.Close()
334+
db2 := s.SQLConn(t, serverutils.UserPassword("testuser", "test"))
342335
userDB := sqlutils.MakeSQLRunner(db2)
343336

344337
userDB.ExpectErr(t, `Failed to dry run create changefeed: user "testuser" requires the CHANGEFEED privilege on all target tables to be able to run an enterprise changefeed`,

pkg/ccl/cliccl/flags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (f *requireFipsFlag) Set(s string) error {
4242
// this behavior globally (PersistentPreRun functions don't help because
4343
// they are inherited across different levels of the command hierarchy only
4444
// if that level does not have its own hook).
45-
if v && fips140.Enabled() {
45+
if v && !fips140.Enabled() {
4646
err := errors.WithHint(errors.New("FIPS readiness checks failed"), "Run `cockroach debug enterprise-check-fips` for details")
4747
clierror.OutputError(os.Stderr, err, true, false)
4848
exit.WithCode(exit.UnspecifiedError())

pkg/sql/catalog/lease/lease.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,12 +1321,14 @@ func (m *Manager) purgeOldVersions(
13211321
handle.release(ctx)
13221322
}
13231323
}()
1324-
state := m.findDescriptorState(id, false)
1325-
state.mu.Lock()
1326-
defer state.mu.Unlock()
1327-
// Find the previous version and determine the timestamp handle that
1328-
// it belongs to.
1329-
prev := state.mu.active.findPrevious()
1324+
prev, newest := func() (*descriptorVersionState, *descriptorVersionState) {
1325+
state := m.findDescriptorState(id, false)
1326+
state.mu.Lock()
1327+
defer state.mu.Unlock()
1328+
// Find the previous version and determine the timestamp handle that
1329+
// it belongs to.
1330+
return state.mu.active.findPrevious(), state.mu.active.findNewest()
1331+
}()
13301332
// If there is no previous or the previous version is a historical descriptor,
13311333
// nothing needs to be done (i.e. no active lease or already setup for
13321334
// expiration).
@@ -1358,8 +1360,8 @@ func (m *Manager) purgeOldVersions(
13581360
handle.mu.leasesToRelease[id].(*descriptorVersionState).getExpiration(ctx),
13591361
prev.GetVersion(),
13601362
prev.getExpiration(ctx),
1361-
state.mu.active.findNewest().GetVersion(),
1362-
state.mu.active.findNewest().getExpiration(ctx))
1363+
newest.GetVersion(),
1364+
newest.getExpiration(ctx))
13631365
}
13641366
// Bump the refcount on the previous version of the descriptor and attach
13651367
// it to the relevant timestamp.

pkg/sql/sqlstats/insights/integration/insights_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,8 @@ func TestInsightsIntegrationForContention(t *testing.T) {
780780
defer leaktest.AfterTest(t)()
781781
defer log.Scope(t).Close(t)
782782

783+
skip.UnderDuress(t)
784+
783785
// Start the cluster. (One node is sufficient; the outliers system is currently in-memory only.)
784786
ctx := context.Background()
785787
settings := cluster.MakeTestingClusterSettings()

0 commit comments

Comments
 (0)