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

bugfix: the console has queried the released lock #5277

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion changes/en-us/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion changes/zh-cn/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 用法
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public PageResult<GlobalLockVO> query(GlobalLockParam param) {
* @return the RowLock list
*/
private Stream<RowLock> filterAndMap(GlobalLockParam param, BranchSession branchSession) {
if (CollectionUtils.isEmpty(branchSession.getLockHolder())) {
return Stream.empty();
}

final String tableName = param.getTableName();

Expand Down
23 changes: 23 additions & 0 deletions server/src/test/java/io/seata/server/lock/LockManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -318,6 +327,20 @@ public void lockQueryTest(GlobalSession globalSessions1, GlobalSession globalSes
final PageResult<GlobalLockVO> 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<GlobalLockVO> 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);
Expand Down