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

txn: fix the maximum value of a transaction from 10GB to 1 TiB #18805

Merged
merged 9 commits into from
Oct 12, 2024
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
3 changes: 2 additions & 1 deletion basic-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,13 @@ aliases: ['/docs-cn/dev/basic-features/','/docs-cn/dev/experimental-features-4.0
|---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
| [Async commit](/system-variables.md#tidb_enable_async_commit-从-v50-版本开始引入) | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
| [1PC](/system-variables.md#tidb_enable_1pc-从-v50-版本开始引入) | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
| [大事务 (10 GB)](/transaction-overview.md#事务限制) | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
| [大事务 (1 TiB)](/transaction-overview.md#事务限制) | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
| [悲观事务](/pessimistic-transaction.md) | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
| [乐观事务](/optimistic-transaction.md) | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
| [可重复读隔离(快照隔离)](/transaction-isolation-levels.md) | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
| [读已提交隔离](/transaction-isolation-levels.md) | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
| [自动终止长时间未提交的空闲事务](/system-variables.md#tidb_idle_transaction_timeout-从-v760-版本开始引入) | Y | Y | Y | N | N | N | N | N | N | N | N |
| [批量 DML 语句的执行方式 (`tidb_dml_type = "bulk"`)](/system-variables.md#tidb_dml_type-从-v800-版本开始引入) | E | E | E | N | N | N | N | N | N | N | N |

## 分区

Expand Down
11 changes: 9 additions & 2 deletions develop/dev-guide-transaction-restraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,15 @@ mysql> SELECT * FROM T2;

基本原则是要限制事务的大小。TiDB 对单个事务的大小有限制,这层限制是在 KV 层面。反映在 SQL 层面的话,简单来说一行数据会映射为一个 KV entry,每多一个索引,也会增加一个 KV entry。所以这个限制反映在 SQL 层面是:

- 最大单行记录容量为 120MB(TiDB v4.0.10 及更高的 v4.0.x 版本、v5.0.0 及更高的版本可通过 tidb-server 配置项 [`performance.txn-entry-size-limit`](/tidb-configuration-file.md#txn-entry-size-limit-从-v4010-和-v500-版本开始引入) 调整,低于 TiDB v4.0.10 的版本支持的单行容量为 6MB)。
- 支持的最大单个事务容量为 10GB(TiDB v4.0 及更高版本可通过 tidb-server 配置项 `performance.txn-total-size-limit` 调整,低于 TiDB v4.0 的版本支持的最大单个事务容量为 100MB)。
- 最大单行记录容量为 120 MiB。

- TiDB v4.0.10 及更高的 v4.0.x 版本、v5.0.0 及更高的版本可通过 tidb-server 配置项 [`performance.txn-entry-size-limit`](/tidb-configuration-file.md#txn-entry-size-limit-从-v4010-和-v500-版本开始引入) 调整,低于 TiDB v4.0.10 的版本支持的单行容量为 6 MiB。
- 从 v7.6.0 开始,你可以使用 [`tidb_txn_entry_size_limit`](/system-variables.md#tidb_txn_entry_size_limit-从-v760-版本开始引入) 系统变量动态修改该配置项的值。

- 支持的最大单个事务容量为 1 TiB。

- TiDB v4.0 及更高版本可通过 tidb-server 配置项 [`performance.txn-total-size-limit`](/tidb-configuration-file.md#txn-total-size-limit) 调整,低于 TiDB v4.0 的版本支持的最大单个事务容量为 100 MiB。
- 在 v6.5.0 及之后的版本中,不再推荐使用配置项 [`performance.txn-total-size-limit`](/tidb-configuration-file.md#txn-total-size-limit)。更多详情请参考 [`performance.txn-total-size-limit`](/tidb-configuration-file.md#txn-total-size-limit)

另外注意,无论是大小限制还是行数限制,还要考虑事务执行过程中,TiDB 做编码以及事务额外 Key 的开销。在使用的时候,为了使性能达到最优,建议每 100 ~ 500 行写入一个事务。

Expand Down
1 change: 1 addition & 0 deletions tidb-configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ TiDB 配置文件比命令行参数支持更多的选项。你可以在 [config/
+ 在 v6.5.0 及之后的版本中,不再推荐使用该配置项,事务的内存大小会被累计计入所在会话的内存使用量中,并由 [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query) 变量在单个会话内存超阈值时采取控制行为。为了向前兼容,由低版本升级至 v6.5.0 及更高版本时,该配置项的行为如下所述:
+ 若该配置项未设置,或设置为默认值 (`104857600`),升级后事务内存大小将会计入所在会话的内存使用中,由 `tidb_mem_quota_query` 变量控制。
+ 若该配置项未设为默认值 (`104857600`),升级前后该配置项仍生效,对单个事务大小的限制行为不会发生变化,事务内存大小不由 `tidb_mem_quota_query` 控制。
+ 从 v8.0.0 开始,如果系统变量 [`tidb_dml_type`](/system-variables.md#tidb_dml_type-从-v800-版本开始引入)`"bulk"` 方式执行事务时,事务的大小不受 TiDB 配置项 `txn-total-size-limit` 的限制。

### `max-txn-ttl`

Expand Down