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 2 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 basic-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ 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 |
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 v4.0 的版本支持的最大单个事务容量为 100 MiB。
- 在 v6.5.0 及之后的版本中,不再推荐使用配置项 `performance.txn-total-size-limit`,事务的内存大小会被累计计入所在会话的内存使用量中,并由 [`tidb_mem_quota_query`](/system-variables.md#tidb_mem_quota_query) 变量在单个会话内存超阈值时采取控制行为。
hfxsd marked this conversation as resolved.
Show resolved Hide resolved

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

Expand Down
2 changes: 1 addition & 1 deletion releases/release-4.0.0-rc.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TiDB 版本:4.0.0-rc.2

+ TiDB

- 去掉了特别为开启 Binlog 时定义的事务容量上限 (100 MB),现在事务的容量上限统一为 10 GB,但若开启 Binlog 且下游是 Kafka,由于 Kafka 消息大小的限制是 1 GB,请根据情况调整 `txn-total-size-limit` 配置参数 [#16941](https://github.com/pingcap/tidb/pull/16941)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 4.0 的 release note 需要改成 1 TiB 吗?应该也是 10 GiB 吧

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- 去掉了特别为开启 Binlog 时定义的事务容量上限 (100 MB),现在事务的容量上限统一为 1 TiB,但若开启 Binlog 且下游是 Kafka,由于 Kafka 消息大小的限制是 1 GiB,请根据情况调整 `txn-total-size-limit` 配置参数 [#16941](https://github.com/pingcap/tidb/pull/16941)
hfxsd marked this conversation as resolved.
Show resolved Hide resolved
- 查询 `CLUSTER_LOG` 表时,如果未指定时间范围,由默认时间范围变更为返回错误且用户必须指定时间范围 [#17003](https://github.com/pingcap/tidb/pull/17003)
- `CREATE TABLE` 创建分区表时指定未支持的 sub-partition 或 linear hash 选项,将会创建非分区普通表,而不是选项未生效的分区表 [#17197](https://github.com/pingcap/tidb/pull/17197)

Expand Down