Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong Result from Tiflash when process Time #9657

Open
Dylan0222 opened this issue Nov 20, 2024 · 6 comments
Open

Wrong Result from Tiflash when process Time #9657

Dylan0222 opened this issue Nov 20, 2024 · 6 comments
Labels
affects-8.4 affects-8.5 This bug affects the 8.5.x(LTS) versions. component/compute severity/moderate type/bug The issue is confirmed as a bug.

Comments

@Dylan0222
Copy link

Dylan0222 commented Nov 20, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Drop table if exists t1;
CREATE TABLE t1 (
    id INT PRIMARY KEY AUTO_INCREMENT,
    col1 TIME DEFAULT NULL
);

insert into t1 values(1, '838:59:59');
insert into t1 values(2, '-838:59:59');
insert into t1 values(3, '0');
ALTER TABLE t1 SET TIFLASH REPLICA 1;

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

I find that the returned information is inconsistent across two queries.

3. What did you see instead (Required)

mysql> SELECT /*+ READ_FROM_STORAGE(TIFLASH[t1]) */
    ->     id,
    ->     col1,
    ->     ADDDATE(col1, INTERVAL 12 HOUR_MINUTE) AS updated_col1,
    ->     CASE
    ->         WHEN ADDDATE(col1, INTERVAL 12 HOUR_MINUTE) IS NULL THEN 'NULL VALUE'
    ->         ELSE 'VALID VALUE'
    ->     END AS value_status,
    ->     LENGTH(col1) AS col1_length,
    ->     CONCAT(ADDDATE(col1, INTERVAL 12 HOUR_MINUTE), ' processed') AS processed_value
    -> FROM
    ->     t1
    -> WHERE
    ->     ADDDATE(col1, INTERVAL 12 HOUR_MINUTE) IS NOT NULL;
+----+------------+--------------+--------------+-------------+----------------------+
| id | col1       | updated_col1 | value_status | col1_length | processed_value      |
+----+------------+--------------+--------------+-------------+----------------------+
|  1 | 838:59:59  | 839:09:59    | VALID VALUE  |           9 | 839:11:59 processed  |
|  2 | -838:59:59 | -838:49:59   | VALID VALUE  |          10 | -838:47:59 processed |
|  3 | 00:00:00   | 00:12:00     | VALID VALUE  |           8 | 00:12:00 processed   |
+----+------------+--------------+--------------+-------------+----------------------+
3 rows in set (0.04 sec)

mysql> SELECT /*+ READ_FROM_STORAGE(TIKV[t1]) */
    ->     id,
    ->     col1,
    ->     ADDDATE(col1, INTERVAL 12 HOUR_MINUTE) AS updated_col1,
    ->     CASE
    ->         WHEN ADDDATE(col1, INTERVAL 12 HOUR_MINUTE) IS NULL THEN 'NULL VALUE'
    ->         ELSE 'VALID VALUE'
    ->     END AS value_status,
    ->     LENGTH(col1) AS col1_length,
    ->     CONCAT(ADDDATE(col1, INTERVAL 12 HOUR_MINUTE), ' processed') AS processed_value
    -> FROM
    ->     t1
    -> WHERE
    ->     ADDDATE(col1, INTERVAL 12 HOUR_MINUTE) IS NOT NULL;
+----+------------+--------------+--------------+-------------+----------------------+
| id | col1       | updated_col1 | value_status | col1_length | processed_value      |
+----+------------+--------------+--------------+-------------+----------------------+
|  2 | -838:59:59 | -838:47:59   | VALID VALUE  |          10 | -838:47:59 processed |
|  3 | 00:00:00   | 00:12:00     | VALID VALUE  |           8 | 00:12:00 processed   |
+----+------------+--------------+--------------+-------------+----------------------+
2 rows in set, 1 warning (0.04 sec)

4. What is your TiDB version? (Required)

TiDB v8.4.0

@Dylan0222 Dylan0222 added the type/bug The issue is confirmed as a bug. label Nov 20, 2024
@Dylan0222 Dylan0222 changed the title Wrong Result from Tiflash when process Wrong Result from Tiflash when process Time Nov 20, 2024
@Dylan0222
Copy link
Author

/label affects-8.5

@ti-chi-bot ti-chi-bot bot added the affects-8.5 This bug affects the 8.5.x(LTS) versions. label Nov 20, 2024
@Dylan0222
Copy link
Author

/label affects-8.4

@Dylan0222
Copy link
Author

I have found some additional bugs in TiFlash, which have been submitted in the TiDB repository. Could you please help check them as well? Thanks a lot, @JaySon-Huang.

@yibin87
Copy link
Contributor

yibin87 commented Nov 25, 2024

The "updated_col1" value in tiflash is "00:12:00" instead of "00:10:00" with latest version, do I miss anything? @Dylan0222

@Dylan0222
Copy link
Author

The "updated_col1" value in tiflash is "00:12:00" instead of "00:10:00" with latest version, do I miss anything? @Dylan0222

I’m very sorry for my mistake. It is indeed 00:12:00, but there is one more row compared to TiKV. I will update the above information.

@yibin87
Copy link
Contributor

yibin87 commented Nov 25, 2024

Tikv returns only two rows with the warning:
evaluation failed: Duration value is out of range in '(838:59:59 - 00:12:00)'
Check that mysql return two rows also, with warning:
Datetime function: time field overflow
And according to MySQL document, time data type should have a valid range: https://dev.mysql.com/doc/refman/8.4/en/time.html#:~:text=MySQL%20retrieves%20and%20displays%20TIME%20values%20in%20%27hh%3Amm%3Ass%27%20format%20(or%20%27hhh%3Amm%3Ass%27%20format%20for%20large%20hours%20values).%20TIME%20values%20may%20range%20from%20%27%2D838%3A59%3A59%27%20to%20%27838%3A59%3A59%27.
Thus, tiflash needs to be consistent with this behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-8.4 affects-8.5 This bug affects the 8.5.x(LTS) versions. component/compute severity/moderate type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

4 participants