diff --git a/changes/en-us/2.0.0.md b/changes/en-us/2.0.0.md index 679ace5a901..93735043286 100644 --- a/changes/en-us/2.0.0.md +++ b/changes/en-us/2.0.0.md @@ -18,7 +18,7 @@ The version is updated as follows: - [[#5165](https://github.com/seata/seata/pull/5165)] optimize TCC structure, supporting API access. add integration layer module(seata-integration-tx-api) for transaction process definition and proxy enhancement. ### bugfix: - - [[#1234](https://github.com/seata/seata/pull/1234)] Please delete the sample later + - [[#5266](https://github.com/seata/seata/pull/5265)] fix server console has queried the released lock ### optimize: - [[#4858](https://github.com/seata/seata/pull/4858)] reorganize the usage of task session manager diff --git a/changes/zh-cn/2.0.0.md b/changes/zh-cn/2.0.0.md index 274c529b3ac..c9e28bb0c1a 100644 --- a/changes/zh-cn/2.0.0.md +++ b/changes/zh-cn/2.0.0.md @@ -18,7 +18,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单 - [[#5165](https://github.com/seata/seata/pull/5165)] TCC结构拆分,支持API方式接入。增加集成层模块(seata-integration-tx-api),对事务流程定义以及代理部分增强。 ### bugfix: - - [[#1234](https://github.com/seata/seata/pull/1234)] 样例,后续请删除 + - [[#5266](https://github.com/seata/seata/pull/5265)] 修复控制台全局锁查询接口查到了已释放的锁 ### optimize: - [[#4858](https://github.com/seata/seata/pull/4858)] 重构优化 SessionManager 用法 diff --git a/server/src/main/java/io/seata/server/console/impl/file/GlobalLockFileServiceImpl.java b/server/src/main/java/io/seata/server/console/impl/file/GlobalLockFileServiceImpl.java index edfdc633b30..60309581584 100644 --- a/server/src/main/java/io/seata/server/console/impl/file/GlobalLockFileServiceImpl.java +++ b/server/src/main/java/io/seata/server/console/impl/file/GlobalLockFileServiceImpl.java @@ -80,6 +80,9 @@ public PageResult query(GlobalLockParam param) { * @return the RowLock list */ private Stream filterAndMap(GlobalLockParam param, BranchSession branchSession) { + if (CollectionUtils.isEmpty(branchSession.getLockHolder())) { + return Stream.empty(); + } final String tableName = param.getTableName(); diff --git a/server/src/test/java/io/seata/server/lock/LockManagerTest.java b/server/src/test/java/io/seata/server/lock/LockManagerTest.java index fea75ba3fcc..9f10ad5512e 100644 --- a/server/src/test/java/io/seata/server/lock/LockManagerTest.java +++ b/server/src/test/java/io/seata/server/lock/LockManagerTest.java @@ -240,6 +240,15 @@ public void lockQueryTest(GlobalSession globalSessions1, GlobalSession globalSes () -> globalLockService.query(param) ); + LockManager lockManager = new FileLockManagerForTest(); + for (BranchSession branchSession : globalSessions1.getBranchSessions()) { + lockManager.acquireLock(branchSession); + } + + for (BranchSession branchSession : globalSessions2.getBranchSessions()) { + lockManager.acquireLock(branchSession); + } + param.setPageNum(1); param.setPageSize(10); @@ -318,6 +327,20 @@ public void lockQueryTest(GlobalSession globalSessions1, GlobalSession globalSes final PageResult timeTestResult4 = globalLockService.query(param); Assertions.assertEquals(4, timeTestResult4.getTotal()); + //test release lock + for (BranchSession branchSession : globalSessions1.getBranchSessions()) { + lockManager.releaseLock(branchSession); + } + + final GlobalLockParam param2 = new GlobalLockParam(); + param2.setPageNum(1); + param2.setPageSize(10); + + final PageResult fullQueryTestResult2 = globalLockService.query(param2); + Assertions.assertEquals(1,fullQueryTestResult2.getPages()); + Assertions.assertEquals(4,fullQueryTestResult2.getTotal()); + Assertions.assertEquals(4,fullQueryTestResult2.getData().size()); + } finally { sessionManager.removeGlobalSession(globalSessions1); sessionManager.removeGlobalSession(globalSessions2);