大家好,我是烤鸭:
问题记录,上线之后懵逼的问题。只能回滚?每次都是上线来暴击,不然多查查文章也不至于这么被动。
报错日志
org.springframework.data.redis.serializer.SerializationException: Cannot deserialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is java.io.InvalidClassException: com.xxxx.xxxxc.core.pojo.vo.Resource; local class incompatible: stream classdesc serialVersionUID = 3936163953604439376, local class serialVersionUID = 4124973216730560840at org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.deserialize(JdkSerializationRedisSerializer.java:84)at org.springframework.data.redis.serializer.SerializationUtils.deserializeValues(SerializationUtils.java:54)at org.springframework.data.redis.serializer.SerializationUtils.deserialize(SerializationUtils.java:68)at org.springframework.data.redis.core.AbstractOperations.deserializeValues(AbstractOperations.java:269)at org.springframework.data.redis.core.DefaultValueOperations.multiGet(DefaultValueOperations.java:182)at com.xxxx.xxxxc.core.service.impl.XxxxcServiceImpl.getCXXXX(XxxxcServiceImpl.java:171)at com.xxxx.xxxxc.core.service.impl.XxxxcServiceImpl.getCXXXX1(XxxxcServiceImpl.java:428)at com.xxxx.xxxxc.core.service.impl.XxxxcServiceImpl$$FastClassBySpringCGLIB$$bef756bd.invoke(<generated>)at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:687)at com.xxxx.xxxxc.core.service.impl.XxxxcServiceImpl$$EnhancerBySpringCGLIB$$e5853a01.getCXXXX1(<generated>)at sun.reflect.GeneratedMethodAccessor698.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282)at org.springframework.cloud.context.scope.GenericScope$LockedScopedProxyFactoryBean.invoke(GenericScope.java:499)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)at com.xxxx.xxxxc.core.service.impl.XxxxcServiceImpl$$EnhancerBySpringCGLIB$$a8e9635a.getCXXXX1(<generated>)at com.xxxx.xxxxc.controller.CXXXXBaseController.CXXXXFlow$original$tm1stvRt(CXXXXBaseController.java:472)at com.xxxx.xxxxc.controller.CXXXXBaseController.CXXXXFlow$original$tm1stvRt$accessor$l6PMstid(CXXXXBaseController.java)at com.xxxx.xxxxc.controller.CXXXXBaseController$auxiliary$qLsnIVj2.call(Unknown Source)at com.xxxx.xxxxc.controller.CXXXXBaseController.CXXXXFlow(CXXXXBaseController.java)at com.xxxx.xxxxc.controller.CXXXXBaseController$$FastClassBySpringCGLIB$$c8ec8734.invoke(<generated>)at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:687)at com.xxxx.xxxxc.controller.CXXXXBaseController$$EnhancerBySpringCGLIB$$ab6f4dc6.CXXXXFlow(<generated>)at sun.reflect.GeneratedMethodAccessor259.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282)at org.springframework.cloud.context.scope.GenericScope$LockedScopedProxyFactoryBean.invoke(GenericScope.java:499)at
过程回溯
大半夜上线之后,报错日志 哐哐哐 来了,第一时间很慌,怎么办,先回滚吧。回滚之后没问题了,可是线还得上,找找啥原因吧。
某个实体反序列化出问题了,第一时间万能的csdn上一顿搜。
这也太简单了,赶紧改完了上线,灰度一台,又报错了,懵了,坑人啊。
中间还折腾了一段反序列化忽略字段的弯路,血泪教训。
后来干脆不解决了,知道是缓存的问题,还好过期时间短,等过期完了就好了。
原因是啥
redistemplate 采用hash存储的时候,序列化id也存进去了,导致实体有字段修改之后,序列化id就对不上了,因为不是一个实体了。
解决方案
- 删redis
- 去掉多加的字段,还原实体
- 换key
需求发版,把实体改回去不太现实了,缓存数量太多,临时清也来不及。
如果不是对redis强依赖的场景,改key吧,起码不会报错了。
相关文章
https://www.zhangshilong.cn/work/409210.html
https://www.jianshu.com/p/acbc7e83e038