Skip to content

bugfix: fixes SQL Server row locks are not released in Redis mode.#8072

Open
maple525866 wants to merge 3 commits intoapache:2.xfrom
maple525866:bugfix/260425
Open

bugfix: fixes SQL Server row locks are not released in Redis mode.#8072
maple525866 wants to merge 3 commits intoapache:2.xfrom
maple525866:bugfix/260425

Conversation

@maple525866
Copy link
Copy Markdown
Contributor

@maple525866 maple525866 commented Apr 25, 2026

Ⅰ. Describe what this PR did

Core Issue:

  • ROW_LOCK_KEY_SPLIT_CHAR = ";" is a global single-character delimiter used to concatenate multiple rowKey values ​​into a single string. However, the sub-element rowKey itself contains a resourceId, and in SQL Server scenarios, resourceId always contains a semicolon (;). This delimiter conflicts with the content being delimited, causing an irreversible "concatenation → splitting" process.

Scope of Impact:

  • Only affects Redis storage modes (RedisLocker, RedisLuaLocker, GlobalLockRedisServiceImpl).

  • DB storage mode (LockStoreDataBaseDAO) stores tables row-by-row LockDO, which does not involve semicolon concatenation and is unaffected.

  • File storage mode is similarly unaffected.

  • Any scenario other than SQL Server where a semicolon might appear in the resourceId will encounter this issue.

My Fix:
In the final step of constructing the rowKey, use replace(";", "^^^") to eliminate the character conflict once and for all.

Ⅱ. Does this pull request fix one issue?

fixes #8033

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

Ⅳ. Describe how to verify it

I have verified the correctness of the changes by adding the corresponding unit tests.

mvn clean test

Ⅴ. Special notes for reviews

@maple525866 maple525866 changed the title bugfix: bugfix: fixes an issue where SQL Server row locks are not released in Redis mode. Apr 25, 2026
@maple525866 maple525866 changed the title bugfix: fixes an issue where SQL Server row locks are not released in Redis mode. bugfix: fixes SQL Server row locks are not released in Redis mode. Apr 25, 2026
@maple525866 maple525866 added type: bug Category issues or prs related to bug. module/core core module store: redis labels Apr 25, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.12%. Comparing base (1145e54) to head (eca0509).

Additional details and impacted files
@@            Coverage Diff            @@
##                2.x    #8072   +/-   ##
=========================================
  Coverage     72.12%   72.12%           
  Complexity      872      872           
=========================================
  Files          1320     1320           
  Lines         50550    50553    +3     
  Branches       6026     6027    +1     
=========================================
+ Hits          36459    36463    +4     
+ Misses        11101    11097    -4     
- Partials       2990     2993    +3     
Files with missing lines Coverage Δ
...ava/org/apache/seata/core/lock/AbstractLocker.java 81.81% <100.00%> (+1.81%) ⬆️

... and 7 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
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.

I believe this has nothing to do with Redis. The ConnectionContext#buildLockKeys method coincidentally uses ; as the separator for Seata's global lock. Replacing ; with , only affects the conversion process in the convertToLockDO method and has no effect on the logic for assembling the global lock on the client side.

A more thorough solution would be to convert the global lock constructed on the client side into a base64-encoded format with hidden symbol delimiters. I have implemented a version locally, but the changes are quite extensive and require multi-version negotiation capabilities to achieve backward compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module/core core module store: redis type: bug Category issues or prs related to bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sqlServer的行锁不释放

2 participants