doc: 阅读seata AT文档

This commit is contained in:
asahi
2025-08-27 10:25:59 +08:00
parent 8edc81b4c2
commit 97990229c9

View File

@@ -2,6 +2,8 @@
- [Seata Global Exclusive Write Lock](#seata-global-exclusive-write-lock)
- [TC - Global Exclusive Write Lock Implementation](#tc---global-exclusive-write-lock-implementation)
- [RM - Global Exclusive Write Lock Usage](#rm---global-exclusive-write-lock-usage)
- [Read Committed \&\& Read UnCommitted](#read-committed--read-uncommitted)
- [`select ... for update` to apply global exclusive write lock](#select--for-update-to-apply-global-exclusive-write-lock)
# seata
@@ -56,4 +58,13 @@ global write lock的释放和RM无关当全局事务提交时全局事务
但是在全局事务提交前其他事务必须等待global exclusive write lock的释放这种等待会带来性能损耗。
## Read Committed && Read UnCommitted
在seata系统中`local transaction/branch transaction`的事务隔离级别和数据库实例的默认隔离级别一致例如在mysql中默认为`repeatable read`但是seata系统中对于`global transaction`,其事务隔离级别为`read uncommitted`作为全局事务G1中的分支事务L1其在L1提交但是G1尚未提交的场景下L1对数据库造成的修改对全局事务G2仍然可见。
故而seata中全局事务的隔离级别为`读未提交`
### `select ... for update` to apply global exclusive write lock
在seata系统中如果特定场景下`需要将全局事务的隔离级别改为读已提交`,可以使用`select ... for update`来实现。
在seata-AT的实现中对于`select ... for update`语句,其会在`ConnectionProxy`执行时校验是否可获取`global write lock`。如果当时global write lock被其他全局事务持有那么当前`select ... for update`会进行重试。当重试次数达到上限时,会抛出异常,如此,可以保证全局事务的读已提交,当全局事务尚未提交/回滚时会持有global write lock其他全局事务无法获取相同数据的global write lock。