Skip to content

Commit

Permalink
logictest: raise TxnLivenessThreshold for multitenant configs
Browse files Browse the repository at this point in the history
Logic tests are flaky due to overload when running in multitenant mode.
This patch increases the threshold for transaction heartbeat timeouts,
which will make it less likely for foreground operations to be aborted
by background jobs like the span config reconciler or the job registry
loop to reclaim jobs from dead sessions.

Release note: None
  • Loading branch information
rafiss committed Feb 6, 2025
1 parent ce79475 commit a82c963
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/sql/logictest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ go_library(
"//pkg/kv/kvclient/rangefeed",
"//pkg/kv/kvserver",
"//pkg/kv/kvserver/kvserverbase",
"//pkg/kv/kvserver/txnwait",
"//pkg/multitenant/tenantcapabilities",
"//pkg/security/username",
"//pkg/server",
Expand Down
28 changes: 28 additions & 0 deletions pkg/sql/logictest/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/kv/kvclient/rangefeed"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverbase"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/txnwait"
"github.com/cockroachdb/cockroach/pkg/multitenant/tenantcapabilities"
"github.com/cockroachdb/cockroach/pkg/security/username"
"github.com/cockroachdb/cockroach/pkg/server"
Expand Down Expand Up @@ -1709,6 +1710,21 @@ func (t *logicTest) newCluster(
t.Fatal(err)
}
}
if _, err := conn.Exec(
"RESET CLUSTER SETTING kv.closed_timestamp.target_duration",
); err != nil {
t.Fatal(err)
}
if _, err := conn.Exec(
"RESET CLUSTER SETTING kv.closed_timestamp.side_transport_interval",
); err != nil {
t.Fatal(err)
}
if _, err := conn.Exec(
"RESET CLUSTER SETTING kv.rangefeed.closed_timestamp_refresh_interval",
); err != nil {
t.Fatal(err)
}
}

capabilities := toa.capabilities
Expand Down Expand Up @@ -4353,6 +4369,18 @@ func RunLogicTest(
if *printErrorSummary {
defer lt.printErrorSummary()
}
if config.UseSecondaryTenant == logictestbase.Always {
// Under multitenant configs running in EngFlow, we have seen that logic
// tests can be flaky due to an overload condition where schema change
// transactions do not heartbeat quickly enough. This allows background jobs
// such as the spanconfig reconciler or the job registry "remove claims from
// dead sessions" loop.
// See https://github.com/cockroachdb/cockroach/pull/140400#issuecomment-2634346278
// and https://github.com/cockroachdb/cockroach/issues/140494#issuecomment-2640208187
// for a detailed analysis of this issue.
cleanup := txnwait.TestingOverrideTxnLivenessThreshold(30 * time.Second)
defer cleanup()
}
// Each test needs a copy because of Parallel
serverArgsCopy := serverArgs
serverArgsCopy.ForceProductionValues = serverArgs.ForceProductionValues || nonMetamorphicBatchSizes
Expand Down

0 comments on commit a82c963

Please sign in to comment.