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

feature: support Dameng database #3672

Merged
merged 34 commits into from
Sep 22, 2023
Merged

feature: support Dameng database #3672

merged 34 commits into from
Sep 22, 2023

Conversation

iquanzhan
Copy link

@iquanzhan iquanzhan commented Apr 24, 2021

Ⅰ. Describe what this PR did

support DM DataBase

Ⅱ. Does this pull request fix one issue?

fixes #4014

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

download DM,and add table
sql:

CREATE TABLE "UNDO_LOG"
(
    "ID" BIGINT IDENTITY(1, 1) NOT NULL,
    "BRANCH_ID" BIGINT NOT NULL,
    "XID" VARCHAR(100) NOT NULL,
    "CONTEXT" VARCHAR(128) NOT NULL,
    "ROLLBACK_INFO" BLOB NOT NULL,
    "LOG_STATUS" INT NOT NULL,
    "LOG_CREATED" TIMESTAMP(0) NOT NULL,
    "LOG_MODIFIED" TIMESTAMP(0) NOT NULL,
    "EXT" VARCHAR(100),
    NOT CLUSTER PRIMARY KEY("ID"),
    CONSTRAINT "UX_UNDO_LOG" UNIQUE("XID", "BRANCH_ID")
) STORAGE(ON "MAIN", CLUSTERBTR) ;

CREATE UNIQUE  INDEX "PRIMARY" ON "SEATA_ORDER"."UNDO_LOG"("ID" ASC) STORAGE(ON "MAIN", CLUSTERBTR) ;

Ⅴ. Special notes for reviews

add support DM DataBase

Copy link
Contributor

@l81893521 l81893521 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI failed. Please check the error detail in https://github.com/seata/seata/pull/3672/checks

import java.util.List;

