TiDB ID Anomaly Issue

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

Original topic: TiDB id异常问题

| username: jingyesi3401

[TiDB Usage Environment] Production environment, testing

[TiDB Version] v5.1.0

[Encountered Issues: Problem Phenomenon and Impact] Currently, we have an issue with ID gaps in three large tables in our database, causing IDs to exceed 2^50. The current maximum ID is 82118249719484777 (17 digits). We are planning to rename the large tables soon. Initially, we wanted to create new empty tables with IDs starting from 1, but the business logic does not support this (the inserted IDs, although the largest, are not the latest data). Given this, we would like to understand the following:

  1. Is it possible to reset the IDs to start incrementing from 1 without gaps?
  2. If resetting is not possible, can we set the IDs of the three new tables to start from the current maximum plus 10 million? This way, there would be no business issues, but would such large IDs impact performance?
  3. How long would it take to rename tables of several terabytes (previously, renaming tables of several gigabytes took at most 1-2 seconds)?

| username: wakaka | Original post link

  1. It might be that the ID was manually specified during insertion.
| username: wakaka | Original post link

  1. As long as the id is within the range of bigint, there is no problem.
  2. At the second level.
| username: wfxxh | Original post link

If multiple TiDB services are deployed, the auto-increment ID will inevitably have gaps.

| username: jingyesi3401 | Original post link

Today, there was another ID jump when querying, from 17 digits to 19 digits. If this continues, will TiDB become unusable after reaching 2^64? Is there a good solution for this?

| username: ffeenn | Original post link

Why is this operating so strangely? Check the business logs. It’s a business issue.

| username: Running | Original post link

TiDB does not guarantee that IDs will increment sequentially, right?

| username: jingyesi3401 | Original post link

Today, I also created a table to test and verify that it cannot exceed 2^64; otherwise, an error will occur during insertion.

| username: zzzzzz | Original post link

You need to check if the business shows any inserts? Is the primary key using auto random?