-
Notifications
You must be signed in to change notification settings - Fork 1.2k
After timeout occurs on MULTI call every following transaction fails #2865
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
Can you reliably reproduce the timeout? If so, please attach debug/trace logs. I expect that this is rather a Lettuce driver issue. |
Hello @mp911de, here are the debug logs:
Let me know if it's what you asked for. |
After
It looks like to me as if the Eventloop thread was blocked. Can you (if you observe that there was no response for over 10-20 seconds) take a thread dump and attach it here? |
Sorry, I cannot attach the full dump. I attached my working thread and all lettuce threads |
the one attached is free from locks, however you might want to watch out for blocked threads that correlate with the thread used in the last log message saying that |
Why do you think that timeout was caused by thread lock? I rather consider timeout 'natural' due to the unavailability of redis |
If Redis was unavailable, there would be a disconnect most likely. |
Hello @mp911de ! |
Thanks a lot. The code intentionally pauses the client response to cause a failure. |
@mp911de thank you for your feedback. Do I understand right that it is not a bug? If so, we can add a note in docs https://docs.spring.io/spring-data/redis/docs/3.2.0-M2/reference/html/#tx mentioning that such error should be handled and 'DISCARD' should be called? I can add this note if you don't mind. Because I think it would be helpful for others, we have faced with this issue on production, redis was unavailable for some time causing transaction state of connections being invalid. What do you think if we handle this error like this?
|
Yeah, I do not consider this a bug per se. You're right that our documentation should outline handling error cases. |
I updated the code to catching |
I have a piece of code:
And timeout occurs on MULTI call:
After that, any following MULTI invocation fails with the following exception:
RedisCommandExecutionException: ERR MULTI calls can not be nested
I was able to reproduce it with a live redis instance using
redis-cli CLIENT PAUSE
to simulate a timeout in redis.Workaround:
I surrounded it with try/catch to call DISCARD manually:
Actually, I expected that it would not help if DISCARD failed because of the timeout, but even if the timeout happens DICARD rollbacks transaction somehow.
My env:
Java version: 17.0.9
spring-data-redis version: 2.7.15
redis version:3.2.12
The text was updated successfully, but these errors were encountered: