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

tiflash json bool value compare to 1 result is different from tikv #49267

Closed
aytrack opened this issue Dec 8, 2023 · 12 comments
Closed

tiflash json bool value compare to 1 result is different from tikv #49267

aytrack opened this issue Dec 8, 2023 · 12 comments
Labels
severity/critical sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@aytrack
Copy link
Contributor

aytrack commented Dec 8, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists t;
create table t(a int, b json);
alter table t set tiflash replica 1;
insert into t values (10, '{"name":"value"}'), (11, '{\"asdf\":true}'), (13, '{\"input1\":\"\\u00f6\"}');

select /*+ read_from_storage(tiflash[t]) */  JSON_EXTRACT(b, "$.\"asdf\"") = true, JSON_EXTRACT(b, "$.\"asdf\"") = false, JSON_EXTRACT(b, "$.\"asdf\"") = 1 from t where a = 11;
select /*+ read_from_storage(tikv[t]) */  JSON_EXTRACT(b, "$.\"asdf\"") = true, JSON_EXTRACT(b, "$.\"asdf\"") = false, JSON_EXTRACT(b, "$.\"asdf\"") = 1 from t where a = 11;

introduced by #48550

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

[10:31:08]TiDB root:test> select /*+ read_from_storage(tikv[t]) */  JSON_EXTRACT(b, "$.\"asdf\"") = true, JSON_EXTRACT(b, "$.\"asdf\"") = false, JSON_EXTRACT(b, "$.\"asdf\"") = 1 from t where a = 11;
                       ->
+--------------------------------------+---------------------------------------+-----------------------------------+
| JSON_EXTRACT(b, "$.\"asdf\"") = true | JSON_EXTRACT(b, "$.\"asdf\"") = false | JSON_EXTRACT(b, "$.\"asdf\"") = 1 |
+--------------------------------------+---------------------------------------+-----------------------------------+
| 1                                    | 0                                     | 0                                 |
+--------------------------------------+---------------------------------------+-----------------------------------+
1 row in set
Time: 0.004s
[10:31:17]TiDB root:test> select /*+ read_from_storage(tiflash[t]) */  JSON_EXTRACT(b, "$.\"asdf\"") = true, JSON_EXTRACT(b, "$.\"asdf\"") = false, JSON_EXTRACT(b, "$.\"asdf\"") = 1 from t where a = 11;
+--------------------------------------+---------------------------------------+-----------------------------------+
| JSON_EXTRACT(b, "$.\"asdf\"") = true | JSON_EXTRACT(b, "$.\"asdf\"") = false | JSON_EXTRACT(b, "$.\"asdf\"") = 1 |
+--------------------------------------+---------------------------------------+-----------------------------------+
| 1                                    | 0                                     | 0                                 |
+--------------------------------------+---------------------------------------+-----------------------------------+

3. What did you see instead (Required)

[10:31:08]TiDB root:test> select /*+ read_from_storage(tikv[t]) */  JSON_EXTRACT(b, "$.\"asdf\"") = true, JSON_EXTRACT(b, "$.\"asdf\"") = false, JSON_EXTRACT(b, "$.\"asdf\"") = 1 from t where a = 11;
                       ->
+--------------------------------------+---------------------------------------+-----------------------------------+
| JSON_EXTRACT(b, "$.\"asdf\"") = true | JSON_EXTRACT(b, "$.\"asdf\"") = false | JSON_EXTRACT(b, "$.\"asdf\"") = 1 |
+--------------------------------------+---------------------------------------+-----------------------------------+
| 1                                    | 0                                     | 0                                 |
+--------------------------------------+---------------------------------------+-----------------------------------+
1 row in set
Time: 0.004s
[10:40:42]TiDB root:test> select /*+ read_from_storage(tiflash[t]) */  JSON_EXTRACT(b, "$.\"asdf\"") = true, JSON_EXTRACT(b, "$.\"asdf\"") = false, JSON_EXTRACT(b, "$.\"asdf\"") = 1 from t where a = 11;
+--------------------------------------+---------------------------------------+-----------------------------------+
| JSON_EXTRACT(b, "$.\"asdf\"") = true | JSON_EXTRACT(b, "$.\"asdf\"") = false | JSON_EXTRACT(b, "$.\"asdf\"") = 1 |
+--------------------------------------+---------------------------------------+-----------------------------------+
| 1                                    | 0                                     | 1                                 |
+--------------------------------------+---------------------------------------+-----------------------------------+
1 row in set

4. What is your TiDB version? (Required)