/**
* The type oracle delete recognizer.
Copy link
Contributor

@l81893521 l81893521 Apr 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type dm delete recognizer.

Copy link
Contributor

@l81893521 l81893521 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create the sql script in /script/client/at/db/dm.sql

@funky-eyes funky-eyes added this to the 1.5.0 milestone Apr 26, 2021
@funky-eyes funky-eyes added type: feature Category issues or prs related to feature request. module/rm-datasource rm-datasource module labels Apr 26, 2021
@iquanzhan
Copy link
Author

代码已重新提交并优化。
使用达梦数据库的分布式事务示例:https://gitee.com/iquanzhan/seata-parent

@funky-eyes
Copy link
Contributor

代码已重新提交并优化。
使用达梦数据库的分布式事务示例:https://gitee.com/iquanzhan/seata-parent

方便给我私发一下你的钉钉号吗?我邮箱364176773@qq.com

@xingfudeshi xingfudeshi changed the title update:添加对达梦数据库的支持 feature:support Dameng database May 14, 2021
@codecov-commenter
Copy link

codecov-commenter commented May 22, 2021

Codecov Report

Merging #3672 (c76f162) into develop (26d8cdb) will increase coverage by 0.86%.
The diff coverage is 68.43%.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #3672      +/-   ##
=============================================
+ Coverage      48.02%   48.89%   +0.86%     
- Complexity      4119     4157      +38     
=============================================
  Files            761      777      +16     
  Lines          26853    27944    +1091     
  Branches        3350     3412      +62     
=============================================
+ Hits           12897    13662     +765     
- Misses         12540    12858     +318     
- Partials        1416     1424       +8     
Files Changed Coverage Δ
...n/src/main/java/io/seata/common/util/PageUtil.java 50.00% <ø> (ø)
...ql/distributed/lock/DistributedLockSqlFactory.java 0.00% <ø> (ø)
...ta/core/store/db/sql/lock/LockStoreSqlFactory.java 75.00% <ø> (ø)
...n/java/io/seata/rm/datasource/DataSourceProxy.java 63.15% <0.00%> (-15.11%) ⬇️
...asource/sql/struct/cache/OracleTableMetaCache.java 67.30% <ø> (+0.96%) ⬆️
...ta/rm/datasource/undo/dm/DmUndoDeleteExecutor.java 0.00% <0.00%> (ø)
...ta/rm/datasource/undo/dm/DmUndoExecutorHolder.java 0.00% <0.00%> (ø)
...ta/rm/datasource/undo/dm/DmUndoInsertExecutor.java 0.00% <0.00%> (ø)
...ta/rm/datasource/undo/dm/DmUndoUpdateExecutor.java 0.00% <0.00%> (ø)
.../io/seata/sqlparser/druid/dm/BaseDmRecognizer.java 0.00% <0.00%> (ø)
... and 12 more

... and 19 files with indirect coverage changes

Copy link
Contributor

@Musknine Musknine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
there is a bug. only the unique index and all the unique index's columes same as primary key columes,it belongs to primary key it's something like this PR #4005

script/client/at/db/dm.sql Outdated Show resolved Hide resolved
import io.seata.rm.datasource.sql.struct.TableMeta;
import io.seata.sqlparser.util.JdbcConstants;

import java.sql.Connection;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

@funky-eyes funky-eyes modified the milestones: 1.5.0, 2.0.0 Jan 22, 2022
@Musknine
Copy link
Contributor

@iquanzhan 请问下,支持DM这个pr, 你们有用在生产跑了吗?

@wangliang181230 wangliang181230 changed the title feature:support Dameng database feature: support Dameng database Apr 25, 2022
@funky-eyes funky-eyes modified the milestones: 2.0.0, 1.7.1 Aug 18, 2023
@teng-jy
Copy link

teng-jy commented Aug 23, 2023

10:27:11.956  INFO --- [     RetryRollbacking_1_1] [server.coordinator.DefaultCore] [    doGlobalRollback]  [192.168.2.50:8091:7800661551294558767] : Rollback global transaction successfully, xid = 192.168.2.50:8091:7800661551294558767.
10:29:09.177  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : receive msg[single]: GlobalBeginRequest{transactionName='save(com.beichuanghui.bch.base.vo.save.user.BaseEmployeeSaveVO)', timeout=60000}, clientIp: 192.168.2.168, vgroup: default_tx_group
10:29:09.179  INFO --- [verHandlerThread_1_49_500] [coordinator.DefaultCoordinator] [       doGlobalBegin]  [192.168.2.50:8091:7800661551294558907] : Begin new global transaction applicationId: beichuanghui-base-server,transactionServiceGroup: default_tx_group, transactionName: save(com.beichuanghui.bch.base.vo.save.user.BaseEmployeeSaveVO),timeout:60000,xid:192.168.2.50:8091:7800661551294558907
10:29:09.183  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : result msg[single]: GlobalBeginResponse{xid='192.168.2.50:8091:7800661551294558907', extraData='null', resultCode=Success, msg='null'}, clientIp: 192.168.2.168, vgroup: default_tx_group
10:29:09.289  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : receive msg[merged]: BranchRegisterRequest{xid='192.168.2.50:8091:7800661551294558907', branchType=AT, resourceId='jdbc:dm://192.168.2.30:5236/beichuanghui_ds_c_defaults', lockKey='def_user:397953020899360832;def_user_tenant_rel:397953020899360833', applicationData='{"autoCommit":false,"skipCheckLock":true}'}, clientIp: 192.168.2.168, vgroup: default_tx_group
10:29:09.293  INFO --- [nPool.commonPool-worker-3] [erver.coordinator.AbstractCore] [bda$branchRegister$0]  [192.168.2.50:8091:7800661551294558907] : Register branch successfully, xid = 192.168.2.50:8091:7800661551294558907, branchId = 7800661551294558909, resourceId = jdbc:dm://192.168.2.30:5236/beichuanghui_ds_c_defaults ,lockKeys = def_user:397953020899360832;def_user_tenant_rel:397953020899360833
10:29:09.296  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : result msg[merged]: BranchRegisterResponse{branchId=7800661551294558909, resultCode=Success, msg='null'}, clientIp: 192.168.2.168, vgroup: default_tx_group
10:29:09.370  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : receive msg[merged]: BranchRegisterRequest{xid='192.168.2.50:8091:7800661551294558907', branchType=AT, resourceId='jdbc:dm://192.168.2.30:5236/beichuanghui_ds_c_defaults', lockKey='def_user:397953020899360832;undo_log:30;def_user_tenant_rel:397953020899360833', applicationData='{"autoCommit":false,"skipCheckLock":true}'}, clientIp: 192.168.2.168, vgroup: default_tx_group
10:29:09.373 ERROR --- [nPool.commonPool-worker-3] [ption.AbstractExceptionHandler] [eptionHandleTemplate]  [192.168.2.50:8091:7800661551294558907] : Catch TransactionException while do RPC, request: BranchRegisterRequest{xid='192.168.2.50:8091:7800661551294558907', branchType=AT, resourceId='jdbc:dm://192.168.2.30:5236/beichuanghui_ds_c_defaults', lockKey='def_user:397953020899360832;undo_log:30;def_user_tenant_rel:397953020899360833', applicationData='{"autoCommit":false,"skipCheckLock":true}'}
==>
io.seata.core.exception.TransactionException: branch register request failed. xid=192.168.2.50:8091:7800661551294558907, msg=违反表[LOCK_TABLE]唯性约束
	at io.seata.server.AbstractTCInboundHandler$4.execute(AbstractTCInboundHandler.java:187) ~[classes!/:1.7.1-SNAPSHOT]
	at io.seata.server.AbstractTCInboundHandler$4.execute(AbstractTCInboundHandler.java:179) ~[classes!/:1.7.1-SNAPSHOT]
	at io.seata.core.exception.AbstractExceptionHandler.exceptionHandleTemplate(AbstractExceptionHandler.java:131) ~[seata-core-1.7.1-SNAPSHOT.jar:1.7.1-SNAPSHOT]
	at io.seata.server.AbstractTCInboundHandler.handle(AbstractTCInboundHandler.java:179) ~[classes!/:1.7.1-SNAPSHOT]
	at io.seata.core.protocol.transaction.BranchRegisterRequest.handle(BranchRegisterRequest.java:136) ~[seata-core-1.7.1-SNAPSHOT.jar:1.7.1-SNAPSHOT]
	at io.seata.server.coordinator.DefaultCoordinator.onRequest(DefaultCoordinator.java:523) ~[classes!/:1.7.1-SNAPSHOT]
	at io.seata.core.rpc.processor.server.ServerOnRequestProcessor.handleRequestsByMergedWarpMessage(ServerOnRequestProcessor.java:288) ~[seata-core-1.7.1-SNAPSHOT.jar:1.7.1-SNAPSHOT]
	at io.seata.core.rpc.processor.server.ServerOnRequestProcessor.lambda$onRequestMessage$1(ServerOnRequestProcessor.java:178) ~[seata-core-1.7.1-SNAPSHOT.jar:1.7.1-SNAPSHOT]
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700) ~[na:na]
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692) ~[na:na]
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) ~[na:na]
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) ~[na:na]
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) ~[na:na]
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) ~[na:na]
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) ~[na:na]
Caused by: io.seata.common.exception.StoreException: 违反表[LOCK_TABLE]唯性约束
	at io.seata.server.storage.db.lock.LockStoreDataBaseDAO.acquireLock(LockStoreDataBaseDAO.java:199) ~[classes!/:1.7.1-SNAPSHOT]
	at io.seata.server.storage.db.lock.DataBaseLocker.acquireLock(DataBaseLocker.java:64) ~[classes!/:1.7.1-SNAPSHOT]
	at io.seata.server.lock.AbstractLockManager.acquireLock(AbstractLockManager.java:65) ~[classes!/:1.7.1-SNAPSHOT]
	at io.seata.server.session.BranchSession.lock(BranchSession.java:287) ~[classes!/:1.7.1-SNAPSHOT]
	at io.seata.server.transaction.at.ATCore.branchSessionLock(ATCore.java:77) ~[classes!/:1.7.1-SNAPSHOT]
	at io.seata.server.coordinator.AbstractCore.lambda$branchRegister$0(AbstractCore.java:83) ~[classes!/:1.7.1-SNAPSHOT]
	at io.seata.server.storage.db.session.DataBaseSessionManager.lockAndExecute(DataBaseSessionManager.java:191) ~[classes!/:1.7.1-SNAPSHOT]
	at io.seata.server.session.SessionHolder.lockAndExecute(SessionHolder.java:367) ~[classes!/:1.7.1-SNAPSHOT]
	at io.seata.server.coordinator.AbstractCore.branchRegister(AbstractCore.java:77) ~[classes!/:1.7.1-SNAPSHOT]
	at io.seata.server.coordinator.DefaultCore.branchRegister(DefaultCore.java:103) ~[classes!/:1.7.1-SNAPSHOT]
	at io.seata.server.coordinator.DefaultCoordinator.doBranchRegister(DefaultCoordinator.java:294) ~[classes!/:1.7.1-SNAPSHOT]
	at io.seata.server.AbstractTCInboundHandler$4.execute(AbstractTCInboundHandler.java:184) ~[classes!/:1.7.1-SNAPSHOT]
	... 14 common frames omitted
Caused by: java.sql.BatchUpdateException: 违反表[LOCK_TABLE]唯性约束
	at dm.jdbc.driver.DBError.throwBatchUpdateException(DBError.java:728) ~[DmJdbcDriver18-8.1.2.192.jar:- 8.1.2.192 - Production]
	at dm.jdbc.a.a.a(DBAccess.java:910) ~[DmJdbcDriver18-8.1.2.192.jar:- 8.1.2.192 - Production]
	at dm.jdbc.driver.DmdbPreparedStatement.do_executeLargeBatch(DmdbPreparedStatement.java:654) ~[DmJdbcDriver18-8.1.2.192.jar:- 8.1.2.192 - Production]
	at dm.jdbc.driver.DmdbPreparedStatement.do_executeBatch(DmdbPreparedStatement.java:601) ~[DmJdbcDriver18-8.1.2.192.jar:- 8.1.2.192 - Production]
	at dm.jdbc.driver.DmdbPreparedStatement.executeBatch(DmdbPreparedStatement.java:1623) ~[DmJdbcDriver18-8.1.2.192.jar:- 8.1.2.192 - Production]
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeBatch(DruidPooledPreparedStatement.java:565) ~[druid-1.2.6.jar:1.2.6]
	at io.seata.server.storage.db.lock.LockStoreDataBaseDAO.doAcquireLocks(LockStoreDataBaseDAO.java:371) ~[classes!/:1.7.1-SNAPSHOT]
	at io.seata.server.storage.db.lock.LockStoreDataBaseDAO.acquireLock(LockStoreDataBaseDAO.java:187) ~[classes!/:1.7.1-SNAPSHOT]
	... 25 common frames omitted
<==

10:29:09.376  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : result msg[merged]: BranchRegisterResponse{branchId=0, resultCode=Failed, msg='TransactionException[branch register request failed. xid=192.168.2.50:8091:7800661551294558907, msg=违反表[LOCK_TABLE]唯一性约束]'}, clientIp: 192.168.2.168, vgroup: default_tx_group
10:29:09.382  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : receive msg[merged]: BranchReportRequest{xid='192.168.2.50:8091:7800661551294558907', branchId=7800661551294558909, resourceId='null', status=PhaseOne_Failed, applicationData='null', branchType=AT}, clientIp: 192.168.2.168, vgroup: default_tx_group
10:29:09.385  INFO --- [nPool.commonPool-worker-3] [erver.coordinator.AbstractCore] [        branchReport]  [192.168.2.50:8091:7800661551294558907] : Report branch status successfully, xid = 192.168.2.50:8091:7800661551294558907, branchId = 7800661551294558909
10:29:09.387  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : result msg[merged]: BranchReportResponse{resultCode=Success, msg='null'}, clientIp: 192.168.2.168, vgroup: default_tx_group
10:29:09.391  INFO --- [nPool.commonPool-worker-3] [erver.coordinator.AbstractCore] [        branchReport]  [192.168.2.50:8091:7800661551294558907] : Report branch status successfully, xid = 192.168.2.50:8091:7800661551294558907, branchId = 7800661551294558909
10:29:09.393  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : receive msg[merged]: BranchReportRequest{xid='192.168.2.50:8091:7800661551294558907', branchId=7800661551294558909, resourceId='null', status=PhaseOne_Failed, applicationData='null', branchType=AT}, clientIp: 192.168.2.168, vgroup: default_tx_group
10:29:09.393  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : result msg[merged]: BranchReportResponse{resultCode=Success, msg='null'}, clientIp: 192.168.2.168, vgroup: default_tx_group
10:29:09.398  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : receive msg[single]: GlobalRollbackRequest{xid='192.168.2.50:8091:7800661551294558907', extraData='null'}, clientIp: 192.168.2.168, vgroup: default_tx_group
10:29:09.402  INFO --- [rverHandlerThread_1_4_500] [server.coordinator.DefaultCore] [    doGlobalRollback]  [192.168.2.50:8091:7800661551294558907] : Rollback global transaction successfully, xid = 192.168.2.50:8091:7800661551294558907.
10:29:09.403  INFO --- [     batchLoggerPrint_1_1] [ocessor.server.BatchLogHandler] [                 run]  [] : result msg[single]: GlobalRollbackResponse{globalStatus=Rollbacked, resultCode=Success, msg='null'}, clientIp: 192.168.2.168, vgroup: default_tx_group

出现了违反表结构的错误

@funky-eyes
Copy link
Contributor

这个是dameng的driver有bug吧,这个时候应该抛出的是SQLIntegrityConstraintViolationException,而不是BatchUpdateException

@funky-eyes
Copy link
Contributor

@teng-jy 你能联系到dameng的技术人员吗,反馈下这个问题

Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@slievrly slievrly modified the milestones: 1.7.1, 1.8.0 Aug 30, 2023
Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@slievrly slievrly merged commit ecb7ef7 into apache:develop Sep 22, 2023
8 checks passed
@jinyulei0710
Copy link

any plan merge to 1.6.1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first-time contributor first-time contributor module/rm-datasource rm-datasource module module/sqlparser sql-parser module type: feature Category issues or prs related to feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

seata框架 是否支持达梦(DM8)数据库