Skip to content
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

使用mybatisplus 先删除在批量插入没有执行成功 #7029

Open
1 task done
BeiQiaoT opened this issue Nov 27, 2024 · 3 comments
Open
1 task done

使用mybatisplus 先删除在批量插入没有执行成功 #7029

BeiQiaoT opened this issue Nov 27, 2024 · 3 comments

Comments

@BeiQiaoT
Copy link

BeiQiaoT commented Nov 27, 2024

  • I have searched the issues of this repository and believe that this is not a duplicate.

Ⅰ. Issue Description

在全局事务中先删除一条数据,然后插入一条数据,两条数据的id保持一致,此时如果使用mybatisplus单条插入则没有问题,使用mybatisplus批量插入没有执行成功。

Ⅱ. Describe what happened

debug发现有如下异常,批量插入时只有第一次注册失败日志,并且插入操作没有执行成功

### Error flushing statements.  Cause: java.sql.SQLException: io.seata.core.exception.RmTransactionException: branch register exception, xid:192.168.1.12:8091:27612063588174772
### Cause: java.sql.SQLException: io.seata.core.exception.RmTransactionException: branch register exception, xid:192.168.1.12:8091:27612063588174772
; uncategorized SQLException; SQL state [null]; error code [0]; io.seata.core.exception.RmTransactionException: branch register exception, xid:192.168.1.12:8091:27612063588174772

Ⅲ. Describe what you expected to happen

可以正常插入

Ⅳ. How to reproduce it (as minimally and precisely as possible)

这个链接有详细的说明:https://developer.aliyun.com/ask/659744

Minimal yet complete reproducer code (or URL to code):

参考这个:https://developer.aliyun.com/ask/659744

Ⅴ. Anything else we need to know?

Ⅵ. Environment:

  • JDK version(e.g. java -version): graalvm-ce-17
  • Seata client/server version: 1.8
  • Database version: mysql 8
  • OS(e.g. uname -a): Darwin Kernel Version 24.1.0
  • Others:
@funky-eyes
Copy link
Contributor

不支持savebatch,因为获取自增主键存在问题。
Savebatch is not supported because there is a problem getting the auto-increment primary key.

@BeiQiaoT
Copy link
Author

不支持savebatch,因为获取自增主键存在问题。 Savebatch is not supported because there is a problem getting the auto-increment primary key.

有什么好的解决办法吗?还是说目前只能循环使用单条插入呢?

@funky-eyes
Copy link
Contributor

不支持savebatch,因为获取自增主键存在问题。 Savebatch is not supported because there is a problem getting the auto-increment primary key.

有什么好的解决办法吗?还是说目前只能循环使用单条插入呢?

这种sql应该是可以的
This sql should work.

INSERT xxxx INTO table_name (column1, column2, column3)
VALUES
    (value1a, value2a, value3a),
    (value1b, value2b, value3b),
    (value1c, value2c, value3c);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants