公司做项目时发现这样的问题:
Execute SQL : insert into blade_log_error (id, stack_trace, exception_name, message, file_name , line_number, tenant_id, service_id, server_ip, server_host , env, remote_ip, user_agent, request_uri, method , method_class, method_name, params, create_by, create_time) values (1903972613089673218, 'org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.lang.RuntimeException: Reading from a byte array threw an IOException (should never happen).
具体描述是:从字节数组读取数据时抛出了 IOException
(这种情况本不应该发生)。
查询数据库的日志信息:
- 最根本的异常是
io.protostuff.ProtostuffException: Corrupt input
,表示在反序列化时输入数据损坏。 - 这个异常被包装为
java.lang.RuntimeException: Reading from a byte array threw an IOException
,最终导致 MyBatis 查询失败。
上下文:
- 异常发生在从 Redis 缓存中读取数据时,具体是在
ProtoStuffSerializer
反序列化数据的过程中。 - 数据可能被错误地序列化或存储,导致反序列化时无法正确解析。
这里的redis数据库就是线上的,有可能是因为和线上数据产生了耦合
我直接改了redi存入的数据库,从13 改为11
然后就没问题了