Search before asking
What happened
In FailoverCoordinator.doMasterFailover(), the lock path used by getLock and releaseLock is inconsistent:
// getLock uses a per-master-address lock path
registryClient.getLock(RegistryUtils.getMasterFailoverLockPath(masterAddress));
try {
// ... failover logic
} finally {
// releaseLock uses the global enum path, which differs from getLock
registryClient.releaseLock(RegistryNodeType.MASTER_FAILOVER_LOCK.getRegistryPath());
}
What you expected to happen
getLock and releaseLock should use the same lock path to ensure the lock is properly acquired and released.
Root cause
This issue was introduced by PR #16953 (commit b6b04617). That PR changed getLock from the global lock path RegistryNodeType.MASTER_FAILOVER_LOCK.getRegistryPath() to a per-master-address fine-grained lock path RegistryUtils.getMasterFailoverLockPath(masterAddress), but missed updating the corresponding releaseLock call in the finally block.
Suggested fix
Extract the lock path into a local variable to ensure getLock and releaseLock use the same path:
final String masterFailoverLockPath = RegistryUtils.getMasterFailoverLockPath(masterAddress);
registryClient.getLock(masterFailoverLockPath);
try {
// ... failover logic
} finally {
registryClient.releaseLock(masterFailoverLockPath);
}
How to reproduce
Triggered when a Master node undergoes failover.
Version
3.4.1-release / dev
Are you willing to submit PR?
Code of Conduct
Search before asking
What happened
In
FailoverCoordinator.doMasterFailover(), the lock path used bygetLockandreleaseLockis inconsistent:What you expected to happen
getLockandreleaseLockshould use the same lock path to ensure the lock is properly acquired and released.Root cause
This issue was introduced by PR #16953 (commit
b6b04617). That PR changedgetLockfrom the global lock pathRegistryNodeType.MASTER_FAILOVER_LOCK.getRegistryPath()to a per-master-address fine-grained lock pathRegistryUtils.getMasterFailoverLockPath(masterAddress), but missed updating the correspondingreleaseLockcall in thefinallyblock.Suggested fix
Extract the lock path into a local variable to ensure
getLockandreleaseLockuse the same path:How to reproduce
Triggered when a Master node undergoes failover.
Version
3.4.1-release / dev
Are you willing to submit PR?
Code of Conduct