Skip to content

check mutation detects inconsistent index values when use expression-index #30809

@vivid392845427

Description

@vivid392845427

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

set tidb_enable_mutation_checker=1
set experimental.allow-expression-index=true
set new_collations_enabled_on_first_bootstrap: true

drop table if exists t;
create table t ( c_int int, c_str varchar(40) character set utf8 collate utf8_general_ci, primary key(c_int, c_str(9))  clustered, unique key(c_int) , key(c_str(31)) , key(c_int, (reverse(c_str))) );
replace into t (c_int, c_str) values (9, "beautiful hermann");

2. What did you expect to see? (Required)

replace success.

3. What did you see instead (Required)

replace failed:

mysql> replace into t (c_int, c_str) values (9, "beautiful hermann");
ERROR 1105 (HY000): inconsistent index values
mysql> set tidb_enable_mutation_checker=0
Query OK, 0 rows affected (0.00 sec)
mysql> replace into t (c_int, c_str) values (9, "beautiful hermann");
Query OK, 1 row affected (0.05 sec)

tidb log:
[2021/12/16 09:29:31.281 +00:00] [ERROR] [mutation_checker.go:318] ["inconsistent index values"] ["truncated mutation datum"="KindNull <nil>"] ["truncated expected datum"="KindString nnamreh lufituaeb"]
[2021/12/16 09:29:31.282 +00:00] [INFO] [tidb.go:260] ["rollbackTxn called due to ddl/autocommit failure"]
[2021/12/16 09:29:31.284 +00:00] [WARN] [session.go:1583] ["run statement failed"] [conn=349] [schemaVersion=30894] [error="inconsistent index values"] [session="{\n  \"currDBName\": \"test1\",\n  \"id\": 349,\n  \"status\": 2,\n  \"strictMode\": true,\n  \"user\": {\n    \"Username\": \"root\",\n    \"Hostname\": \"127.0.0.1\",\n    \"CurrentUser\": false,\n    \"AuthUsername\": \"root\",\n    \"AuthHostname\": \"%\"\n  }\n}"]
[2021/12/16 09:29:31.285 +00:00] [INFO] [conn.go:1103] ["command dispatched failed"] [conn=349] [connInfo="id:349, addr:127.0.0.1:52444 status:10, collation:utf8_general_ci, user:root"] [command=Query] [status="inTxn:0, autocommit:1"] [sql="replace into t (c_int, c_str, c_datetime, c_double, c_enum, c_set) values (9, \"beautiful hermann\", '2020-06-18 22:14:59', 86.361783, \"yellow\", \"blue\")"] [txn_mode=PESSIMISTIC] [err="inconsistent index values\ngithub.com/pingcap/tidb/table/tables.compareIndexData\n\t/home/gopath/src/github.com/pingcap/tidb/table/tables/mutation_checker.go:323\ngithub.com/pingcap/tidb/table/tables.checkIndexKeys\n\t/home/gopath/src/github.com/pingcap/tidb/table/tables/mutation_checker.go:209\ngithub.com/pingcap/tidb/table/tables.CheckDataConsistency\n\t/home/gopath/src/github.com/pingcap/tidb/table/tables/mutation_checker.go:101\ngithub.com/pingcap/tidb/table/tables.(*TableCommon).AddRecord\n\t/home/gopath/src/github.com/pingcap/tidb/table/tables/tables.go:853\ngithub.com/pingcap/tidb/executor.(*InsertValues).addRecordWithAutoIDHint\n\t/home/gopath/src/github.com/pingcap/tidb/executor/insert_common.go:1139\ngithub.com/pingcap/tidb/executor.(*InsertValues).addRecord\n\t/home/gopath/src/github.com/pingcap/tidb/executor/insert_common.go:1128\ngithub.com/pingcap/tidb/executor.(*ReplaceExec).replaceRow\n\t/home/gopath/src/github.com/pingcap/tidb/executor/replace.go:157\ngithub.com/pingcap/tidb/executor.(*ReplaceExec).exec\n\t/home/gopath/src/github.com/pingcap/tidb/executor/replace.go:238\ngithub.com/pingcap/tidb/executor.insertRows\n\t/home/gopath/src/github.com/pingcap/tidb/executor/insert_common.go:278\ngithub.com/pingcap/tidb/executor.(*ReplaceExec).Next\n\t/home/gopath/src/github.com/pingcap/tidb/executor/replace.go:257\ngithub.com/pingcap/tidb/executor.Next\n\t/home/gopath/src/github.com/pingcap/tidb/executor/executor.go:286\ngithub.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelayExecutor\n\t/home/gopath/src/github.com/pingcap/tidb/executor/adapter.go:594\ngithub.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelay\n\t/home/gopath/src/github.com/pingcap/tidb/executor/adapter.go:470\ngithub.com/pingcap/tidb/executor.(*ExecStmt).Exec\n\t/home/gopath/src/github.com/pingcap/tidb/executor/adapter.go:419\ngithub.com/pingcap/tidb/session.runStmt\n\t/home/gopath/src/github.com/pingcap/tidb/session/session.go:1696\ngithub.com/pingcap/tidb/session.(*session).ExecuteStmt\n\t/home/gopath/src/github.com/pingcap/tidb/session/session.go:1580\ngithub.com/pingcap/tidb/server.(*TiDBContext).ExecuteStmt\n\t/home/gopath/src/github.com/pingcap/tidb/server/driver_tidb.go:219\ngithub.com/pingcap/tidb/server.(*clientConn).handleStmt\n\t/home/gopath/src/github.com/pingcap/tidb/server/conn.go:1950\ngithub.com/pingcap/tidb/server.(*clientConn).handleQuery\n\t/home/gopath/src/github.com/pingcap/tidb/server/conn.go:1819\ngithub.com/pingcap/tidb/server.(*clientConn).dispatch\n\t/home/gopath/src/github.com/pingcap/tidb/server/conn.go:1324\ngithub.com/pingcap/tidb/server.(*clientConn).Run\n\t/home/gopath/src/github.com/pingcap/tidb/server/conn.go:1079\ngithub.com/pingcap/tidb/server.(*Server).onConn\n\t/home/gopath/src/github.com/pingcap/tidb/server/server.go:548\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1371"]

4. What is your TiDB version? (Required)

Release Version: v5.4.0-alpha-348-g583ff25-dirty
Edition: Community
Git Commit Hash: 583ff252d76a6525518114a772e7fb4cf9441fd0
Git Branch: ft-data-inconsistency
UTC Build Time: 2021-12-16 05:36:08
GoVersion: go1.16.3
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions