copy_both: handle Future
cancellation case
#27
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When a user starts a CopyBoth query a state machine is created that is responsible for driving the CopyBoth protocol forward regardless of what the user does with the returned handles. The state machine starts in the
Setup
phase and only gives control back to the user (in the form of the returned handles) after having finished with the Setup. Therefore the code assumed (incorrectly) that the handles will never be dropped while in Setup mode.It turns out there is one more way of dropping the handle even while in the Setup phase, and that is to cancel the entire Future object returned by the
copy_both
method at just the right time. This resulted in the state machine observing that the handles were dropped while still in the Setup phase, which was asserted to never happen.This PR fixes the problem by handling the case where a handles are dropped while still in the
Setup
phase.Fixes: https://github.com/MaterializeInc/database-issues/issues/8604