From 6c1c85759c2560aafacd5080ce606965cba2acfc Mon Sep 17 00:00:00 2001 From: RainGan Date: Sun, 9 Oct 2022 18:28:26 +0800 Subject: [PATCH] optimize: optimize tcc fence record not exists errMessage (#4981) --- changes/en-us/develop.md | 1 + changes/zh-cn/develop.md | 1 + .../java/io/seata/common/exception/FrameworkErrorCode.java | 4 ++-- tcc/src/main/java/io/seata/rm/tcc/TCCFenceHandler.java | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/changes/en-us/develop.md b/changes/en-us/develop.md index f7edf3329d5..e4894e828e2 100644 --- a/changes/en-us/develop.md +++ b/changes/en-us/develop.md @@ -46,6 +46,7 @@ Add changes here for all PR submitted to the develop branch. - [[#4946](https://github.com/seata/seata/pull/4946)] pass the sqlexception to client when get lock - [[#4962](https://github.com/seata/seata/pull/4962)] optimize build and fix the base image - [[#4974](https://github.com/seata/seata/pull/4974)] optimize cancel the limit on the number of globalStatus queries in Redis mode +- [[#4981](https://github.com/seata/seata/pull/4981)] optimize tcc fence record not exists errMessage ### test: - [[#4794](https://github.com/seata/seata/pull/4794)] try to fix the test `DataSourceProxyTest.getResourceIdTest()` diff --git a/changes/zh-cn/develop.md b/changes/zh-cn/develop.md index 01a064a00de..8efe05aeed0 100644 --- a/changes/zh-cn/develop.md +++ b/changes/zh-cn/develop.md @@ -46,6 +46,7 @@ - [[#4946](https://github.com/seata/seata/pull/4946)] 将获取锁时遇到的sql异常传递给客户端 - [[#4962](https://github.com/seata/seata/pull/4962)] 优化构建配置,并修正docker镜像的基础镜像 - [[#4974](https://github.com/seata/seata/pull/4974)] 取消redis模式下,查询globalStatus条数的限制 +- [[#4981](https://github.com/seata/seata/pull/4981)] 优化当tcc栅栏记录查不到时的错误提示 ### test: - [[#4794](https://github.com/seata/seata/pull/4794)] 重构代码,尝试修复单元测试 `DataSourceProxyTest.getResourceIdTest()` diff --git a/common/src/main/java/io/seata/common/exception/FrameworkErrorCode.java b/common/src/main/java/io/seata/common/exception/FrameworkErrorCode.java index c8358ec015f..938268552c6 100644 --- a/common/src/main/java/io/seata/common/exception/FrameworkErrorCode.java +++ b/common/src/main/java/io/seata/common/exception/FrameworkErrorCode.java @@ -219,9 +219,9 @@ public enum FrameworkErrorCode { DateSourceNeedInjected("0501","TCC fence datasource need injected","TCC fence datasource need injected"), /** - * TCC fence record already exists + * TCC fence record not exists */ - RecordAlreadyExists("0502","TCC fence record already exists","TCC fence record already exists"), + RecordNotExists("0502","TCC fence record not exists","TCC fence record not exists"), /** * Insert tcc fence record error diff --git a/tcc/src/main/java/io/seata/rm/tcc/TCCFenceHandler.java b/tcc/src/main/java/io/seata/rm/tcc/TCCFenceHandler.java index f0abd3d48cf..86222acd60f 100644 --- a/tcc/src/main/java/io/seata/rm/tcc/TCCFenceHandler.java +++ b/tcc/src/main/java/io/seata/rm/tcc/TCCFenceHandler.java @@ -148,7 +148,7 @@ public static boolean commitFence(Method commitMethod, Object targetTCCBean, TCCFenceDO tccFenceDO = TCC_FENCE_DAO.queryTCCFenceDO(conn, xid, branchId); if (tccFenceDO == null) { throw new TCCFenceException(String.format("TCC fence record not exists, commit fence method failed. xid= %s, branchId= %s", xid, branchId), - FrameworkErrorCode.RecordAlreadyExists); + FrameworkErrorCode.RecordNotExists); } if (TCCFenceConstant.STATUS_COMMITTED == tccFenceDO.getStatus()) { LOGGER.info("Branch transaction has already committed before. idempotency rejected. xid: {}, branchId: {}, status: {}", xid, branchId, tccFenceDO.getStatus());