From 1e3cefe321237c0af98b6a0b10de33a2106367ab Mon Sep 17 00:00:00 2001 From: Michael Erickson Date: Wed, 9 Aug 2023 23:30:32 -0700 Subject: [PATCH] kvstreamer: add more assertions to RequestsProvider.enqueue If we ever enqueue zero-length requests, it could cause a deadlock where the `workerCoordinator` is waiting for more requests and the enqueuer is waiting for results. Add assertions that we never do this. Release note: None --- pkg/kv/kvclient/kvstreamer/requests_provider.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/kv/kvclient/kvstreamer/requests_provider.go b/pkg/kv/kvclient/kvstreamer/requests_provider.go index 14efdd53ab6b..6f1baf680cb3 100644 --- a/pkg/kv/kvclient/kvstreamer/requests_provider.go +++ b/pkg/kv/kvclient/kvstreamer/requests_provider.go @@ -264,6 +264,9 @@ func (p *outOfOrderRequestsProvider) enqueue(requests []singleRangeBatch) { if len(p.requests) > 0 { panic(errors.AssertionFailedf("outOfOrderRequestsProvider has old requests in enqueue")) } + if len(requests) == 0 { + panic(errors.AssertionFailedf("outOfOrderRequestsProvider enqueuing zero requests")) + } p.requests = requests p.hasWork.Signal() } @@ -388,6 +391,9 @@ func (p *inOrderRequestsProvider) enqueue(requests []singleRangeBatch) { if len(p.requests) > 0 { panic(errors.AssertionFailedf("inOrderRequestsProvider has old requests in enqueue")) } + if len(requests) == 0 { + panic(errors.AssertionFailedf("inOrderRequestsProvider enqueuing zero requests")) + } p.requests = requests p.heapInit() p.hasWork.Signal()