Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
79716: colexec: fix recent regression with cancellation of inboxes r=yuzefovich a=yuzefovich Recent change 773d9ca fixed the way inboxes handle regular query errors so that now the gRPC streams are not broken whenever a query error is encountered. However, that change introduced a regression - it is now possible that the inbox handler goroutine (the one instantiated to handle FlowStream gRPC call) never exits when the inbox is an input to the parallel unordered synchronizer. In particular, the following sequence of events can happen: 1. the reader goroutine of the inbox receives an error from the corresponding outbox 2. this error is propagated to one of the input goroutines of the unordered synchronizer via a panic. Notably, this is considered a "graceful" termination from the perspective of the gRPC stream handling, so the handler goroutine is not notified of this error, and the inbox is not closed. It is expected that the inbox will be drained which will close the handler goroutine. 3. however, the synchronizer input goroutine currently simply receives the error, propagates it to the coordinator goroutine, and exits, without performing the draining. Thus, we get into such a state that the inbox is never drained, so the handler goroutine will stay alive forever. In particular, this will block `Flow.Wait` calls, and `Flow.Cleanup` will never be called. This could leak, for example, to leaking file descriptors used by the temporary disk storage in the vectorized engine. This fix is quite simple - instead of exiting in step 3, the synchronizer's input goroutine should just proceed to draining, and only exit once draining is performed. I believe this was always the intention, but it didn't really matter until the fix in 773d9ca because draining of the inbox was a noop since the gRPC stream was prematurely broken. Fixes: #79469. Release note: None Co-authored-by: Yahor Yuzefovich <[email protected]>
- Loading branch information