lealone / Lealone

比 MySQL 和 MongoDB 快10倍的 OLTP 关系数据库和文档数据库
Other
2.44k stars 514 forks source link

尔发现BUG #188

Closed cbqqkcel closed 9 months ago

cbqqkcel commented 1 year ago
Caused by: org.springframework.jdbc.UncategorizedSQLException: 
### Error querying database.  Cause: org.lealone.common.exceptions.JdbcSQLException: General error: "java.lang.NullPointerException: Cannot invoke ""org.lealone.db.result.Result.getVisibleColumnCount()"" because ""result"" is null" [50000-2]
### The error may exist in cn/com/idmy/zhdc/pa/admin/dao/RoomDao.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT `code`, `tenantId`, `name`, `roomStructure`, `businessType`, `buildingArea`, `realBuildingArea`, `projectId`, `projectName`, `rengouDate`, `qianyueDate`, `jiezhuanDate`, `customerName`, `contractNo`, `contractPrice`, `finalSettlePrice`, `noTaxContactPrice`, `noTaxFinalSettlePrice`, `payTypeName`, `shouqiPrice`, `anjiePrice`, `providentFundBank`, `providentFundLoan`, `anjieBank`, `areaSpread`, `realAreaSpread`, `realNoLoan`, `realLoan`, `discount`, `standardPrice`, `additionalTerms`, `seller`, `isIgnore`, `isBeian`, `beianDate`, `isZhesuan`, `zhesuanBili`, `zhesuanRemark`, `isYujie`, `yujieBili`, `yujieRemark`, `isHuanfang`, `isHuikuan`, `createAt`, `updateAt`, `isDelete` FROM `Room` ORDER BY `Room`.`isBeian` ASC LIMIT 0, 10
### Cause: org.lealone.common.exceptions.JdbcSQLException: General error: "java.lang.NullPointerException: Cannot invoke ""org.lealone.db.result.Result.getVisibleColumnCount()"" because ""result"" is null" [50000-2]
; uncategorized SQLException; SQL state [HY000]; error code [50000]; General error: "java.lang.NullPointerException: Cannot invoke ""org.lealone.db.result.Result.getVisibleColumnCount()"" because ""result"" is null" [50000-2]
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:93) ~[mybatis-spring-3.0.2.jar:3.0.2]
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:439) ~[mybatis-spring-3.0.2.jar:3.0.2]

一个页面的查询,有时候会出现这个错误。不好重现的问题。

cbqqkcel commented 1 year ago

image

看了详情错误是超时导致的,但是异常信息没用体现出来

cbqqkcel commented 1 year ago

image

我配置的是session_timeout不超时,是不是配错了

用法是嵌入式的。 image

codefollower commented 1 year ago

在 jdbc url 中加参数 NETWORK_TIMEOUT

cbqqkcel commented 1 year ago

为啥异常信息显示的是null指针,而不是 timeout异常呢。

codefollower commented 1 year ago

调用 executeQuery,如果响应时间超时了会抛出 org.lealone.common.exceptions.JdbcSQLException: Network timeout: "ack timeout, request start time: 2023-06-24 14:15:25.364, network timeout: 1000ms, request packet: StatementQuery[SELECT pk, f1, f2, f3 from SelectTest]" [90147-0] at org.lealone.common.exceptions.DbException.getJdbcSQLException(DbException.java:342) at org.lealone.common.exceptions.DbException.get(DbException.java:173) at org.lealone.common.exceptions.DbException.get(DbException.java:150) at org.lealone.db.async.AsyncCallback.handleTimeout(AsyncCallback.java:221) at org.lealone.db.async.AsyncCallback.checkTimeout(AsyncCallback.java:214) at org.lealone.net.TcpClientConnection.checkTimeout(TcpClientConnection.java:132) at org.lealone.net.AsyncConnectionPool.checkTimeout(AsyncConnectionPool.java:64) at org.lealone.net.NetClientBase.checkTimeout(NetClientBase.java:129) at org.lealone.net.nio.NioEventLoopClient.run(NioEventLoopClient.java:60) at org.lealone.net.nio.NioEventLoopClient.lambda$0(NioEventLoopClient.java:44) at java.lang.Thread.run(Thread.java:748)

如果调用的是 executeQueryAsync,要像这样使用:

 ((JdbcStatement) stmt).executeQueryAsync(sql).onSuccess(result -> {
        }).onFailure(t -> {
            t.printStackTrace();
        });

你的场景需要打断点跟踪一下完整的异常链,我看不出是哪里的代码出异常了。 最大的可能就是框架没有捕获超时异常,然后调用 getMetaData()。

codefollower commented 1 year ago

调用 org.lealone.db.result.Result.getVisibleColumnCount() 的地方有很多,不一定是超时的原因, 你可以在 org.lealone.client.jdbc.JdbcResultSet.JdbcResultSet(JdbcConnection, JdbcStatement, Result, int, boolean, boolean, boolean) 里打个断点,或者在 org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible 那里打断点,看看完整的异常链是什么。

cbqqkcel commented 1 year ago

目前应该就是超时的问题,之前使用默认设置,在压力测试下。经常出现这个错误。后来调大时间后再也没有出现过了