Skip to content

Commit b8a2c4e

Browse files
committed
sql: fix lease duration in TestReacquireLeaseOnRestart
The test jumps the clock forward in order to expire KV leases. However, the DefaultDescriptorLeaseDuration constant that it chooses seems to be by mistake taken as the KV lease duration. Use the RangeLeaseDuration from the server config instead. This also fixes early SQL pod termination when multi-tenancy is enabled. Currently, the lifetime of the SQL pod is the same as that of the session, which has a TTL of 40s (server.sqlliveness.ttl setting). The 10 minute clock jump in this test was causing early SQL pod termination and flakes. Epic: none Release note: none
1 parent c484d09 commit b8a2c4e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/sql/txn_restart_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,9 @@ func TestReacquireLeaseOnRestart(t *testing.T) {
12651265
clientTestingKnobs := &kvcoord.ClientTestingKnobs{
12661266
MaxTxnRefreshAttempts: refreshAttempts,
12671267
}
1268+
var params base.TestServerArgs
1269+
params.RaftConfig.SetDefaults()
1270+
leaseDuration := params.RaftConfig.RangeLeaseDuration
12681271

12691272
testKey := []byte("test_key")
12701273
var s serverutils.ApplicationLayerInterface
@@ -1280,7 +1283,7 @@ func TestReacquireLeaseOnRestart(t *testing.T) {
12801283
atomic.AddInt32(&clockUpdate, 1)
12811284
// Hack to advance the transaction timestamp on a
12821285
// transaction restart.
1283-
const advancement = 2 * base.DefaultDescriptorLeaseDuration
1286+
advancement := 2 * leaseDuration
12841287
now := s.Clock().NowAsClockTimestamp()
12851288
now.WallTime += advancement.Nanoseconds()
12861289
s.Clock().Update(now)
@@ -1310,7 +1313,6 @@ func TestReacquireLeaseOnRestart(t *testing.T) {
13101313
DisableMaxOffsetCheck: true,
13111314
}
13121315

1313-
var params base.TestServerArgs
13141316
params.Knobs.Store = storeTestingKnobs
13151317
params.Knobs.KVClient = clientTestingKnobs
13161318
params.DefaultTestTenant = base.TestDoesNotWorkWithExternalProcessMode(156333)

0 commit comments

Comments
 (0)