Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
50352: catalog/lease: fix flakey TestTxnObeysTableModificationTime r=lucy-zhang a=ajwerner

Prior to this change the test would fail under roachprod stressrace almost
instantly if the `-p` flag was set high enough. It has now survived for
15ish minutes.

Fixes cockroachdb#47142.

Release note: None

Co-authored-by: Andrew Werner <[email protected]>
  • Loading branch information
craig[bot] and ajwerner committed Jun 17, 2020
2 parents 6589106 + 15e6892 commit 3426ece
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/sql/catalog/lease/lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
"github.com/cockroachdb/cockroach/pkg/testutils/testcluster"
"github.com/cockroachdb/cockroach/pkg/util"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/cockroachdb/cockroach/pkg/util/log"
Expand Down Expand Up @@ -913,6 +914,19 @@ func TestTxnObeysTableModificationTime(t *testing.T) {
// TTL into the system with AddImmediateGCZoneConfig.
defer sqltestutils.DisableGCTTLStrictEnforcement(t, sqlDB)()

// This test intentionally relies on uncontended transactions not being pushed
// in order to verify what it claims to verify. The default closed timestamp
// interval in 20.1+ is 3s. When run under the race detector, the process can
// stall for upwards of 3s leading to the write transaction getting pushed.
//
// In order to mitigate that push, we increase the target_duration when the
// test is run under race.
if util.RaceEnabled {
_, err := sqlDB.Exec(
"SET CLUSTER SETTING kv.closed_timestamp.target_duration = '120s'")
require.NoError(t, err)
}

if _, err := sqlDB.Exec(`
CREATE DATABASE t;
CREATE TABLE t.kv (k CHAR PRIMARY KEY, v CHAR);
Expand Down

0 comments on commit 3426ece

Please sign in to comment.