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

raft: Fix race when proposal is cancelled and triggered at the same time #1846

Merged
merged 1 commit into from
Jan 6, 2017

Conversation

aaronlehmann
Copy link
Collaborator

The demotion changes revealed an interesting race. If a proposal is
triggered at the same moment that something cancels it, the callback can
be called (which commits the transaction to memory), but an error can be
returned from ProposeValue, which causes the transaction to be aborted.

ProposeValue should return an error if and only if the callback was not
called.

Add a return value to cancel(). If cancel fails because the proposal was
already triggered, avoid returning an error.

Also, remove the applyResult type, since it isn't useful.

The demotion changes revealed an interesting race. If a proposal is
triggered at the same moment that something cancels it, the callback can
be called (which commits the transaction to memory), but an error can be
returned from ProposeValue, which causes the transaction to be aborted.

ProposeValue should return an error if and only if the callback was not
called.

Add a return value to cancel(). If cancel fails because the proposal was
already triggered, avoid returning an error.

Also, remove the applyResult type, since it isn't useful.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
@codecov-io
Copy link

Current coverage is 54.66% (diff: 50.00%)

Merging #1846 into master will decrease coverage by 0.05%

@@             master      #1846   diff @@
==========================================
  Files           102        102          
  Lines         17041      17041          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits           9325       9315    -10   
- Misses         6583       6588     +5   
- Partials       1133       1138     +5   

Sunburst

Powered by Codecov. Last update 2e956c4...18869b9

Copy link
Contributor

@LK4D4 LK4D4 left a comment

Choose a reason for hiding this comment

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

LGTM

@cyli
Copy link
Contributor

cyli commented Jan 6, 2017

LGTM

@aaronlehmann aaronlehmann merged commit 9512037 into moby:master Jan 6, 2017
@aaronlehmann aaronlehmann deleted the raft-wait-race branch January 6, 2017 02:02
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.

4 participants