pingcap / pingcap/tidb

tidb_decode_key() does not decode meta data keys

Open
#39,951 2 comments 1 reaction 0 assignees View on GitHub
severity/moderate sig/sql-infra type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

In TiDB log file, some times keys are included in the log, I would expect `tidb_decode_key()` to be able to decode those.
Like '6d44444c4a6f625265ff6f72670000000000fa0000000000000068000000000000005cff5f656c6500000000fb'

### 2. What did you expect to see? (Required)
Something like:
```
tidb> select tidb_decode_key('6d44444c4a6f625265ff6f72670000000000fa0000000000000068000000000000005cff5f656c6500000000fb');
+---------------------------------------------------------------------------------------------------------------+
| tidb_decode_key('6d44444c4a6f625265ff6f72670000000000fa0000000000000068000000000000005cff5f656c6500000000fb') |
+---------------------------------------------------------------------------------------------------------------+
| {"meta_key":"DDLJobReorg","field":"_ele"} |
+---------------------------------------------------------------------------------------------------------------+
```

### 3. What did you see instead (Required)
```
tidb> select tidb_decode_key('6d44444c4a6f625265ff6f72670000000000fa0000000000000068000000000000005cff5f656c6500000000fb');
+---------------------------------------------------------------------------------------------------------------+
| tidb_decode_key('6d44444c4a6f625265ff6f72670000000000fa0000000000000068000000000000005cff5f656c6500000000fb') |
+---------------------------------------------------------------------------------------------------------------+
| 6d44444c4a6f625265ff6f72670000000000fa0000000000000068000000000000005cff5f656c6500000000fb |
+---------------------------------------------------------------------------------------------------------------+
1 row in set, 1 warning (0,00 sec)

tidb> show warnings;
+---------+------+---------------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------------------------------------------------------------------------+
| Warning | 1105 | invalid key: 6D44444C4A6F625265FF6F72670000000000FA0000000000000068000000000000005CFF5F656C6500000000FB |
+---------+------+---------------------------------------------------------------------------------------------------------+
1 row in set (0,00 sec)
```
### 4. What is your TiDB version? (Required)

```
tidb_version(): Release Version: v6.6.0-alpha-13-gc26a6b5297
Edition: Community
Git Commit Hash: c26a6b5297b5133196ba03771e0bf6db56055ec4
Git Branch: master
UTC Build Time: 2022-12-14 17:39:04
GoVersion: go1.19
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: unistore
```

Contributor guide

Open the contributing guide

Research direction

Start with the tidb_decode_key() SQL entry point and reproduce the provided metadata-key example on the reported TiDB version. Trace how the key is validated and decoded; done means the sample returns the expected DDLJobReorg metadata and no invalid-key warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.