查询数据异常

为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。

  • 【TiDB 版本】:v3.0.11
  • 【问题描述】:

通过task_id 字段查找数据无法获取到对应的数据行,但是直接指定该行的主键ID,就可以获取到该行。

通过其他 task_id 值获取数据就可以获取到。

连接其他的TiDB节点,得到的结果都是一样的,还请帮忙看下是否是bug。或者说如何解决呢

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 1296482
Server version: 5.7.25-TiDB-v3.0.11 MySQL Community Server (Apache License 2.0)

Copyright © 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

select * from ap_user_task where id = 344248753;
±----------±----±----------±--------±----------±-----------±-------------------±-------------------±--------------------±--------------------±-------------------±--------------------±------------±--------------------±--------------------+
| id | pid | uid | task_id | config_id | time_type | time_progress_type | time_progress_data | total_progress_type | total_progress_data | task_progress_data | task_timestamp | task_status | ctime | mtime |
±----------±----±----------±--------±----------±-----------±-------------------±-------------------±--------------------±--------------------±-------------------±--------------------±------------±--------------------±--------------------+
| 344248753 | 0 | 490855454 | 1004 | 5100 | 2020-09-08 | 1 | 0 | 4 | 395100 | 50000 | 2020-09-08 15:10:40 | 2 | 2020-09-08 15:10:40 | 2020-09-08 15:21:51 |
±----------±----±----------±--------±----------±-----------±-------------------±-------------------±--------------------±--------------------±-------------------±--------------------±------------±--------------------±--------------------+
1 row in set (0.01 sec)

select * from ap_user_task where uid = 490855454 and task_id = 1004 ;
Empty set (0.00 sec)

select * from ap_user_task where uid = 490855454 and task_id = 1004 and id = 344248753;
±----------±----±----------±--------±----------±-----------±-------------------±-------------------±--------------------±--------------------±-------------------±--------------------±------------±--------------------±--------------------+
| id | pid | uid | task_id | config_id | time_type | time_progress_type | time_progress_data | total_progress_type | total_progress_data | task_progress_data | task_timestamp | task_status | ctime | mtime |
±----------±----±----------±--------±----------±-----------±-------------------±-------------------±--------------------±--------------------±-------------------±--------------------±------------±--------------------±--------------------+
| 344248753 | 0 | 490855454 | 1004 | 5100 | 2020-09-08 | 1 | 0 | 4 | 395100 | 50000 | 2020-09-08 15:10:40 | 2 | 2020-09-08 15:10:40 | 2020-09-08 15:21:51 |
±----------±----±----------±--------±----------±-----------±-------------------±-------------------±--------------------±--------------------±-------------------±--------------------±------------±--------------------±--------------------+
1 row in set (0.00 sec)

explain select * from ap_user_task where uid = 490855454 and task_id = 1004 ;
±------------------±--------±-----±-----------------------------------------------------------------------------------------------------------+
| id | count | task | operator info |
±------------------±--------±-----±-----------------------------------------------------------------------------------------------------------+
| IndexLookUp_10 | 2450.59 | root | |
| ├─IndexScan_8 | 2450.59 | cop | table:ap_user_task, index:uid, task_id, time_type, range:[490855454 1004,490855454 1004], keep order:false |
| └─TableScan_9 | 2450.59 | cop | table:ap_user_task, keep order:false |
±------------------±--------±-----±-----------------------------------------------------------------------------------------------------------+
3 rows in set (0.00 sec)

explain select * from ap_user_task where uid = 490855454 and task_id = 1004 and id = 344248753;
±--------------------±------±-----±------------------------------------------------------------------------------------+
| id | count | task | operator info |
±--------------------±------±-----±------------------------------------------------------------------------------------+
| TableReader_7 | 0.00 | root | data:Selection_6 |
| └─Selection_6 | 0.00 | cop | eq(live_task.ap_user_task.task_id, 1004), eq(live_task.ap_user_task.uid, 490855454) |
| └─TableScan_5 | 1.00 | cop | table:ap_user_task, range:[344248753,344248753], keep order:false |
±--------------------±------±-----±------------------------------------------------------------------------------------+
3 rows in set (0.00 sec)

select * from ap_user_task where uid = 490855454 and task_id in (1002,1004);
±----------±----±----------±--------±----------±-----------±-------------------±-------------------±--------------------±--------------------±-------------------±--------------------±------------±--------------------±--------------------+
| id | pid | uid | task_id | config_id | time_type | time_progress_type | time_progress_data | total_progress_type | total_progress_data | task_progress_data | task_timestamp | task_status | ctime | mtime |
±----------±----±----------±--------±----------±-----------±-------------------±-------------------±--------------------±--------------------±-------------------±--------------------±------------±--------------------±--------------------+
| 344190690 | 0 | 490855454 | 1002 | 1 | 2020-09-08 | 1 | 0 | 2 | 2 | 2 | 2020-09-08 09:56:24 | 2 | 2020-09-08 09:56:24 | 2020-09-08 15:21:51 |
±----------±----±----------±--------±----------±-----------±-------------------±-------------------±--------------------±--------------------±-------------------±--------------------±------------±--------------------±--------------------+
1 row in set (0.02 sec)

麻烦提供一下以下信息用于测试复现:

  1. 提供表结构 show create table ap_user_task
  2. 提供可以用于复现的 ap_user_task 表的数据。最好是 Insert 的 SQL 。用于复现问题,敏感数据可以去掉。
  3. 提供给一下具体的版本号 select tidb_version()