-
Notifications
You must be signed in to change notification settings - Fork 987
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
TransactionCommand applied incorrectly #1625
Comments
Are you using dedicated connections for each transaction or are you sharing a single connection across multiple concurrent Reactive Streams subscriptions? |
I'm using dedicated connections for each transaction. return this.redisConnectionManager.getConnectionForTransaction(userId)
.flatMap(pooledRedisConnection -> {
RedisReactiveCommands<String, String> reactiveCommands = pooledRedisConnection.reactive();
return reactiveCommands.watch(sessionInventoryRedisKey)
.flatMap(watchResult -> reactiveCommands.hgetall(sessionInventoryRedisKey))
// ... do something ... This problem doesn't happen often. It mainly occurs in high cpu utilization > 80% while executing transactions more than 2000 tps. |
Interestingly, the |
Do you mean, did I have tried the "Possible Solution" that i suggested by myself? If the question is that, the answer is "no". Sorry. I am very beginner, so I haven't tried modifying myself yet. @Override
public Collection<RedisCommand<K, V, ?>> dispatch(Collection<? extends RedisCommand<K, V, ?>> commands) {
List<RedisCommand<K, V, ?>> sentCommands = new ArrayList<>(commands.size());
commands.forEach(o -> {
RedisCommand<K, V, ?> command = preProcessCommand(o);
sentCommands.add(command);
if (command.getType().name().equals(MULTI.name())) {
multi = (multi == null ? new MultiOutput<>(codec) : multi);
}
});
return super.dispatch(sentCommands);
} If the suggested solution has a problem with an error scenario, how about setting the |
the issue with |
OK, I understood that using Today I tried to modify lettuce-core souce code, and applied it to my application manually. When I move the multi block to before calling |
Thanks for the update. Do you want to submit a pull request? |
I filed #1650 as follow up. |
Bug Report
Current Behavior
During load testing, I found that some commands throw
RedisCommandTimeoutException
. When I checked the DEBUG log in io.lettuce.core.protocol, I found that the transaction was applied to an incorrect command.Below is the log. The transactional commands of the
function1
are processed asSubscriptionCommand
. The first "WATCH" command of thefunction2
is processed asTransactionalCommand
. Even though the "WATCH" command received response from redis server, it throws the RedisCommandTimeoutException.This issue occurs when the caller thread of the "MULTI" command runs delayed the
StatefulRedisConnectionImpl.dispatch (RedisCommand <K, V, T> command)
's finally statement. You can see the "write() done" of the MULTI command logged after the "EXEC" command is done. (focus on the thread name of the log)Input Code
function1
function2
Expected behavior/code
The commands that come after the "MULTI" command must be processed by TransactionalCommand regardless of the thread order.
Environment
Possible Solution
How about set
multi
field before runsuper.dispatch(sentCommands);
inStatefulRedisConnectionImpl.dispatch (RedisCommand <K, V, T> command)
.The text was updated successfully, but these errors were encountered: