Inconsistent Index Issue

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

Original topic: inconsistent index 不连续的索引问题

| username: TiDBer_AcAczQ2E

[TiDB Usage Environment] Test
[TiDB Version] 5.3
[Encountered Issue]
When querying data, the following error occurs: inconsistent index PRIMARY handle count 21 isn’t equal to value count 7
[Reproduction Path]
tispark writes to tidb
df.write.
format(“tidb”).
option(“tidb.addr”, “”).
option(“tidb.port”, “4000”).
option(“tidb.user”, “bdata”).
option(“tidb.password”, “”).
option(“database”, “bdata”).
option(“table”, tblName).
option(“replace”, true).
option(“isolationLevel”, “NONE”).
option(JDBCOptions.JDBC_BATCH_INSERT_SIZE, 1000).
mode(“append”).
save()
[Issue Phenomenon and Impact]
After each data write execution, select will encounter inconsistent index issues.

| username: db_user | Original post link

It looks similar to this issue:

| username: Lawrence | Original post link

What version of TiSpark are you using? This is a bug in TiSpark. Another critical bug in TiSpark is that the number of records written to TiKV and TiFlash is inconsistent. Therefore, it’s better not to use TiSpark for writing data; it can be used for reading.

| username: TiDBer_AcAczQ2E | Original post link

The version is 2.4.1

| username: Lawrence | Original post link

Try upgrading to 2.4.2. It should be fixed in 2.4.2, but the changelog probably didn’t mention it.

| username: TiDBer_AcAczQ2E | Original post link

Okay, thanks, I’ll give it a try.

| username: TiDBer_AcAczQ2E | Original post link

But I’m using Scala 2.11.

| username: Lawrence | Original post link

Then don’t use TiSpark to write, the lower versions have serious bugs.

| username: Billmay表妹 | Original post link

TiSpark has been updated to 3.0. For specific version information, see:

| username: TiDBer_AcAczQ2E | Original post link

Today I encountered a serious issue while querying: my table has a composite primary key consisting of item_id and erpsource. When querying by delivery_id, duplicate composite primary keys appeared!


However, when querying by the item_id primary key, no duplicate composite primary keys appeared!

| username: Lawrence | Original post link

Open a new thread for different topics.