Comments (6)
Please share the code to reproduce the issue.
from redisson.
Make sure that the lock wasn't unlocked by the time when the second thread acquired it.
from redisson.
Make sure that the lock wasn't unlocked by the time when the second thread acquired it.
Thanks reply,
- the log shows that the two threads acquired the lock in a very short period of time. I don't think it is the case of releasing and acquiring the lock again.
- I didn't assigned a leaseTime and unlocked in finally body.
private void generate() {
RLock lock = redisson.getLock(key);
try {
String threadName = Thread.currentThread().getName();
boolean locked = lock.tryLock();
if (locked && shouldGenerateTask() {
log.info("locked by key:{} with thread:{}", key, threadName);
saveTask();
}
} catch (Exception e) {
Thread.currentThread().interrupt();
} finally {
if (lock.isHeldByCurrentThread()) {
lock.unlock();
}
}
}
2024-01-12T12:00:07.514288425Z 2024-01-12 12:00:07.514 INFO 7 --- [ XNIO-1 task-4] .s.p.a.t.c.h.i.test : locked by key:App:Procurement:PENDING_PRICING:1400_65_2 with thread:XNIO-1 task-4
2024-01-12T12:00:07.542088285Z 2024-01-12 12:00:07.541 INFO 7 --- [ XNIO-1 task-2] .s.p.a.t.c.h.i.test : locked by key:App:Procurement:PENDING_PRICING:1400_65_2 with thread:XNIO-1 task-2
from redisson.
This is occurring in a concurrent scenario where the real situation involves listening to a database change data capture (CDC). Then, two threads simultaneously acquire the lock and save two separate task data.
from redisson.
Can you add log.info("unlocked1 by key:{} with thread:{}", key, threadName);
after if (lock.isHeldByCurrentThread()) {
add log.info("unlocked2 by key:{} with thread:{}", key, threadName);
after lock.unlock();
from redisson.
thanks for your help
from redisson.
Related Issues (20)
- Failed to parse yaml configuration throws NoSuchMethodError com.fasterxml.jackson.annotation.JsonTypeInfo.requireTypeIdForSubtypes() HOT 1
- Method Redisson#create keeps running Netty thread even if it fails to create a client instance HOT 2
- Question - I have a question about the way you implemented locks HOT 2
- Will already authenticated connections continue to work after refreshing credentials via credentialsResolver dynamically? HOT 1
- RMapCache Cache expiration not working correctly on a cluster of Redisson clients HOT 4
- WriteRedisConnectionException: Unable to write command into connection! HOT 3
- RedissonClient.shutdown() always take 15 seconds to end HOT 2
- Can Redisson be used for Tomcat session cache? Getting java.lang.ClassNotFoundException on broadcasting session updates HOT 10
- Spring data: ERR wrong number of arguments for 'pexpire' command HOT 1
- Redisson throws NPE after upgrading to version 3.25.0 and higher HOT 1
- When using RMapCache to save data, \x00 appears HOT 4
- RedisConnectionException: SlaveConnectionPool no available Redis entries HOT 2
- There was no method to add MapEntryListener in RedissonSpringCacheManager and why?
- Add TrackingListener support to RList, RQueue, RDeque, RBlockingQueue, RBlockingDeque, RDelayedQueue, RRingBuffer objects HOT 1
- 订阅消失 HOT 1
- Add random() methods to RLexSortedSet object HOT 1
- ClassCastException when using FlushListener along with LocalCachedMap HOT 1
- Exception in redission netty thread throw java.lang.OutOfMemoryError: Java heap space HOT 1
- Messages getting lost from redis delayed queue with redisson client HOT 1
- Redis Scaling Issue with Redisson Client HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redisson.