Fix one more race condition in RedisLeaderTests
https://build.spring.io/browse/INT-SI50X-JOB1-56 We can't wait for the latch in the interruptable code flow; we can't have a round-robing election guarantees. * Add `Thread.sleep(LockRegistryLeaderInitiator.this.busyWaitMillis)` to the `LockRegistryLeaderInitiator` when we restart the main task * Remove latches waiting and thread shifting from the `RedisLockRegistryLeaderInitiatorTests` * Use long `busyWaitMillis` for yielding initiator to let the second candidate to be elected **Cherry-pick to 5.0.x**
This commit is contained in:
@@ -408,7 +408,12 @@ public class LockRegistryLeaderInitiator implements SmartLifecycle, DisposableBe
|
||||
if (isRunning()) {
|
||||
logger.warn("Restarting LeaderSelector for " + this.context + " because of error.", e);
|
||||
LockRegistryLeaderInitiator.this.future =
|
||||
LockRegistryLeaderInitiator.this.executorService.submit(this);
|
||||
LockRegistryLeaderInitiator.this.executorService.submit(
|
||||
() -> {
|
||||
// Give it a chance to elect some other leader.
|
||||
Thread.sleep(LockRegistryLeaderInitiator.this.busyWaitMillis);
|
||||
return call();
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user