-
Notifications
You must be signed in to change notification settings - Fork 692
docs: clarify AUTO_RANDOM_BASE usage and explicit insert behavior #20734
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
base: master
Are you sure you want to change the base?
Conversation
Warning You have reached your daily quota limit. As a reminder, free tier users are limited to 5 requests per day. Please wait up to 24 hours and I will start processing your requests again! |
2a8de50
to
be6b29d
Compare
To confirm the behavior described in the documentation updates, I ran the following tests on a local TiDB instance: 1. Create Table: CREATE TABLE t (a BIGINT PRIMARY KEY AUTO_RANDOM, b VARCHAR(255));
2. Attempt ALTER TABLE t AUTO_RANDOM_BASE=0;
SHOW WARNINGS;
(Confirms the command completes with a warning but doesn't reset to 0.) 3. Attempt ALTER TABLE t FORCE AUTO_RANDOM_BASE=0;
(Confirms forcing the base to 0 results in an error.) 4. Attempt ALTER TABLE t FORCE AUTO_RANDOM_BASE = 1000;
(Confirms forcing the base to a non-zero value succeeds.) 5. Insert data after forcing base to 1000: INSERT INTO t (b) VALUES ('test1'), ('test2');
SELECT * FROM t WHERE b LIKE 'test%';
(Confirms the auto-increment part starts from the forced base value.) These results align with the behavior described in the updated documentation. |
auto-random.md
Outdated
|
||
> **Note:** | ||
> | ||
> * If you try to alter `AUTO_RANDOM_BASE` without the `FORCE` keyword, the value will not change. The command completes, but the base value stays unchanged. A subsequent `SHOW WARNINGS` reveals the specific warning `Can't reset AUTO_INCREMENT to 0 without FORCE option, using 1 instead`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you try to alter
AUTO_RANDOM_BASE
without theFORCE
keyword,
the value WILL not change even if the warning is reported. We should suggest ignoring the warning instead of using FORCE
(see my comment above)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tangenta I appreciate this critical correction. I've updated the documentation to clearly state that when using AUTO_RANDOM_BASE=0
without the FORCE
keyword, "the value will change and you can safely ignore this warning." This is an important distinction that users need to know.
The warning message itself (Can't reset AUTO_INCREMENT to 0 without FORCE option, using XXX instead
) is a bit misleading since it mentions AUTO_INCREMENT
instead of AUTO_RANDOM
and suggests the change isn't happening when it actually is. Would updating this warning message be something to consider for a future release?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion just in case you are considering updating the warning message: "AUTO_RANDOM_BASE has been updated to XXX. You specified '0' which triggered automatic rebasing to prevent ID collisions."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM
Mention conflicts happen in deployments with multiple TiDB nodes.
Adjustments based on the review by @tangenta
fixing link that had an extra slash "/"
1f7443b
to
89585ab
Compare
First-time contributors' checklist
What is changed, added or deleted? (Required)
Close issue: #20732
This PR updates the "Clear the auto-increment ID cache" section in
auto-random.md
to address confusion reported in the issue above. Specifically, the changes:ALTER TABLE ... AUTO_RANDOM_BASE
without theFORCE
keyword does not actually change the value, despite the warning message.FORCE
keyword is mandatory to modifyAUTO_RANDOM_BASE
.AUTO_RANDOM_BASE
to0
, even withFORCE
, will result in an error.FORCE
.AUTO_RANDOM
IDs, potentially leading to duplicate key errors.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.
What is the related PR or file link(s)?
auto-random.md
Do your changes match any of the following descriptions?