Aggregation spill may stuck in infinite loop if an empty hash table is marked to spill #8905
Labels
affects-7.4
affects-7.5
This bug affects the 7.5.x(LTS) versions.
affects-8.0
component/compute
severity/major
type/bug
The issue is confirmed as a bug.
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
Step 1
In
tiflash/dbms/src/Interpreters/AggSpillContext.cpp
Lines 94 to 139 in 9970e49
Even if
per_thread_revocable_memories[index]
is 0(which mean the hash table is empty), it will be marked asNEED_AUTO_SPILL
Step 2
In
tiflash/dbms/src/Operators/AggregateBuildSinkOp.cpp
Lines 20 to 29 in 9970e49
If there is no local data to build, it will first check
isTaskMarkedForSpill
Step 3
In
tiflash/dbms/src/Operators/AggregateContext.cpp
Lines 57 to 66 in 9970e49
isTaskMarkedForSpill
will callupdatePerThreadRevocableMemory
Step 4
In
tiflash/dbms/src/Interpreters/AggSpillContext.cpp
Lines 50 to 73 in 9970e49
It will use cas to change
per_thread_auto_spill_status[thread_num]
toWAIT_SPILL_FINISH
and returntrue
Step 5
In
tiflash/dbms/src/Interpreters/Aggregator.cpp
Lines 71 to 75 in 9970e49
If current hash table is empty, it will return
false
, which means no need to spillStep 6
After the above 5 steps, now aggregation is expected to be in spill status from the view of
AggregationSpillContext
, but it actually is not in spill state from the view ofAggregator
, inAggregator::executeOnBlock
, it will throwResizeException
but can not trigger spill becauseupdatePerThreadRevocableMemory
never returns true, so there is no change to calltryMarkNeedSpill
. ButAggregator::executeOnBlock
never aggregate data because once it need to resize hash table, it will meetResizeException
2. What did you expect to see? (Required)
3. What did you see instead (Required)
4. What is your TiFlash version? (Required)
The text was updated successfully, but these errors were encountered: