From 927f1ea194b8b254a895cb2e5ea9ba2f9b8ef6b2 Mon Sep 17 00:00:00 2001 From: jimin Date: Sun, 7 May 2023 17:44:11 +0800 Subject: [PATCH] bugfix: fix oracle insert undolog failed Signed-off-by: slievrly --- changes/en-us/develop.md | 1 + changes/zh-cn/develop.md | 1 + script/client/at/db/oracle.sql | 7 ++++++- script/client/at/db/postgresql.sql | 6 +++++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/changes/en-us/develop.md b/changes/en-us/develop.md index bd35c58c196..8930e4c88d8 100644 --- a/changes/en-us/develop.md +++ b/changes/en-us/develop.md @@ -36,6 +36,7 @@ Add changes here for all PR submitted to the develop branch. - [[#5552](https://github.com/seata/seata/pull/5552)] fix mariadb rollback failed - [[#5583](https://github.com/seata/seata/pull/5583)] fix grpc interceptor xid unbinding problem - [[#5602](https://github.com/seata/seata/pull/5602)] fix log in participant transaction role +- [[#5645](https://github.com/seata/seata/pull/5645)] fix oracle insert undolog failed ### optimize: - [[#5208](https://github.com/seata/seata/pull/5208)] optimize throwable getCause once more diff --git a/changes/zh-cn/develop.md b/changes/zh-cn/develop.md index ae7f5e8fee5..62a471193d2 100644 --- a/changes/zh-cn/develop.md +++ b/changes/zh-cn/develop.md @@ -36,6 +36,7 @@ - [[#5552](https://github.com/seata/seata/pull/5552)] 修复mariadb回滚失败的问题 - [[#5583](https://github.com/seata/seata/pull/5583)] 修复grpc xid 解绑问题 - [[#5602](https://github.com/seata/seata/pull/5602)] 修复participant情况下的重复日志 +- [[#5645](https://github.com/seata/seata/pull/5645)] 修复 oracle 插入 undolog 失败问题 ### optimize: - [[#5208](https://github.com/seata/seata/pull/5208)] 优化多次重复获取Throwable#getCause问题 diff --git a/script/client/at/db/oracle.sql b/script/client/at/db/oracle.sql index e1db1e95d44..364dc68b74a 100644 --- a/script/client/at/db/oracle.sql +++ b/script/client/at/db/oracle.sql @@ -1,6 +1,7 @@ -- for AT mode you must to init this sql for you business database. the seata server not need it. CREATE TABLE undo_log ( + id NUMBER(19) NOT NULL, branch_id NUMBER(19) NOT NULL, xid VARCHAR2(128) NOT NULL, context VARCHAR2(128) NOT NULL, @@ -8,6 +9,7 @@ CREATE TABLE undo_log log_status NUMBER(10) NOT NULL, log_created TIMESTAMP(0) NOT NULL, log_modified TIMESTAMP(0) NOT NULL, + PRIMARY KEY (id), CONSTRAINT ux_undo_log UNIQUE (xid, branch_id) ); CREATE INDEX ix_log_created ON undo_log(log_created); @@ -18,4 +20,7 @@ COMMENT ON COLUMN undo_log.context is 'undo_log context,such as serialization'; COMMENT ON COLUMN undo_log.rollback_info is 'rollback info'; COMMENT ON COLUMN undo_log.log_status is '0:normal status,1:defense status'; COMMENT ON COLUMN undo_log.log_created is 'create datetime'; -COMMENT ON COLUMN undo_log.log_modified is 'modify datetime'; \ No newline at end of file +COMMENT ON COLUMN undo_log.log_modified is 'modify datetime'; + +-- Generate ID using sequence and trigger +CREATE SEQUENCE UNDO_LOG_SEQ START WITH 1 INCREMENT BY 1; \ No newline at end of file diff --git a/script/client/at/db/postgresql.sql b/script/client/at/db/postgresql.sql index 6b9feddd406..bf562bcbdc3 100644 --- a/script/client/at/db/postgresql.sql +++ b/script/client/at/db/postgresql.sql @@ -1,6 +1,7 @@ -- for AT mode you must to init this sql for you business database. the seata server not need it. CREATE TABLE IF NOT EXISTS public.undo_log ( + id SERIAL NOT NULL, branch_id BIGINT NOT NULL, xid VARCHAR(128) NOT NULL, context VARCHAR(128) NOT NULL, @@ -8,6 +9,7 @@ CREATE TABLE IF NOT EXISTS public.undo_log log_status INT NOT NULL, log_created TIMESTAMP(0) NOT NULL, log_modified TIMESTAMP(0) NOT NULL, + CONSTRAINT pk_undo_log PRIMARY KEY (id), CONSTRAINT ux_undo_log UNIQUE (xid, branch_id) ); CREATE INDEX ix_log_created ON undo_log(log_created); @@ -19,4 +21,6 @@ COMMENT ON COLUMN public.undo_log.context IS 'undo_log context,such as serializa COMMENT ON COLUMN public.undo_log.rollback_info IS 'rollback info'; COMMENT ON COLUMN public.undo_log.log_status IS '0:normal status,1:defense status'; COMMENT ON COLUMN public.undo_log.log_created IS 'create datetime'; -COMMENT ON COLUMN public.undo_log.log_modified IS 'modify datetime'; \ No newline at end of file +COMMENT ON COLUMN public.undo_log.log_modified IS 'modify datetime'; + +CREATE SEQUENCE IF NOT EXISTS undo_log_id_seq INCREMENT BY 1 MINVALUE 1 ; \ No newline at end of file