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

RATIS-1490. Follower should not change to candidate if already stopped #581

Merged
merged 1 commit into from Jan 18, 2022

Conversation

adoroszlai
Copy link
Contributor

What changes were proposed in this pull request?

RaftServerImpl creates a new FollowerState for each vote request received. The old FollowerState may trigger change to candidate role even after it was shutdown by the server. Both RaftServerImpl#requestVote and the change to candidate by FollowerState requires lock on server (RaftServerImpl object). The order of events which triggers the problem:

Let FollowerState check if it is still running after entering the synchronized block.

https://issues.apache.org/jira/browse/RATIS-1490

How was this patch tested?

Tweaked FollowerState, RaftServerImpl and LeaderElectionTests with code injection. It required too much test-specific code, even in synchronized blocks, so I think it should not be part of this patch. Ideas for unit tests welcome.

Regular CI:
https://github.com/adoroszlai/incubator-ratis/runs/4845475132

@adoroszlai adoroszlai self-assigned this Jan 17, 2022
@codings-dan
Copy link
Contributor

I think this change is good, but it doesn't seem to be very easy to test it. Is it possible to consider adding a way to start Application in software like Intellij IDEA and start several ratis servers locally, which can easily add breakpoints and reproduce the problem, which is helpful for debugging and testing.

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

+1 the change looks good.

@szetszwo szetszwo merged commit b53c51d into apache:master Jan 18, 2022
@adoroszlai adoroszlai deleted the RATIS-1490 branch January 18, 2022 14:55
@adoroszlai
Copy link
Contributor Author

Thanks @codings-dan, @szetszwo for the review, @szetszwo for merging this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants