mysql5.7.32切到 tidb5.0.1后,有很多这样报错Could not create JDBC savepoint

为提高效率,请提供以下信息,问题描述清晰能够更快得到解决:
【 TiDB 使用环境】
centos7

【概述】 场景 + 问题概述

【应用框架及开发适配业务逻辑】

【背景】 做过哪些操作

【现象】 业务和数据库现象

【问题】 当前遇到的问题
在mysql没问题,切到tidb5,运行报这个错,找了半天没找到解决办法,

org.springframework.transaction.CannotCreateTransactionException: Could not create JDBC savepoint; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 9 near "SAVEPOINT SAVEPOINT_1"

You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 9 near "SAVEPOINT SAVEPOINT_1"
【业务影响】

【TiDB 版本】
v5.0.1
【附件】 相关日志及监控(https://metricstool.pingcap.com/)


若提问为性能优化、故障排查类问题,请下载脚本运行。终端输出的打印结果,请务必全选并复制粘贴上传。

3 个赞

语法错误,建议找到对应的 SQL(程序或 tidb- server 日志里,应该有记录)

1 个赞

用mysql5.7正常,换TIDB5.0.1后,执行方法报错

1 个赞

格式化失败,在navicat连TIDB执行正常

    select gg.SCGG_TYWYSBM as id, SC_TYWYSBM as materialId, SCPP_TYWYSBM as brandId, SCPP_MC as brandName,
    JLDLDW as unit, d1.ZDMC as normName, GG_SZ as normNum, GG_DW as normUnit, d2.ZDMC as normUnitName,
    BZZL_SZ as standWeight, gg.JG_TYWYSBM as orgId
    from hs_sc_gg gg
    left join sys_dict d1 on d1.ZDM = 'canMaterialUnit' and gg.JLDLDW = d1.ZDZ
    left join sys_dict d2 on d2.ZDM = 'normUnit' and gg.GG_DW = d2.ZDZ
    where gg.SCBS = '0' and gg.SC_TYWYSBM = #{materialId}
    and (((gg.JG_TYWYSBM is null or gg.JG_TYWYSBM = '') and JLDLDW in ('1','99')) or gg.JG_TYWYSBM = #{orgId})
    order by gg.JG_TYWYSBM, gg.SCPP_TYWYSBM
1 个赞

:ok_hand:

org.springframework.transaction.CannotCreateTransactionException: Could not create JDBC savepoint; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 9 near "SAVEPOINT SAVEPOINT_1"

语法在库里执行是没问题的,怎么能知道转换失败是什么原因呢?从mysql5.7切过来后由很多这样的报错

表结构
hs_sc_gg.sql (4.0 KB)

这个报错和上面说的 SQL 语句没关系吧(建议你打开 general log ,看看报错的这个连接是那个程序链接过来的,看看 SQL语句: SAVEPOINT SAVEPOINT_1 是怎么生成的

你程序用的什么框架?以前版本不报错吗(tidb 不支持 savepoint 的)(建议你确认一下程序是否有变动/新上线之类)

是这个页面吗,程序是springboot2+mybatis-plus,以前用的mysql5.7没问题,刚迁移过来发现的问题

1 个赞

额,你是刚从 mysql 迁移到 tidb 啊,tidb 不支持 savepoint 语法的,https://docs.pingcap.com/zh/tidb/dev/mysql-compatibility#不支持的功能特性

已解决,是service里@Transactional(propagation = Propagation.NESTED, isolation = Isolation.DEFAULT, rollbackFor = Exception.class)标签的问题

2 个赞

:joy:学习一下,你上面的是什么的配置》?

service里面事务的配置

:ok_hand:我查一下

嵌套事务问题

您好,我们目前对 savepoint 有了明确的支持计划,不出意外的话会在 TiDB v6.2 正式支持:https://github.com/pingcap/tidb/issues/6840,如果需要的话还请关注下。

1 个赞

学习了。。。

此话题已在最后回复的 1 分钟后被自动关闭。不再允许新回复。