The UnblocksWhenCancellationTokenIsCancelled test (defined here) may hang due to the following:
- The main-thread proceeds with running commands for the mocked network interface (here), but is scheduled out after running the first command, which cancels the cancelation token.
- The commit monitor is notified about the cancelation, by checking the cancelation token in here, and returns from the function that queries the shards. As a result, the instance of ARS goes out of scope, and the destructor for ARS cancels any pending network operations.
- The main thread is scheduled again to run commands on behalf of the mocked network interface, but since the pending commands are canceled, it will stay blocked forever.
The simple fix for this data-race is to create a new fail-point that blocks the commit-monitor in here, and unblocks it after canceling the cancelation token. This change obviates the need for the main thread to serve any commands for the mocked network interface.