Skip to content

Commit

Permalink
kvstreamer: add more assertions to RequestsProvider.enqueue
Browse files Browse the repository at this point in the history
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
  • Loading branch information
michae2 committed Aug 10, 2023
1 parent 67e16cb commit 1e3cefe
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/kv/kvclient/kvstreamer/requests_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 1e3cefe

Please sign in to comment.