RatulDawar opened a new pull request, #21631:
URL: https://github.com/apache/datafusion/pull/21631
## Summary
This PR fixes a deadlock in `HashJoinExec` that occurs when dynamic
filtering is enabled and some partitions have an empty build side.
### The Issue
When dynamic filtering is enabled, all partitions must report their
build-side data to a `SharedBuildAccumulator` and wait on a
`tokio::sync::Barrier`. However, a short-circuit optimization was causing
partitions with empty build sides to immediately transition to the `Completed`
state, skipping the reporting and the barrier. This left non-empty partitions
waiting indefinitely for the missing partitions to reach the barrier.
### The Fix
The fix ensures that if a `SharedBuildAccumulator` is present, even empty
partitions must proceed to the `WaitPartitionBoundsReport` state. This ensures
they participate in the barrier synchronization before the short-circuit to
`Completed` is allowed to happen.
## Test Plan
Reproduced the issue using TPC-H Query 18 with 24 partitions
(`DATAFUSION_EXECUTION_TARGET_PARTITIONS=24`).
- **Before fix:** The query hangs indefinitely with 0% CPU usage.
- **After fix:** The query completes successfully in ~0.1s.
```sql
-- Reproduction query (TPC-H Q18)
select
c_name,
c_custkey,
o_orderkey,
o_orderdate,
o_totalprice,
sum(l_quantity)
from
customer,
orders,
lineitem
where
o_orderkey in (
select
l_orderkey
from
lineitem
group by
l_orderkey having
sum(l_quantity) > 300
)
and c_custkey = o_custkey
and o_orderkey = l_orderkey
group by
c_name, c_custkey,
o_orderkey,
o_orderdate,
o_totalprice
order by
o_totalprice desc,
o_orderdate
limit 100;
```
Made with [Cursor](https://cursor.com)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]