-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Potential race condition in listener adding code #2755
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
Comments
Yes! Good find. Any compound action (i.e. the Given 1) the Javadoc on the |
Given addListener(:MessageListener, :Collection<Topic>) could be called concurrently from the addMessageListener(:MessageListener, Collection<Topic>) method by multiple Threads, and the RedisMessageListenerContainer Javadoc specifically states that it is safe to call the addMessageListener(..) method conurrently without any external synchronization, and the registeration (or mapping) of listener to Topics is a componund action, then a race condition is possible. Closes spring-projects#2755
Given addListener(:MessageListener, :Collection<Topic>) could be called concurrently from the addMessageListener(:MessageListener, Collection<Topic>) method by multiple Threads, and the RedisMessageListenerContainer Javadoc specifically states that it is safe to call the addMessageListener(..) method conurrently without any external synchronization, and the registeration (or mapping) of listener to Topics is a componund action, then a race condition is possible. Closes spring-projects#2755
Given addListener(:MessageListener, :Collection<Topic>) could be called concurrently from the addMessageListener(:MessageListener, Collection<Topic>) method by multiple Threads, and the RedisMessageListenerContainer Javadoc specifically states that it is safe to call the addMessageListener(..) method conurrently without any external synchronization, and the registeration (or mapping) of listener to Topics is a componund action, then a race condition is possible. Closes spring-projects#2755
I may also be affected by a race condition in RedisMessageListenerContainer. It doesn't happen while debugging the shutdown hook, but it happens every single time I don't. The thread dump makes me believe the error is caused by a race condition during re-registration during shutdown due to messages being sent. Edit: removing message listener during shutdown workaround the problem. |
I'm pretty sure that there is potential race condition in the following code:
The solution could be to replace it with something like this:
spring-data-redis/src/main/java/org/springframework/data/redis/listener/RedisMessageListenerContainer.java
Line 649 in fc9f9d8
The text was updated successfully, but these errors were encountered: