Inconsistent cast conversion in Tiflash
オープン
まだ誰も着手していません。
affects-8.4
affects-8.5
component/compute
impact/inconsistency
may-affects-5.4
may-affects-6.1
may-affects-6.5
may-affects-7.1
may-affects-7.5
may-affects-8.1
severity/major
type/bug
- 主要言語
- C++
- スター
- 1k
- フォーク
- 423
- 平均マージ
- 1日 15時間
- マージ済み PR(30日)
- 24
説明
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
Drop table if exists test_table;
CREATE TABLE test_table (
id INT PRIMARY KEY AUTO_INCREMENT,
col1 VARCHAR(255),
col2 TINYINT,
col3 SMALLINT
);
INSERT INTO test_table (col1, col2, col3) VALUES
('-9223372036854775809', -128, -32768),
('-9223372036854775808', 127, 32767);
ALTER TABLE test_table SET TIFLASH REPLICA 1;
SELECT /*+ READ_FROM_STORAGE(TIKV[test_table])*/
id,
col1,
CAST(col1 AS SIGNED) AS signed_int,
CAST(col1 AS UNSIGNED) AS unsigned_int,
CAST(col1 AS DECIMAL(65,30)) AS decimal_value,
CAST(col1 AS DOUBLE) AS double_value
FROM
test_table;
SELECT /*+ READ_FROM_STORAGE(TIFLASH[test_table])*/
id,
col1,
CAST(col1 AS SIGNED) AS signed_int,
CAST(col1 AS UNSIGNED) AS unsigned_int,
CAST(col1 AS DECIMAL(65,30)) AS decimal_value,
CAST(col1 AS DOUBLE) AS double_value
FROM
test_table;
2. What did you expect to see? (Required)
I find that unsigned_int is inconsistent across two queries.
3. What did you see instead (Required)
mysql> SELECT /*+ READ_FROM_STORAGE(TIKV[test_table])*/
-> id,
-> col1,
-> CAST(col1 AS SIGNED) AS signed_int,
-> CAST(col1 AS UNSIGNED) AS unsigned_int,
-> CAST(col1 AS DECIMAL(65,30)) AS decimal_value,
-> CAST(col1 AS DOUBLE) AS double_value
-> FROM
-> test_table;
+----+----------------------+----------------------+---------------------+-----------------------------------------------------+-----------------------+
| id | col1 | signed_int | unsigned_int | decimal_value | double_value |
+----+----------------------+----------------------+---------------------+-----------------------------------------------------+-----------------------+
| 1 | -9223372036854775809 | -9223372036854775808 | 9223372036854775808 | -9223372036854775809.000000000000000000000000000000 | -9.223372036854776e18 |
| 2 | -9223372036854775808 | -9223372036854775808 | 9223372036854775808 | -9223372036854775808.000000000000000000000000000000 | -9.223372036854776e18 |
+----+----------------------+----------------------+---------------------+-----------------------------------------------------+-----------------------+
2 rows in set, 4 warnings (0.01 sec)
mysql> SELECT /*+ READ_FROM_STORAGE(TIFLASH[test_table])*/ id, col1, CAST(col1 AS SIGNED) AS signed_int, CAST(col1 AS UNSIGNED) AS unsigned_int, CAST(col1 AS DECIMAL(65,30)) AS decimal_value, CAST(col1 AS DOUBLE) AS double_value FROM
test_table;
+----+----------------------+----------------------+---------------------+-----------------------------------------------------+-----------------------+
| id | col1 | signed_int | unsigned_int | decimal_value | double_value |
+----+----------------------+----------------------+---------------------+-----------------------------------------------------+-----------------------+
| 1 | -9223372036854775809 | -9223372036854775808 | 0 | -9223372036854775809.000000000000000000000000000000 | -9.223372036854776e18 |
| 2 | -9223372036854775808 | -9223372036854775808 | 9223372036854775808 | -9223372036854775808.000000000000000000000000000000 | -9.223372036854776e18 |
+----+----------------------+----------------------+---------------------+-----------------------------------------------------+-----------------------+
2 rows in set (0.01 sec)
4. What is your TiDB version? (Required)
TiDB v8.4.0
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供されたSQL再現をTiDB v8.4.0で実行し、CAST(col1 AS UNSIGNED)に対するTIKVとTIFLASH-READ_FROM_STORAGEの結果を比較します。示されている境界値に注目しながら、2つのストレージパスでのcast処理を追跡します。両方のクエリが一貫したunsigned_int結果を生成すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- cpp, sql
- 領域
- databases
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100