BiteTheDDDDt opened a new pull request, #62434: URL: https://github.com/apache/doris/pull/62434
## Proposed changes Fix a race condition in Set operator (INTERSECT/EXCEPT) runtime filter processing that causes `RuntimeFilterWrapper::insert()` to fail with `Status::InternalError` when using pure `IN_FILTER` type with a small `runtime_filter_max_in_num`. ### Root Cause In the original code, RF processing happens in `close()` after `set_ready()` has already enabled the probe pipeline. For INTERSECT, the probe side can shrink the hash table via `_refresh_hash_table()` in this window. When `close()` later reads `get_hash_table_size()`, it gets the shrunk size, causing `RuntimeFilterWrapper::init()` to under-estimate cardinality. This breaks the invariant `unique_column_values <= hash_table_size <= max_in_num`, and `insert()` detects the overflow. The race window (between `set_ready()` and `get_hash_table_size()` in `close()`) spans closing all source operators, function returns, and Defer blocks — microseconds to milliseconds. ### Fix Move RF `process()` from `close()` to `sink(eos)` **before** `set_ready()`, ensuring the hash table size is read before the probe side can modify it. This is safe because Set operators do not override `finishdependency()`, so the pipeline task does not wait for `synced_filter_size` before closing — processing before `send_filter_size()` is equivalent to processing after it (both use local size). ### Changes 1. **`set_sink_operator.cpp`**: Move RF `process()` from `close()` to `sink(eos)` before `set_ready()` 2. **`runtime_filter_producer_helper_set.h`**: Add validation that Set operator RF descs have `is_broadcast_join=false` 3. **`runtime_filter_wrapper.cpp`**: Add comment explaining why `insert()` reports InternalError (indicates caller bug) 4. **Regression test**: `set_operator_in_filter.groovy` covering INTERSECT/EXCEPT with IN_FILTER type and small `max_in_num` ### How was this bug hidden for ~1 year? Five protection layers make this nearly unreachable under normal conditions: - Default `runtime_filter_type = 12` = `IN_OR_BLOOM | MIN_MAX`, not pure `IN_FILTER` - `IN_OR_BLOOM_FILTER` uses a different code path without size checks - Mathematical invariant: `unique_column_values <= hash_table_size <= max_in_num` holds under sequential execution - Only fuzzy testing randomizes: 25% chance pure `IN_FILTER`, 25% chance `max_in_num=10` - The race window requires INTERSECT probe to complete and shrink the hash table in microseconds -- 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]
