integration: test inflight range requests while defragmenting
@@ -47,3 +47,31 @@ func TestV3MaintenanceHashInflight(t *testing.T) {
<-donec
}
+
+// TestV3MaintenanceDefragmentInflightRange ensures inflight range requests
+// does not panic the mvcc backend while defragment is running.
+func TestV3MaintenanceDefragmentInflightRange(t *testing.T) {
+ defer testutil.AfterTest(t)
+ clus := NewClusterV3(t, &ClusterConfig{Size: 1})
+ defer clus.Terminate(t)
+
+ cli := clus.RandClient()
+ kvc := toGRPC(cli).KV
+ if _, err := kvc.Put(context.Background(), &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")}); err != nil {
+ t.Fatal(err)
+ }
+
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second)
+
+ donec := make(chan struct{})
+ go func() {
+ defer close(donec)
+ kvc.Range(ctx, &pb.RangeRequest{Key: []byte("foo")})
+ }()
+
+ mvc := toGRPC(cli).Maintenance
+ mvc.Defragment(context.Background(), &pb.DefragmentRequest{})
+ cancel()
+
+ <-donec
+}
