Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: drain instead of hard shutdown in DistSQLReceiver.Push
Previously, when the DistSQLReceiver encountered an error or received enough rows to satisfy its consumer, it would transition to `ConsumerClosed` status. I believe this is an incorrect behavior, and in almost all cases we actually must transition to draining (we already had several TODOs to do that), the only exception is if we're canceled (indicated by an error on the context). My reasoning is that there are certain types of metadata (like LeafTxnFinalState) that must be received by the gateway to achieve the correctness, yet that metadata is only collected in the draining state, so if we go from `NeedMoreRows` to `ConsumerClosed`, we don't get a chance to collect that meta. As a concrete example, consider the way we implemented portals with limits - some SELECT query reads some rows, once the portal limit is satisfied, an error is returned from `AddRow`, this will currently cause us to perform a hard shutdown of the flow, and we end up not collecting spans to refresh. I believe it is a no bueno. This commit fixes this problem by transitioning to draining in all cases except when the context has an error. Release note: None
- Loading branch information