Skip to content

Fix RLock trylock and unlock race condition - #7070

Merged
mrniko merged 4 commits into
redisson:masterfrom
nhancdt2602:fix/trylock-unlock-race
Apr 30, 2026
Merged

mrniko merged 4 commits into
redisson:masterfrom
nhancdt2602:fix/trylock-unlock-race

Conversation

@nhancdt2602

Copy link
Copy Markdown
Contributor

Fix #6844

Use `name2entry.compute` to ensure thread-safety

ref redisson#6844

Signed-off-by: nhancdt2602 <[email protected]>
Signed-off-by: nhancdt2602 <[email protected]>
@mrniko

mrniko commented Apr 29, 2026

Copy link
Copy Markdown
Member

Good catch!

RLock instrumentedLock = new RedissonLock(client.getCommandExecutor(), "1testConcurrencyTryLockUnLock") {
@Override
public RFuture<Void> unlockAsync(long threadId) {
if (renewalScheduler.isLockSetEmpty()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

use Reflect.on(renewalScheduler) instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did switch to use Reflect and removed isLockSetEmpty helper method

@mrniko mrniko added this to the 4.3.2 milestone Apr 29, 2026
@mrniko mrniko added the bug label Apr 29, 2026
@nhancdt2602
nhancdt2602 requested a review from mrniko April 29, 2026 18:42
@nhancdt2602
nhancdt2602 force-pushed the fix/trylock-unlock-race branch from e1ddb36 to 1ca0a90 Compare April 29, 2026 19:37
@mrniko
mrniko merged commit f375cdb into redisson:master Apr 30, 2026
4 checks passed
@mrniko

mrniko commented Apr 30, 2026

Copy link
Copy Markdown
Member

Thanks for contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

Attempt to unlock lock, not locked by current thread by node id in redisson 3.52

2 participants