-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Fallback to txn mode when adding unique index #41630
Labels
Comments
Let me add more details. Test datadbgen template CREATE TABLE `test`.`multi_indexes` (
`f_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
/*{{ rownum }}*/
`f_user_id` bigint(20) unsigned NOT NULL,
/*{{ rand.range(1, 9223372036854775808) }}*/
`f_account_id` bigint(20) unsigned NOT NULL ,
/*{{ rand.range(1, 9223372036854775808) }}*/
`f_subaccount_id` bigint(20) unsigned NOT NULL ,
/*{{ rand.range(1, 9223372036854775808) }}*/
`f_transaction_id` bigint(20) unsigned NOT NULL ,
/*{{ rownum }}*/
`f_transaction_type` tinyint(3) unsigned NOT NULL ,
/*{{ rand.range(1, 10) }}*/
`f_currency` varchar(10) NOT NULL ,
/*{{ rand.regex('[a-z0-9]+', '', 5) }}*/
`f_balance` decimal(36,18) NOT NULL DEFAULT '0.000000000000000000' ,
/*{{ rand.range(1, 100000) }}*/
`f_amount` decimal(36,18) NOT NULL DEFAULT '0.000000000000000000' ,
/*{{ rand.range(1, 10000000) }}*/
`f_precision` tinyint(4) NOT NULL DEFAULT '0' ,
/*{{ rand.range(0, 20) }}*/
`f_state` tinyint(4) NOT NULL ,
/*{{ rand.range(0, 5) }}*/
`f_created_at` bigint(20) unsigned NOT NULL DEFAULT '0' ,
/*{{ rand.range(1610535068, 1676882755) }}*/
`f_updated_at` bigint(20) unsigned NOT NULL DEFAULT '0' ,
/*{{ rand.range(1610535068, 1676882755) }}*/
`f_version` bigint(20) unsigned NOT NULL DEFAULT '0' ,
/*{{ rand.range(1, 10000) }}*/
PRIMARY KEY (`f_id`),
UNIQUE KEY `uniq_subaccount_transaction` (`f_subaccount_id`,`f_transaction_type`,`f_transaction_id`),
KEY `idx_user_id` (`f_user_id`),
KEY `idx_account_state_subaccount` (`f_account_id`,`f_state`,`f_subaccount_id`),
KEY `idx_state_precision` (`f_state`,`f_precision`),
KEY `idx_updated_at` (`f_updated_at`)
); dbgen command ./dbgen -i multi_indexes.sql -o test-data/multi_indexes -N 4000000000 -R 2000000 -r 1000 The generated data size is approximately 562GiB. It's guaranteed that there is no unique conflict in the test data. Test stepsFirstly, I use tidb-lightning to import the table without any secondary index. Then I execute a SQL to add all indexes. ALTER TABLE `test`.`multi_indexes`
ADD UNIQUE INDEX `uniq_subaccount_transaction` (`f_subaccount_id`,`f_transaction_type`,`f_transaction_id`),
ADD INDEX `idx_user_id` (`f_user_id`),
ADD INDEX `idx_account_state_subaccount` (`f_account_id`,`f_state`,`f_subaccount_id`),
ADD INDEX `idx_state_precision` (`f_state`,`f_precision`),
ADD INDEX `idx_updated_at` (`f_updated_at`); I did two tests and got this error both times.
The full tidb log is in tidb.log.gz |
12 tasks
ti-chi-bot
pushed a commit
that referenced
this issue
Feb 23, 2023
12 tasks
ti-chi-bot
added a commit
that referenced
this issue
Feb 24, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
Add unique index for a distinct column on a huge table.
2. What did you expect to see? (Required)
No error.
3. What did you see instead (Required)
4. What is your TiDB version? (Required)
7389b2b
The text was updated successfully, but these errors were encountered: