-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
When LettuceConnectionFactory shareNativeConnection is true, We may encounter serialization failure when querying the value of key1 and returning the value of key2 #3077
Comments
Thanks for the report. Without a reproducer, we can't find out what is happening here. It could be that some responses get out of order with Lettuce. Spring Data Redis uses |
We need a runnable reproducer, a collection of screenshots is unusable for us. |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
My Redis configuration is as shown in the screenshot above. As it is a very occasional operation (suspected to be in a high concurrency scenario), I have provided a demo example, but it may not be reproducible. Therefore, I have provided a screenshot. |
The above problem may occur after a period of time after the occurrence of OOM |
This is an interesting data point. I'm going to provide these details to the Lettuce maintainers at redis/lettuce#3117. |
I am using default LettuceConnectionFactory in my springboot webflux project. default field shareNativeConnection is true
in some case(maybe high concurrency), when I query key1 from redis, I unexpectedly got the value of key2 Causing serialization failure.
error msg:
[lettuce-epollEventLoop-5-2] [ERROR] c.h.r.c.redisCache - getCacheOrLoadInternal from redis error,key: key1, errMsg: Could not read JSON: Unrecognized token*****##***** expecting (JSON String, Number, Array, Object or token*****##true' or 'false')[N] at [Source: (byte[])"OK"; line: 1, column: 3]; nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token##***** expecting (JSON String, Number, Array, Object or token*****##*****true' or 'false')[N] at [Source: (byte[])"OK"; line: 1, column: 3]
Expected to obtain a policy model but got OK
[lettuce-epollEventLoop-5-2] [ERROR] c.h.r.c.RedisCache - getCacheOrLoadInternal from redis error, key:key2, errMsg:Could not read JSON: Cannot deserialize value of type
java.util.ArrayList<com.test.policy.Policy>
from Object value (token*****##Token##*****ECT)[N] at [Source: (byte[])"{"name":"123","age":16,"address":null,"reversedRelationTypes":null}"; line: 1, column: 1]; nested exception is com.fasterxml.jackson.data*****#*#*****ismatchedInputException: Cannot deserialize value of type
java.util.ArrayList<com.test.policy.Policy>from Object value (token*****#*#*****Token*****#*#*****ECT
)[N] at [Source: (byte[])"{"name":"123","age":16,"address":null,"reversedRelationTypes":null}";line: 1, column: 1]Expected to obtain a policy model but got another model (value of key 3)
this is getCacheOrLoadInternal method
private <T> Mono<T> getCacheOrLoadInternal(String key, RedisSerializationContext<String, T> context, Function<String, Mono<T>> loadingFunction, Duration expireTime) { return redisTemplate.opsForValue(context) .get(key) .timeout(Duration.ofMillis(1000)) .onErrorResume(e -> { log.error("getCacheOrLoadInternal from redis error, key:{}, errMsg:{}", key, e.getLocalizedMessage()); return Mono.empty(); }) .switchIfEmpty(getFromLoadingFunction(key, context, loadingFunction, expireTime)); }
when i set shareNativeConnection is false,There will be no such problem, But it will lead to a waste of resources。
the default value is true, Is this spring-data-redis bug lettuce bug?
The text was updated successfully, but these errors were encountered: