Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Slave should always switch to SLAVE for the most recently selected ma…
…ster When a slave get a masterIsAvailable message, it will try to go to SLAVE for the selected master. However if during its state change from TO_SLAVE to SLAVE, the slave get a new masterIsAvailable message from another master (the first master fails and another master is selected), the slave should reset the master id and try to switch to SLAVE for the newly selected master. The state change from TO_SLAVE to SLAVE is done by a scheduled executor in a separate thread. So whenever we receive masterIsAvailable message, we should always make sure that the executor could see this master change. This pr fix a rare bug where a slave fails to come online because it enters an infinite loop to switch to SLAVE for a wrong/stale master. The bug was seen if the messages came to a slave with the following order: Got coordinator(1) | SLAVE -> SLAVE | electedMasterId = 1 Got coordinator(2) | SLAVE -> PENDING | electedMasterId = 2 Got masterIsAvailable(1) | PENDING -> TO_SLAVE | availableMasterId = 1 and switchToSlave Got masterIsAvailable(2) | TO_SLAVE -> TO_SLAVE | availableMasterId = 2
- Loading branch information
Zhen
committed
Feb 24, 2015
1 parent
f4320df
commit 99469b3
Showing
2 changed files
with
114 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters