From b9cfa4cef957c532ce0435a303fce6d1a808db34 Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Fri, 24 Mar 2017 13:09:54 -0700 Subject: [PATCH 1/2] integration: add serialized range to TestV3CompactCurrentRev To catch compaction bugs in the proxy key cache. --- integration/v3_grpc_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/integration/v3_grpc_test.go b/integration/v3_grpc_test.go index 4d9945b84..5113821de 100644 --- a/integration/v3_grpc_test.go +++ b/integration/v3_grpc_test.go @@ -123,16 +123,25 @@ func TestV3CompactCurrentRev(t *testing.T) { t.Fatalf("couldn't put key (%v)", err) } } + // get key to add to proxy cache, if any + if _, err := kvc.Range(context.TODO(), &pb.RangeRequest{Key: []byte("foo")}); err != nil { + t.Fatal(err) + } // compact on current revision _, err := kvc.Compact(context.Background(), &pb.CompactionRequest{Revision: 4}) if err != nil { t.Fatalf("couldn't compact kv space (%v)", err) } - // key still exists? + // key still exists when linearized? _, err = kvc.Range(context.Background(), &pb.RangeRequest{Key: []byte("foo")}) if err != nil { t.Fatalf("couldn't get key after compaction (%v)", err) } + // key still exists when serialized? + _, err = kvc.Range(context.Background(), &pb.RangeRequest{Key: []byte("foo"), Serializable: true}) + if err != nil { + t.Fatalf("couldn't get serialized key after compaction (%v)", err) + } } func TestV3TxnTooManyOps(t *testing.T) { From b2a465e3545ef95b5db5429f5ef349464fb87256 Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Fri, 24 Mar 2017 13:18:31 -0700 Subject: [PATCH 2/2] grpcproxy/cache: only check compaction revision for historical revisions Since the current revision is 0, it'll always be less than the compaction revision. If the proxy sees a compaction, it would always reject the current revision requests since it's less than the compaction revision. Instead, check if the revision is historical before trying to reject on compaction revision. Fixes #7599 --- proxy/grpcproxy/cache/store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy/grpcproxy/cache/store.go b/proxy/grpcproxy/cache/store.go index 895fb1f97..9936ab3d2 100644 --- a/proxy/grpcproxy/cache/store.go +++ b/proxy/grpcproxy/cache/store.go @@ -111,7 +111,7 @@ func (c *cache) Get(req *pb.RangeRequest) (*pb.RangeResponse, error) { c.mu.Lock() defer c.mu.Unlock() - if req.Revision < c.compactedRev { + if req.Revision > 0 && req.Revision < c.compactedRev { c.lru.Remove(key) return nil, ErrCompacted }