Issues with Using TiFlash When TiDB Business Table's Auto-Increment Primary Key Reaches Trillions (6666675293967)

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

Original topic: tidb的业务表,自增主键达到万亿(6666675293967 )级别的时候,使用tiflash的问题

| username: hacker_77powerful

[TiDB Usage Environment] Production Environment
[TiDB Version] 7.2
[Reproduction Path]
[Encountered Problem: Problem Phenomenon and Impact] In the production system, the auto-increment primary key of this business table has reached 6 trillion rows, and it is found that the synchronization from tikv to tiflash often crashes.
[Resource Configuration] Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachment: Screenshot/Log/Monitoring]
show create table event_analyze \G;
*************************** 1. row ***************************
Table: event_analyze
Create Table: CREATE TABLE event_analyze (
id bigint(20) NOT NULL AUTO_INCREMENT,
title varchar(255) DEFAULT NULL COMMENT ‘Title’,

KEY province_index (province),
KEY number_index (number),
KEY commandId_index (commandId)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=6666675293967 COMMENT=‘Event Analysis Main Table’
1 row in set (0.00 sec)

Error as follows
[2023/08/30 09:55:19.453 +08:00] [ERROR] [Exception.cpp:90] ["Code: 49, e.displayText() = DB::Exception: Check compare(range.getEnd(), ext_file.range.getEnd()) >= 0 failed, range.toDebugString() = [6666664934914,6666664941665), ext_file.range.toDebugString() = [6666664934914,6666664941666), e.what() = DB::Exception, Stack trace:\n\n\n 0x1bfe42e\tDB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, int) [tiflash+29353006]\n \tdbms/src/Common/Exception.h:46\n 0x73a0bde\tDB::DM::DeltaMergeStore::ingestFiles(std::__1::shared_ptrDB::DM::DMContext const&, DB::DM::RowKeyRange const&, std::__1::vector<DB::DM::ExternalDTFileInfo, std::__1::allocatorDB::DM::ExternalDTFileInfo > const&, bool) [tiflash+121244638]\n \tdbms/src/Storages/DeltaMerge/DeltaMergeStore_Ingest.cpp:564\n 0x7e63fe4\tDB::DM::DeltaMergeStore::ingestFiles(DB::Context const&, DB::Settings const&, DB::DM::RowKeyRange const&, std::__1::vector<DB::DM::ExternalDTFileInfo, std::_1::allocatorDB::DM::ExternalDTFileInfo > const&, bool) [tiflash+132530148]\n \tdbms/src/Storages/DeltaMerge/DeltaMergeStore.h:305\n 0x7f119d9\tvoid DB::KVStore::checkAndApplyPreHandledSnapshotDB::RegionPtrWithSnapshotFiles(DB::RegionPtrWithSnapshotFiles const&, DB::TMTContext&) [tiflash+133241305]\n \tdbms/src/Storages/Transaction/ApplySnapshot.cpp:139\n 0x7f10166\tvoid DB::KVStore::applyPreHandledSnapshotDB::RegionPtrWithSnapshotFiles(DB::RegionPtrWithSnapshotFiles const&, DB::TMTContext&) [tiflash+133235046]\n \tdbms/src/Storages/Transaction/ApplySnapshot.cpp:426\n 0x7f87eb1\tApplyPreHandledSnapshot [tiflash+133725873]\n \tdbms/src/Storages/Transaction/ProxyFFI.cpp:664\n 0x7f3d2289a09f\t$LT$engine_store_ffi…observer…TiFlashObserver$LT$T$C$ER$GT$$u20$as$u20$raftstore…coprocessor…ApplySnapshotObserver$GT$::post_apply_snapshot::h9cf73b076a6be5ca [libtiflash_proxy.so+24293535]\n 0x7

| username: DBAER | Original post link

I feel like I can report a bug.

| username: 随缘天空 | Original post link

You can search the error code in the official documentation to see if there is any similar explanation.

| username: zhang_2023 | Original post link

A trillion-level estimate probably triggered a bug.

| username: 像风一样的男子 | Original post link

This is a known bug. Upgrade to a newer version to fix it.
Also, your version 7.2 is a test version and is not recommended for production environments.

| username: yulei7633 | Original post link

When choosing a version, select LTS, which is the official stable version.

| username: hacker_77powerful | Original post link

Did you encounter a bug? The actual data is only in the tens of millions, but somehow this auto-increment ID has reached the 6 trillion level.

| username: zhaokede | Original post link

There is some waste, right?
What is the step size, is it 1 or another number?

| username: xfworld | Original post link

What is the current maximum value of the primary key?

| username: 像风一样的男子 | Original post link

Has the ID been set to AUTO_RANDOM? If it has, then the ID will consist of multiple parts and not just the pure data count.

| username: dba远航 | Original post link

Is it possible that it has reached the maximum value?

| username: hacker_77powerful | Original post link

Looking at the auto-increment value of that create table statement, it has already reached over 6 trillion. The actual data is only over 10 million.

| username: hacker_77powerful | Original post link

The step size is 1.

| username: hacker_77powerful | Original post link

It should not be using auto_random.
It is using AUTO_INCREMENT.

| username: hacker_77powerful | Original post link

There are no issues in TiKV, but synchronizing this table to TiFlash will cause TiFlash to crash, resulting in the above error.

| username: 像风一样的男子 | Original post link

You should upgrade first. It’s normal for a dev version like 7.2 to have bugs.

| username: xiaoqiao | Original post link

Waiting to see.

| username: QH琉璃 | Original post link

You can ask the official team.

| username: xfworld | Original post link

Upgrade to LTS … 7.5.x

7.2 is DMR, and there is no upgrade support…

| username: zhimadi | Original post link

Has the table been modified? Changed from auto_random back to AUTO_INCREMENT?