diff --git a/pkg/storage/client_raft_test.go b/pkg/storage/client_raft_test.go index 3a8b64569b54..e6e6b04b4c87 100644 --- a/pkg/storage/client_raft_test.go +++ b/pkg/storage/client_raft_test.go @@ -3932,6 +3932,12 @@ func TestInitRaftGroupOnRequest(t *testing.T) { defer leaktest.AfterTest(t)() storeCfg := storage.TestStoreConfig(nil /* clock */) storeCfg.TestingKnobs.DisableMergeQueue = true + // Disable async intent resolution. This can lead to flakiness in the test + // because it allows for the intents written by the split transaction to be + // resolved at any time, including after the nodes are restarted. The intent + // resolution on the RHS's local range descriptor can both wake up the RHS + // range's Raft group and result in the wrong replica acquiring the lease. + storeCfg.TestingKnobs.IntentResolverKnobs.DisableAsyncIntentResolution = true mtc := &multiTestContext{ storeConfig: &storeCfg, // TODO(andrei): This test was written before multiTestContexts started with @@ -3963,6 +3969,8 @@ func TestInitRaftGroupOnRequest(t *testing.T) { mtc.restart() // Get replica from the store which isn't the leaseholder. + // NOTE: StoreID is 1-indexed and storeIdx is 0-indexed, so despite what + // this might look like, this is grabbing the replica without the lease. storeIdx := int(lease.Replica.StoreID) % len(mtc.stores) if repl = mtc.stores[storeIdx].LookupReplica(roachpb.RKey(splitKey)); repl == nil { t.Fatal("replica should not be nil for RHS range")