[10:41:25]TiDB root:test> select type,version,git_hash  from information_schema.cluster_info;
+---------+-------------+------------------------------------------+
| type    | version     | git_hash                                 |
+---------+-------------+------------------------------------------+
| tidb    | 7.6.0-alpha | 8fc13dadb250139694d608144219fb1ded041412 |
| pd      | 7.6.0-alpha | 995fcef820f43758b94a2eeef8cdd91fa08deaea |
| tikv    | 7.6.0-alpha | 213299221806959c95d05d0f2d7368e597fa9281 |
| tiflash | 7.6.0-alpha | 713bca0a4f65c3217192baf00dc00b8ea7c9dccc |
+---------+-------------+------------------------------------------+
@aytrack aytrack added type/bug The issue is confirmed as a bug. sig/execution SIG execution severity/critical labels Dec 8, 2023
@SeaRise
Copy link
Contributor

SeaRise commented Dec 8, 2023

img_v3_025u_4f2c3701-cf56-4fd8-9f6b-50fda1c2d1fg
The results for JSON_EXTRACT(b, "$.\"asdf\"") = 1 are different in the two sql's and more investigation is needed

@SeaRise
Copy link
Contributor

SeaRise commented Dec 8, 2023

The reason is that the result reuse mechanism of tiflash's ExpressionAction, JSON_EXTRACT(b, "$.\"asdf\"") = 1 incorrectly reuses the result of JSON_EXTRACT(b, "$.\"asdf\"") = true .
So running JSON_EXTRACT(b, "$.\"asdf\"") = true alone results is correctly

@SeaRise
Copy link
Contributor

SeaRise commented Dec 8, 2023

/remove label may-affects-5.4

@SeaRise
Copy link
Contributor

SeaRise commented Dec 8, 2023

/remove-label may-affects-5.4

@ti-chi-bot ti-chi-bot bot removed the may-affects-5.4 This bug maybe affects 5.4.x versions. label Dec 8, 2023
@SeaRise
Copy link
Contributor

SeaRise commented Dec 8, 2023

/remove-label may-affects-6.1

@SeaRise
Copy link
Contributor

SeaRise commented Dec 8, 2023

/remove-label may-affects-6.5

@SeaRise
Copy link
Contributor

SeaRise commented Dec 8, 2023

/remove-label may-affects-7.1

@SeaRise
Copy link
Contributor

SeaRise commented Dec 8, 2023

/remove-label may-affects-7.5

@SeaRise
Copy link
Contributor

SeaRise commented Dec 11, 2023

should be fixed by pingcap/tiflash#8483

@SeaRise
Copy link
Contributor

SeaRise commented Dec 12, 2023

fixed

mysql>
mysql> select /*+ read_from_storage(tiflash[t]) */  JSON_EXTRACT(b, "$.\"asdf\"") = true, JSON_EXTRACT(b, "$.\"asdf\"") = false, JSON_EXTRACT(b,
"$.\"asdf\"") = 1 from t where a = 11;
+--------------------------------------+---------------------------------------+-----------------------------------+
| JSON_EXTRACT(b, "$.\"asdf\"") = true | JSON_EXTRACT(b, "$.\"asdf\"") = false | JSON_EXTRACT(b, "$.\"asdf\"") = 1 |
+--------------------------------------+---------------------------------------+-----------------------------------+
|                                    1 |                                     0 |                                 0 |
+--------------------------------------+---------------------------------------+-----------------------------------+
1 row in set (0.03 sec)

mysql> select /*+ read_from_storage(tikv[t]) */  JSON_EXTRACT(b, "$.\"asdf\"") = true, JSON_EXTRACT(b, "$.\"asdf\"") = false, JSON_EXTRACT(b, "$.\"asdf\"") = 1 from t where a = 11;
+--------------------------------------+---------------------------------------+-----------------------------------+
| JSON_EXTRACT(b, "$.\"asdf\"") = true | JSON_EXTRACT(b, "$.\"asdf\"") = false | JSON_EXTRACT(b, "$.\"asdf\"") = 1 |
+--------------------------------------+---------------------------------------+-----------------------------------+
|                                    1 |                                     0 |                                 0 |
+--------------------------------------+---------------------------------------+-----------------------------------+
1 row in set (0.00 sec)

@SeaRise
Copy link
Contributor

SeaRise commented Dec 12, 2023

/close

Copy link

ti-chi-bot bot commented Dec 12, 2023

@SeaRise: Closing this issue.

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot bot closed this as completed Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/critical sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

2 participants