分区动态裁剪导致analyze table报invalid encoded key flag 9

【版本】5.2.3
会话开启分区动态裁剪后analyze table报invalid encoded key flag 9
mysql> set @@session.tidb_partition_prune_mode = ‘static’;
Query OK, 0 rows affected (0.00 sec)

mysql> analyze table oracle_cb_metric_dbtime;
Query OK, 0 rows affected (13.97 sec)

mysql> set @@session.tidb_partition_prune_mode = ‘dynamic’;
Query OK, 0 rows affected (0.00 sec)

mysql> analyze table oracle_cb_metric_dbtime;
ERROR 1105 (HY000): invalid encoded key flag 9
mysql> set @@session.tidb_partition_prune_mode = ‘static’;
Query OK, 0 rows affected (0.00 sec)

mysql> analyze table oracle_cb_metric_dbtime;
Query OK, 0 rows affected (14.06 sec)

mysql> set @@session.tidb_partition_prune_mode = ‘dynamic’;
Query OK, 0 rows affected (0.00 sec)

mysql> analyze table oracle_cb_metric_dbtime;
ERROR 1105 (HY000): invalid encoded key flag 9
mysql>

补充一下 tidb 对应的 log 哈。

[2022/04/06 21:30:40.629 +08:00] [INFO] [coprocessor.go:812] ["[TIME_COP_PROCESS] resp_time:1.016002785s txnStartTS:432341470533648387 region_id:3069864 store_addr:10.161.69.183:20160 kv_process_ms:1015 kv_wait_ms:0 kv_read_ms:0 processed_versions:1267596 total_versions:1267599 rocksdb_delete_skipped_count:0 rocksdb_key_skipped_count:1267598 rocksdb_cache_hit_count:9 rocksdb_read_count:956 rocksdb_read_byte:28454960"]
[2022/04/06 21:30:40.666 +08:00] [INFO] [coprocessor.go:812] ["[TIME_COP_PROCESS] resp_time:911.148477ms txnStartTS:432341470533648387 region_id:3070449 store_addr:10.161.69.185:20160 kv_process_ms:910 kv_wait_ms:0 kv_read_ms:0 processed_versions:1104796 total_versions:1104797 rocksdb_delete_skipped_count:0 rocksdb_key_skipped_count:1104796 rocksdb_cache_hit_count:9 rocksdb_read_count:833 rocksdb_read_byte:17813877"]
[2022/04/06 21:30:41.096 +08:00] [INFO] [coprocessor.go:812] ["[TIME_COP_PROCESS] resp_time:429.958746ms txnStartTS:432341470533648387 region_id:2911225 store_addr:10.161.69.185:20160 kv_process_ms:428 kv_wait_ms:1 kv_read_ms:0 processed_versions:439424 total_versions:439425 rocksdb_delete_skipped_count:0 rocksdb_key_skipped_count:439424 rocksdb_cache_hit_count:9 rocksdb_read_count:333 rocksdb_read_byte:7150495"]
[2022/04/06 21:30:41.264 +08:00] [INFO] [analyze.go:128] [“analyze table skyalarm.oracle_cb_metric_dbtime has finished”] [conn=7765] [partition=p202203] [“job info”=“analyze index idx1”] [“start time”=2022/04/06 21:30:38.911 +08:00] [“end time”=2022/04/06 21:30:41.264 +08:00] [cost=2.352774409s]
[2022/04/06 21:30:41.540 +08:00] [INFO] [coprocessor.go:812] ["[TIME_COP_PROCESS] resp_time:910.879738ms txnStartTS:432341470533648387 region_id:2678295 store_addr:10.161.69.183:20160 kv_process_ms:910 kv_wait_ms:0 kv_read_ms:0 processed_versions:1260077 total_versions:1260078 rocksdb_delete_skipped_count:0 rocksdb_key_skipped_count:1260077 rocksdb_cache_hit_count:468 rocksdb_read_count:490 rocksdb_read_byte:18392738"]
[2022/04/06 21:30:41.677 +08:00] [INFO] [analyze.go:128] [“analyze table skyalarm.oracle_cb_metric_dbtime has finished”] [conn=7765] [partition=p202201] [“job info”=“analyze index idx1”] [“start time”=2022/04/06 21:30:36.587 +08:00] [“end time”=2022/04/06 21:30:41.677 +08:00] [cost=5.089503488s]
[2022/04/06 21:30:42.130 +08:00] [INFO] [tidb.go:242] [“rollbackTxn called due to ddl/autocommit failure”]
[2022/04/06 21:30:42.130 +08:00] [WARN] [session.go:1686] [“run statement failed”] [conn=7765] [schemaVersion=853] [error=“invalid encoded key flag 9”] [session="{\ “currDBName”: “skyalarm”,\ “id”: 7765,\ “status”: 2,\ “strictMode”: true,\ “user”: {\ “Username”: “root”,\ “Hostname”: “10.161.69.187”,\ “CurrentUser”: false,\ “AuthUsername”: “root”,\ “AuthHostname”: “%”\ }\ }"]
[2022/04/06 21:30:42.130 +08:00] [INFO] [conn.go:1007] [“command dispatched failed”] [conn=7765] [connInfo=“id:7765, addr:10.161.69.187:13802 status:10, collation:utf8mb4_0900_ai_ci, user:root”] [command=Query] [status=“inTxn:0, autocommit:1”] [sql=“analyze table oracle_cb_metric_dbtime”] [txn_mode=PESSIMISTIC] [err=“invalid encoded key flag 9\ngithub.com/pingcap/tidb/util/codec.DecodeAsDateTime\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/util/codec/codec.go:885\ github.com/pingcap/tidb/statistics.MergePartTopN2GlobalTopN\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/statistics/cmsketch.go:758\ github.com/pingcap/tidb/statistics/handle.(*Handle).mergePartitionStats2GlobalStats\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/statistics/handle/handle.go:448\ngithub.com/pingcap/tidb/statistics/handle.(*Handle).MergePartitionStats2GlobalStatsByTableID\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/statistics/handle/handle.go:334\ngithub.com/pingcap/tidb/executor.(*AnalyzeExec).Next\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/executor/analyze.go:186\ngithub.com/pingcap/tidb/executor.Next\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/executor/executor.go:285\ github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelayExecutor\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/executor/adapter.go:590\ngithub.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelay\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/executor/adapter.go:471\ngithub.com/pingcap/tidb/executor.(*ExecStmt).Exec\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/executor/adapter.go:420\ngithub.com/pingcap/tidb/session.runStmt\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/session/session.go:1789\ github.com/pingcap/tidb/session.(*session).ExecuteStmt\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/session/session.go:1683\ngithub.com/pingcap/tidb/server.(*TiDBContext).ExecuteStmt\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/driver_tidb.go:218\ngithub.com/pingcap/tidb/server.(*clientConn).handleStmt\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/conn.go:1830\ngithub.com/pingcap/tidb/server.(*clientConn).handleQuery\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/conn.go:1702\ngithub.com/pingcap/tidb/server.(*clientConn).dispatch\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/conn.go:1227\ngithub.com/pingcap/tidb/server.(*clientConn).Run\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/conn.go:990\ngithub.com/pingcap/tidb/server.(*Server).onConn\ \t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/server.go:501\ runtime.goexit\ \t/usr/local/go/src/runtime/asm_amd64.s:1371”]