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

tidb-configuration-file: add more notes to txn-entry-size-limit #10629

Merged
merged 6 commits into from Oct 26, 2022

Conversation

dveeden
Copy link
Contributor

@dveeden dveeden commented Oct 7, 2022

What is changed, added or deleted? (Required)

Growing the txn-entry-size-limit to the maximum size needs adjustments in other settings as well.

When txn-entry-size-limit is too small:

sql> INSERT INTO t1(t) VALUES(REPEAT('x',6*1024*1024));
ERROR: 8025 (HY000): entry too large, the max entry size is 6291456, the size of data is 6291489

When raft-entry-max-size is too small:

sql> INSERT INTO t1(t) VALUES(REPEAT('x',15*1024*1024));
ERROR: 1105 (HY000): message:"raft entry is too large, region 2, entry size 15728790" raft_entry_too_large:<region_id:2 entry_size:15728790 > 

When max_allowed_packet is too small:

sql> INSERT INTO t1(t) VALUES(REPEAT('x',100*1024*1024));
ERROR: 1301 (HY000): Result of repeat() was larger than max_allowed_packet (67108864) - truncated

When txn-total-size-limit is too small:

sql> INSERT INTO t1(t) VALUES(REPEAT('x',100*1024*1024));
ERROR: 8004 (HY000): Transaction is too large, size: 104857633

Tested with:

tiup playground --tiflash 0 --without-monitor --db.config /tmp/tidb.toml --kv.config /tmp/tikv.toml v6.3.0

tikv.toml:

[raftstore]
raft-entry-max-size = "150MB"

tidb.toml:

[performance]
txn-entry-size-limit = 125829120
txn-total-size-limit = 1073741824

And SET GLOBAL max_allowed_packet=130*1024*1024 (and then reconnect)

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions.

  • master (the latest development version)
  • v6.4 (TiDB 6.4 versions)
  • v6.3 (TiDB 6.3 versions)
  • v6.1 (TiDB 6.1 versions)
  • v5.4 (TiDB 5.4 versions)
  • v5.3 (TiDB 5.3 versions)
  • v5.2 (TiDB 5.2 versions)
  • v5.1 (TiDB 5.1 versions)
  • v5.0 (TiDB 5.0 versions)

What is the related PR or file link(s)?

  • This PR is translated from:
  • Other reference link(s):

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Oct 7, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • TomShawn
  • qiancai

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added missing-translation-status This PR does not have translation status info. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 7, 2022
@ti-chi-bot ti-chi-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 7, 2022
@dveeden
Copy link
Contributor Author

dveeden commented Oct 7, 2022

Note that the actual limit might be slightly less. Instead of 6MiB (default config) exactly it is 33 bytes less for the defaults. I don't think this is a problem.

sql> CREATE TABLE t1(id bigint primary key auto_random, t longtext);
Query OK, 0 rows affected, 1 warning (0.1575 sec)
Note (code 1105): Available implicit allocation times: 288230376151711743

sql> INSERT INTO t1(t) VALUES(REPEAT('x',5*1024*1024));
Query OK, 1 row affected (0.0811 sec)

sql> INSERT INTO t1(t) VALUES(REPEAT('x',6*1024*1024));
ERROR: 8025 (HY000): entry too large, the max entry size is 6291456, the size of data is 6291489

sql> SELECT 6291489-6291456;
+-----------------+
| 6291489-6291456 |
+-----------------+
|              33 |
+-----------------+
1 row in set (0.0003 sec)

sql> INSERT INTO t1(t) VALUES(REPEAT('x',(6*1024*1024)-33));
Query OK, 1 row affected (0.0803 sec)

sql> SELECT LENGTH(t), FORMAT_BYTES(LENGTH(t)) FROM t1;
+-----------+-------------------------+
| LENGTH(t) | FORMAT_BYTES(LENGTH(t)) |
+-----------+-------------------------+
|   6291423 | 6.00 MiB                |
|   5242880 | 5.00 MiB                |
+-----------+-------------------------+
2 rows in set (0.0921 sec)

