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

fix(RedisMessageStore): RedisMessageStore add lock #9680

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

NaccOll
Copy link
Contributor

@NaccOll NaccOll commented Nov 23, 2024

I found that when RedisMessageStore adds and removes messages, it operates on two keys separately, which may cause problems in multi-threading due to non-atomic operations.

Although using redis to delay messages is not a good idea, the abnormal loss of messages in the logs alerted me when the number of requests was not large. By comparing the logs, I found the problem that the message group representing the metadata is not consistent with the actual message.

I discovered this problem at least three years ago, but not many people use redis as a message storage, and there is little feedback from the community. I solved this problem by inheriting RedisMessageStore in my project.

My current solution is to add a lock like SimpleMessageStore, which is also the method used in this pull request. After several years of production environment verification, this is feasible. But this is bound to bring some performance loss, which is why I have not yet initiated a pull request to spring-integrate. But now I think it is troublesome to duplicate this class between multiple projects, and not all project members are aware of this problem, so I hope to solve this problem at the framework level.

like #463

I found that when RedisMessageStore adds and removes messages, it operates on two keys separately, which may cause problems in multi-threading due to non-atomic operations.

Although using redis to delay messages is not a good idea, the abnormal loss of messages in the logs alerted me when the number of requests was not large. By comparing the logs, I found the problem that the message group representing the metadata is not consistent with the actual message.

A simple solution is to add lock like SimpleMessageStore, which is also the approach taken in this pull request. This will bring some performance loss, and I am not sure whether a configable switch is needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant