Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

Redisson distributed lock: Is it normal that a thread can get the lock before lease time had past?

$
0
0

enter image description here

https://github.com/cuipengfei/Spikes/blob/22a9896137dd62bda5f030f5a3d33c67fba67310/jpa/spring-jdbc-distributed-lock-issue/src/test/java/com/github/spring/example/LockTest.java#L38C9-L49

the above junit test can reproduce this.

docker run -p 6379:6379 -d redis:7.0.12 --requirepass "mypass"# start this docker container before running the above junit test

If I run these 2 threads in 2 jvms, then the lease thread 2 can only get lock after lease time is past.But if I run them in the same jvm, then thread 2 can get lock before lease time is past.

Is this by design?


Viewing all articles
Browse latest Browse all 2204

Trending Articles