@shichun-0415 shichun-0415 added type/enhancement This issue/PR improves documentation usability or supplements document content. translation/doing This PR's assignee is translating this PR. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-6.3 and removed missing-translation-status This PR does not have translation status info. labels Oct 8, 2022
Comment on lines 365 to 366
- The default `max_allowed_packet` is 67108864 (64 MiB), which may lead to truncation with rows that are bigger.
- The default `txn-total-size-limit` is 100 MiB, which you need to increase if you increase `txn-entry-size-limit` to be over 100 MiB.
Copy link
Contributor

Choose a reason for hiding this comment

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

What does "rows that are bigger" mean? Does it mean rows bigger than txn-entry-size-limit?

Suggested change
- The default `max_allowed_packet` is 67108864 (64 MiB), which may lead to truncation with rows that are bigger.
- The default `txn-total-size-limit` is 100 MiB, which you need to increase if you increase `txn-entry-size-limit` to be over 100 MiB.
- Because the default value of [`max_allowed_packet`](/system-variables.md#max_allowed_packet) (the maximum size of a packet for the MySQL protocol) is 67108864 (64 MiB), which might lead to truncation with rows that are bigger.
- The default value of [`txn-total-size-limit`](#txn-total-size-limit) (the size limit of a single transaction in TiDB) is 100 MiB. If you increase the `txn-entry-size-limit` value to be over 100 MiB, you need to increase the `txn-total-size-limit` value accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If a column is larger than max_allowed_packet it gets truncated. With a strict SQL mode it will probably give an error instead of truncating the value, but I didn't test that.

Copy link
Contributor

@TomShawn TomShawn left a comment

Choose a reason for hiding this comment

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

rest LGTM

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Oct 8, 2022
@dveeden
Copy link
Contributor Author

dveeden commented Oct 10, 2022

@TomShawn PTAL

1 similar comment
@dveeden
Copy link
Contributor Author

dveeden commented Oct 18, 2022

@TomShawn PTAL

@@ -362,6 +362,8 @@ Configuration items related to performance.
- Default value: `6291456` (in bytes)
Copy link
Collaborator

Choose a reason for hiding this comment

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

In L361, do we need to mention this configuration item also controls the size limit of a single column?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that's needed as this should be implicit as columns can't be bigger than the row.

@dveeden
Copy link
Contributor Author

dveeden commented Oct 25, 2022

The ci / tidb-check found this:

 tidb-configuration-file.md
  365:24-365:87  warning  Dead anchor: /system-variables.md#max_allowed_packet  pingcap-docs-anchors  remark-lint

However the link seems fine to me.

@TomShawn
Copy link
Contributor

/rebase

@TomShawn TomShawn force-pushed the tidb-config-txn-entry-size-limit branch from 00d7707 to c4d9a45 Compare October 25, 2022 14:42
@TomShawn
Copy link
Contributor

TomShawn commented Oct 25, 2022

The ci / tidb-check found this:

 tidb-configuration-file.md
  365:24-365:87  warning  Dead anchor: /system-variables.md#max_allowed_packet  pingcap-docs-anchors  remark-lint

However the link seems fine to me.

Anchor fixed. If @qiancai has no further comment, let's merge this PR.

Copy link
Collaborator

@qiancai qiancai left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Oct 26, 2022
@qiancai
Copy link
Collaborator

qiancai commented Oct 26, 2022

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 64542ef

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Oct 26, 2022
@ti-chi-bot ti-chi-bot merged commit 406eb18 into pingcap:master Oct 26, 2022
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #11014.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #11015.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. translation/done This PR has been translated from English into Chinese and updated to pingcap/docs-cn in a PR. type/enhancement This issue/PR improves documentation usability or supplements document content.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants