pingcap / pingcap/tidb

Undeterministic result of deterministic query

Open
#65,387 2 comments 0 reactions 1 assignee Claimed by @fixdb View on GitHub
affects-8.5 contribution severity/major sig/planner type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

Hi, in the following test case, the SELECT query should return a deterministic result; however, when I run this test case 10 times. 5 of them return an empty result, and 5 of them return 1 row.

```
CREATE TABLE t0(c0 FLOAT);
CREATE TABLE t1 LIKE t0;
REPLACE INTO t1 VALUES (0.26201291039277286);
INSERT IGNORE INTO t0(c0) VALUES (0.47821491788303083);
ALTER TABLE t0 MODIFY c0 TEXT;
UPDATE t1 SET c0=(CASE -518779582 WHEN INSERT(((t1.c0)OR(((t1.c0) IS NULL))), true, FORMAT(DEFAULT(t1.c0), t1.c0), t1.c0) THEN '(ymlif\r' ELSE ((t1.c0)>=(t1.c0)) END );
ALTER TABLE t1 MODIFY c0 DECIMAL;
REPLACE INTO t1(c0) VALUES (-1539818217), (1719485563), (-384323401);
INSERT INTO t0 VALUES ('1+[Sic') ON DUPLICATE KEY UPDATE c0=-350963399;
SELECT t0.c0 FROM t0 NATURAL RIGHT JOIN t1 GROUP BY NULL HAVING t0.c0;
```

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

The SELECT query should always return the same result.

### 3. What did you see instead (Required)

The SELECT query returns different results.

### 4. What is your TiDB version? (Required)

Release Version: v9.0.0-beta.2.pre-551-g71caddf56d\nEdition: Community\nGit Commit Hash: 71caddf56d9c1887650568101590417558149e3f\nGit Branch: master\nUTC Build Time: 2025-10-11 06:46:47\nGoVersion: go1.23.12\nRace Enabled: false\nCheck Table Before Drop: false\nStore: unistore\nKernel Type: Classic

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.