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

update transaction doc (#6858) #7037

Merged
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 optimistic-transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ summary: 了解 TiDB 的乐观事务模型。

## 事务的重试

使用乐观事务模型时,在高冲突率的场景中,事务容易发生写写冲突而导致提交失败。MySQL 使用悲观事务模型,在执行 SQL 语句的过程中进行加锁并且其 Repeatable Read 隔离级别允许出现不可重复读,所以提交时一般不会出现异常。为了降低应用改造难度,TiDB 提供了数据库内部自动重试机制。
使用乐观事务模型时,在高冲突率的场景中,事务容易发生写写冲突而导致提交失败。MySQL 使用悲观事务模型,在执行写入类型的 SQL 语句的过程中进行加锁并且在 Repeatable Read 隔离级别下使用了当前读的机制,能够读取到最新的数据,所以提交时一般不会出现异常。为了降低应用改造难度,TiDB 提供了数据库内部自动重试机制。

### 重试机制

Expand Down
2 changes: 1 addition & 1 deletion transaction-isolation-levels.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ commit; |

### 与 MySQL 可重复读隔离级别的区别

MySQL 可重复读隔离级别在更新时并不检验当前版本是否可见,也就是说,即使该行在事务启动后被更新过,同样可以继续更新。这种情况在 TiDB 会导致事务回滚,导致事务最终失败,而 MySQL 是可以更新成功的。MySQL 的可重复读隔离级别并非 Snapshot 隔离级别,MySQL 可重复读隔离级别的一致性要弱于 Snapshot 隔离级别,也弱于 TiDB 的可重复读隔离级别
MySQL 可重复读隔离级别在更新时并不检验当前版本是否可见,也就是说,即使该行在事务启动后被更新过,同样可以继续更新。这种情况在 TiDB 使用乐观事务时会导致事务回滚,导致事务最终失败,而 TiDB 默认的悲观事务和 MySQL 是可以更新成功的

## 读已提交隔离级别 (Read Committed)

Expand Down