Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultRedisCacheWriter is not atomic [DATAREDIS-1117] #1686

Closed
spring-projects-issues opened this issue Mar 20, 2020 · 0 comments
Closed

DefaultRedisCacheWriter is not atomic [DATAREDIS-1117] #1686

spring-projects-issues opened this issue Mar 20, 2020 · 0 comments
Assignees
Labels
in: cache RedisCache and CacheManager type: bug A general bug

Comments

@spring-projects-issues
Copy link

joongsoo opened DATAREDIS-1117 and commented

If using RedisCacheWriter.lockingCacheWriter(), it is not atomic.

 

In DefaultRedisCacheWriter

  1. execute method wait for unlock. and execute target callable.
  2. try acquire lock in target callable.

 

When the lock is released, many waiting threads possible access to callable.

But doLock method is not guarantee to acquire lock. because it does not check acquired lock.

So multiple threads can run the task at the same time.

 

So the doLock method must be improved to acquired a lock


Affects: 2.2.5 (Moore SR5)

Reference URL: https://github.com/spring-projects/spring-data-redis/blob/master/src/main/java/org/springframework/data/redis/cache/DefaultRedisCacheWriter.java

Referenced from: pull request #518

@spring-projects-issues spring-projects-issues added in: cache RedisCache and CacheManager type: bug A general bug labels Dec 30, 2020
chanyoung1998 added a commit to chanyoung1998/spring-data-redis that referenced this issue Mar 22, 2024
chanyoung1998 added a commit to chanyoung1998/spring-data-redis that referenced this issue Mar 23, 2024
@mp911de mp911de assigned mp911de and unassigned christophstrobl Apr 19, 2024
mp911de added a commit that referenced this issue Apr 19, 2024
Refine unlocking by checking whether the lock was actually applied.

Reduce allocations, refine test assertions to check for concurrency.

See #1686
Original pull request: #2879
mp911de pushed a commit that referenced this issue Apr 19, 2024
mp911de added a commit that referenced this issue Apr 19, 2024
Refine unlocking by checking whether the lock was actually applied.

Reduce allocations, refine test assertions to check for concurrency.

See #1686
Original pull request: #2879
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: cache RedisCache and CacheManager type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants