Error When Restoring Data from S3 to a New TiDB Cluster Using BR: [ddl:1069] Too many keys specified; max 64 keys allowed

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 使用br从s3恢复数据到一个新的tidb集群报错Error: [ddl:1069]Too many keys specified; max 64 keys allowed

| username: panqiao

[Test Environment for TiDB] Testing
[TiDB Version] v6.5.3
[Reproduction Path] What operations were performed to cause the issue
Normal backup to S3

During restoration

[Encountered Issue: Issue Phenomenon and Impact]
[Resource Configuration] Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachments: Screenshots/Logs/Monitoring]
Error during restoration:

| username: WalterWj | Original post link

Error code 1069 specifically means “Error 1069: Too many keys specified; max 64 keys allowed,” which implies that the number of keys specified when creating an index or constraint exceeds the maximum limit. In TiDB, the total number of keys for indexes and constraints in each table cannot exceed 64. :thinking:

| username: 大飞哥online | Original post link

You can check your table definition to see if there are any redundant or duplicate keys. Additionally, you might consider using composite keys instead of multiple individual keys to reduce the number of keys.

| username: 大飞哥online | Original post link

I think an optimization should be suggested here. During the backup process, a warning message should be provided. Otherwise, if the backup is successful but the environment is lost and recovery fails, it would be a disaster.

| username: dba远航 | Original post link

The number of indexes has exceeded the limit.

| username: panqiao | Original post link

Yes, it’s really frustrating. The backup was successful, but it won’t let me restore. Today, I was doing a disaster recovery drill because TiDB’s BR had issues before, so I thought it had been a few months since I last tested backup and recovery. It turned out there was indeed a problem. But when I asked our developers, they said we need that many indexes. Is there a way to solve this problem from the database level, like increasing the number of indexes to allow a table to have 256 or 512 indexes? If I need to restore in a production environment now, I’m screwed.

| username: panqiao | Original post link

Is there a way to solve the problem from the database level, such as increasing the number of indexes, allowing a table to have 256 or 512 indexes? If I need to recover in the production environment now, I’m done for.

| username: panqiao | Original post link

I configured this, but it still reports an error.

| username: WalterWj | Original post link

Check this: TiDB 配置文件描述 | PingCAP 文档中心

| username: WalterWj | Original post link

Ah, did you find the table? Check the table structure…
Also, use this command to confirm if the modification was successful: show config where name like ‘%index%’;

Oh right, BR restoring the table structure probably doesn’t execute an SQL file but uses SST to load into TiKV. So changing the database configuration won’t help, this error is likely a validation done by BR itself, I’m not too sure.

You should report this in the feedback section.

| username: yulei7633 | Original post link

Check if the version of BR you used for export is consistent with the version you used for import?

| username: yulei7633 | Original post link

It is best to keep the imported BR version consistent, although the imported BR version can be higher than the exported BR version.

| username: panqiao | Original post link

Thank you for your response. I have identified which table caused the error. I imported this table into my new cluster using an SQL script, and there were no errors. This indicates that at the TiDB layer, there was no obstruction in creating the table, and it also shows that my configuration has taken effect, confirming that I successfully modified the configuration to 256, as shown in the image below:

To further verify this issue, I created a new cluster and set the index-limit to 64. When I imported the table again, it indeed reported an error because the table has 66 indexes. This once again confirmed that my configuration had taken effect. However, it was blocked by the BR tool. After checking the source code, it seems that in this version of the BR tool, the right value of the if condition should be the default index-limit, which is 64. Therefore, the error reported is 64. This is confirmed to be a bug.

| username: panqiao | Original post link

It is consistent; the cluster version and the tool version are both the same.

| username: panqiao | Original post link

It is most likely a bug in BR, which did not correctly read the index-limit I configured.

| username: yulei7633 | Original post link

It’s unlikely to be a bug. Let’s keep looking for the cause.

| username: zhanggame1 | Original post link

You can report bugs to the community.

| username: h5n1 | Original post link

6.5.4
Increase the default values of the global parameters TableColumnCountLimit and IndexLimit used by BR to the maximum value to fix the issue of failure during the restore process #45793

| username: panqiao | Original post link

Sure, I’ll give it a try. I’ll take this opportunity to upgrade TiDB. Which versions of the operator and TiDB should I choose for production use?

| username: panqiao | Original post link

I upgraded my database to v7.1.0, then did a full backup, and then fully restored it to a new cluster (dr, also v7.1.0), but the error still occurs. This indicates that the problem has not been resolved yet.