pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.37k stars 5.86k forks source link

Tiflash Fail to Execute Query #57656

Open Dylan0222 opened 1 day ago

Dylan0222 commented 1 day ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

DROP TABLE IF EXISTS person;
CREATE TABLE person (
    id INT NOT NULL PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    address_info JSON,
    age DOUBLE GENERATED ALWAYS AS ((id + 100) /2) VIRTUAL
);

ALTER TABLE person SET TIFLASH REPLICA 1;
INSERT INTO person (id, name, address_info) 
VALUES 
    (1, 'Alice', '{"street": "123 Elm St", "city": "Wonderland", "zipcode": "12345"}'),
    (2, 'Bob', '{"street": "456 Oak St", "city": "Nowhere", "zipcode": "67890"}'),
    (3, 'Charlie', '{"street": "789 Pine St", "city": "Somewhere", "zipcode": "11223"}');

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

I find that the returned result is inconsistent across two queries. Moreover, Tiflash cannot even execute this query.

3. What did you see instead (Required)

mysql> SELECT /*+ READ_FROM_STORAGE(tikv[person]) */ age FROM person limit 1;
+------+
| age  |
+------+
| 50.5 |
+------+
1 row in set (0.04 sec)

mysql> SELECT /*+ READ_FROM_STORAGE(tiflash[person]) */ age FROM person limit 1;
ERROR 1815 (HY000): Internal : Can't find a proper physical plan for this query

4. What is your TiDB version? (Required)

TiDB v8.4.0

Dylan0222 commented 1 day ago

/label affects-8.4 /label affects-8.5

Dylan0222 commented 14 hours ago

But this query can work well @jebter: mysql> SELECT /+ READ_FROM_STORAGE(tikv[person]) / age FROM person order by age; +------+ | age | +------+ | 50.5 | | 51 | | 51.5 | +------+ 3 rows in set (0.04 sec)

mysql> SELECT /+ READ_FROM_STORAGE(tiflash[person]) / age FROM person order by age; +------+ | age | +------+ | 50.5 | | 51 | | 51.5 | +------+ 3 rows in set (0.04 sec)