tiflash handle out of bigint data is different from tidb and tikv
Open
Nobody has claimed this yet.
affects-8.1
affects-8.5
component/compute
impact/wrong-result
may-affects-5.4
may-affects-6.1
may-affects-6.5
may-affects-7.1
may-affects-7.5
severity/major
type/bug
- Dominant language
- C++
- Stars
- 1k
- Forks
- 423
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 24
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
create table t(a bigint, b bigint, c bigint, d bigint);
insert into t values (-1938981551717142867, 8476101292023354016, 9223372036854775807, 9223372036854775807);
alter table t set tiflash replica 1;
-- tikv
select a - b, c + d from t;
-- tiflash
set tidb_isolation_read_engines='tiflash';
select a - b, c + d from t;
-- tidb
select -1938981551717142867 - 8476101292023354016;
select 9223372036854775807 + 9223372036854775807;
2. What did you expect to see? (Required)
the result should be same
3. What did you see instead (Required)
-- tidb
mysql> select -1938981551717142867 - 8476101292023354016;
ERROR 1690 (22003): BIGINT value is out of range in '(-1938981551717142867 - 8476101292023354016)'
mysql> select 9223372036854775807 + 9223372036854775807;
ERROR 1690 (22003): BIGINT value is out of range in '(9223372036854775807 + 9223372036854775807)'
mysql> create table t(a bigint, b bigint, c bigint, d bigint);
Query OK, 0 rows affected (0.63 sec)
mysql> insert into t values (-1938981551717142867, 8476101292023354016, 9223372036854775807, 9223372036854775807);
Query OK, 1 row affected (0.05 sec)
mysql> alter table t set tiflash replica 1;
Query OK, 0 rows affected (0.58 sec)
-- tikv
mysql> set tidb_isolation_read_engines='tikv';
Query OK, 0 rows affected (0.04 sec)
mysql> select a - b, c + d from t;
ERROR 1690 (22003): BIGINT value is out of range in '(test.t.a - test.t.b)'
mysql> set tidb_isolation_read_engines='tidb';
Query OK, 0 rows affected (0.04 sec)
-- tiflash
mysql> set tidb_isolation_read_engines='tiflash';
Query OK, 0 rows affected (0.06 sec)
mysql> select a - b, c + d from t;
+---------------------+-------+
| a - b | c + d |
+---------------------+-------+
| 8031661229969054733 | -2 |
+---------------------+-------+
1 row in set (0.05 sec)
4. What is your TiFlash version? (Required)
mysql> select type, version, git_hash from information_schema.cluster_info group by type;
+---------+---------+------------------------------------------+
| type | version | git_hash |
+---------+---------+------------------------------------------+
| tikv | 7.6.0 | 737daffe15aafaa0115067a2898e7d98e19fd448 |
| tidb | 7.6.0 | 42960c3352d165810c79852b85ada448a68efa4c |
| tiflash | 7.6.0 | 383e1bd9d3a793f6adb84156639febc68739ea63 |
| pd | 7.6.0 | 9271ad98c28e6c8650d470e6bfd738a75d434448 |
+---------+---------+------------------------------------------+
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the SQL reproduction and compare the results from TiFlash, TiKV, and TiDB for BIGINT addition and subtraction beyond the signed 64-bit range. Trace the relevant TiFlash expression evaluation path and verify behavior against the reported TiDB/TiKV errors. Done means TiFlash returns the same out-of-range error behavior as the other engines.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100