-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
flowinfra: fix a rare bug that could make drain be stuck forever
This commit fixes a long-standing bug around the flow registry that could make the drain loop be stuck forever. Drain process works by draining several components in a loop until each component reports that there was no more remaining work when the drain iteration was initiated. One of the components to be drained is the flow registry: namely, we want to make sure that there are no more remote flows present on the node. We track that by having a map from the `FlowID` to the `flowEntry` object. Previously, it was possible for a `flowEntry` to become "stale" and remain in the map forever. In particular, this was the case when - `ConnectInboundStream` was called before the flow was scheduled - the gRPC "handshake" failed in `ConnectInboundStream` (most likely due to a network fluke) - the flow never arrived (perhaps it was canceled before `Flow.StartInternal` is called), or it arrived too late when the registry was marked as "draining". With such a scenario we would create a `flowEntry` with ref count of zero and add it to the map in `ConnectInboundStream`, but no one would ever remove it. This commit fixes this oversight by adjusting the ref counting logic a bit so that we always hold a reference throughout (and only until the end of) `ConnectInboundStream`. Release note (bug fix): A rare bug with distributed plans shutdown has been fixed that previously could make the graceful drain of cockroach nodes be retrying forever. The bug has been present since before 22.1. The drain process is affected by this bug if you see messages in the logs like `drain details: distSQL execution flows:` with non-zero number of flows that isn't going down over long period of time.
- Loading branch information
1 parent
b2ef99d
commit 8d939df
Showing
3 changed files
with
67 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters