Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transaction service bug with tx send/receive cancellation #2354

Merged

Conversation

philipr-za
Copy link
Contributor

Description

Fix a bug where the result of the cancellation oneshot in the send and receive protocols was not checked if it was Ok(()). This meant that on a shutdown when the sender side of that oneshot channel is dropped the receiver side resolves to a Err(_) and triggered an attempt to cancel the transaction. Generally the database was already broken down during the shutdown but depending on when stuff is dropped this could mistakenly cancel a pending transaction on wallet shutdown.

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Feature refactor (No new feature or functional changes, but performance or technical debt improvements)
  • New Tests
  • Documentation

Checklist:

  • I'm merging against the development branch.
  • I ran cargo-fmt --all before pushing.
  • I ran cargo test successfully before submitting my PR.
  • I have squashed my commits into a single commit.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

Fix a bug where the result of the cancellation oneshot in the send and receive protocols was not checked if it was Ok(()). This meant that on a shutdown when the sender side of that oneshot channel is dropped the receiver side resolves to a Err(_) and triggered an attempt to cancel the transaction. Generally the database was already broken down during the shutdown but depending on when stuff is dropped this could mistakenly cancel a pending transaction on wallet shutdown.
@delta1
Copy link
Contributor

delta1 commented Oct 20, 2020

Nice catch - is there any test we could add for this?

@philipr-za
Copy link
Contributor Author

Nice catch - is there any test we could add for this?

Couldn't think of a way to test it as the bug occured during shutdown which breaks down all the interfaces you could use to do the test with.

@delta1
Copy link
Contributor

delta1 commented Oct 20, 2020

Yeah I figured it was difficult to test this one! Well spotted.

self.id,
TransactionServiceError::TransactionCancelled,
));
result = cancellation_receiver => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably log the result via warn! if it's not ok().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can only happen if the other end of the channel is shutdown in which case all the channels in this select! will do the same and didn't feel like it needs to be logged as it will happen only in shutdown or else all the channels will show the same error (which are logged).

@stringhandler stringhandler merged commit 23d67d6 into tari-project:development Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants