Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 基本的select查询,数据都会混乱,索引与KV数据不一致,请问如何修复呢?
【TiDB Usage Environment】Production Environment / Testing / PoC
【TiDB Version】5.2.4
【Encountered Problem】When performing a select query based on birthday, name, etc., no data is found. However, after adding a primary key, the query returns results, as shown in the image.
【Reproduction Path】Steps taken that led to the problem
【Problem Phenomenon and Impact】
【Attachment】
This will affect the production environment, right?
Check the official website. It shouldn’t, it just compares whether the index and data are consistent, without table lock. It’s better to run it during off-peak business hours.
Inconsistency, is there any way to fix the 8003 error code? Deleting and rebuilding the index is too time-consuming. This table has tens of billions of data.
Rebuild the index first. You can name it something else initially, then rename it after execution.
First, set this index as an invisible index, CREATE INDEX | PingCAP Docs, so that your production environment SQL will no longer use it, as the data is inconsistent. Second, recreate the index. In TiDB, it is an online DDL, which will not lock the table and affect your use of the table. Third, delete the problematic index.
Last time we used this solution for inconsistency, adding the index was relatively slow. There might be a small portion of data that didn’t match. Is it possible to repair the index for this small portion of data?
There should be no such way. Rebuilding the index also helps with the performance of index queries for future data, as it can reduce the previous skip key performance issues.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.