# [Critical bug] 关于TiDB 5.0 MPP关键问题的通知：错误的JOIN结果

## Issue

TiDB MPP 模式上周发现了一个 critical bug，该 bug 会使跑在 MPP 模式下的 query 返回错误结果。 Bug 现象： 当 query 包含一个或多个 join 且跑在 MPP 模式下时，可能会返回错误的结果。

### 触发条件

1. 集群含有多于 1 个的 TiFlash 节点

2. MPP plan 中包含一个或多个 shuffle hash join

3. 至少有一个shuffle hash join 的 join key 满足以下三个条件: ○ 左右两边的 join key 类型是同一个 category 的(例如都是 integer) ○ 左右两边的 join key 不是 decimal 类型 ○ 左右两边的 join key 的类型不是完全一样的（例如 int8 join int64） 举例来说，对于 select count(*) from a join b on a.id = b.id, 如果 a.id 是 small int 类型, b.id 是 big int 类型, 而且 TiDB 是用了 shuffle hash join，那么该 query 的结果就是错的。

## Root Cause

在 TiFlash 中，如果两个对象的类型不一致，那么他们的 hash 值也不保证一致

## Diagnostic Steps

N/A

## Resolution

显式加 cast 来保证 join key 类型的一致性

## Workaround

N/A
