Skip to content

Commit

Permalink
[DNM] Repro of transferring lease to behind replica causing stall
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
a-robinson committed Oct 3, 2018
1 parent e5644aa commit 933cbd5
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
48 changes: 48 additions & 0 deletions pkg/storage/client_lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,51 @@ func TestGossipSystemConfigOnLeaseChange(t *testing.T) {
return nil
})
}

func TestLeaseTransferToBehindReplica(t *testing.T) {
defer leaktest.AfterTest(t)()
sc := storage.TestStoreConfig(nil)
sc.TestingKnobs.DisableReplicateQueue = true
mtc := &multiTestContext{storeConfig: &sc}
defer mtc.Stop()
const numStores = 3
mtc.Start(t, numStores)

mtc.replicateRange(roachpb.RangeID(1), 1, 2)

splitKeys := []roachpb.Key{
keys.NodeLivenessKeyMax, roachpb.Key("a"), roachpb.Key("b"), roachpb.Key("c"),
}
for _, splitKey := range splitKeys {
splitArgs := adminSplitArgs(splitKey)
if _, pErr := client.SendWrapped(context.Background(), mtc.distSenders[0], splitArgs); pErr != nil {
t.Fatal(pErr)
}
}

s0Repl := mtc.stores[0].LookupReplica(roachpb.RKey("c"))
s2Repl := mtc.stores[2].LookupReplica(roachpb.RKey("c"))
t.Errorf("s0 desc: %v", s0Repl.Desc())
lease, nextLease := s0Repl.GetLease()
t.Errorf("s0 lease: %v, %v", lease, nextLease)
t.Errorf("s0 desc: %v", s2Repl.Desc())
lease, nextLease = s2Repl.GetLease()
t.Errorf("s2 lease: %v, %v", lease, nextLease)

mtc.transferLease(context.TODO(), s0Repl.RangeID, 0, 2)

lease, nextLease = s0Repl.GetLease()
t.Errorf("s0 lease: %v, %v", lease, nextLease)
lease, nextLease = s2Repl.GetLease()
t.Errorf("s2 lease: %v, %v", lease, nextLease)

testutils.SucceedsSoon(t, func() error {
splitArgs := adminSplitArgs(roachpb.Key("d"))
if _, pErr := client.SendWrapped(context.Background(), mtc.distSenders[0], splitArgs); pErr != nil {
t.Errorf("split failed: %v", pErr)
return pErr.GoError()
}
return nil
})
t.Errorf("split succeeded")
}
4 changes: 4 additions & 0 deletions pkg/storage/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -4059,6 +4059,10 @@ func (r *Replica) handleRaftReadyRaftMuLocked(
) (handleRaftReadyStats, string, error) {
var stats handleRaftReadyStats

if r.store.StoreID() == roachpb.StoreID(3) && r.RangeID >= 5 {
return stats, "", nil
}

ctx := r.AnnotateCtx(context.TODO())
var hasReady bool
var rd raft.Ready
Expand Down

1 comment on commit 933cbd5

@a-robinson
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this proof of concept, the client.SendWrapped call just stalls forever as NotLeaseHolderErrors pile up.

Please sign in to comment.