Commit c9e6e79
[fix](runtime-filter) Fix race condition in Set operator runtime filter processing (#62434)
This pull request addresses a race condition in the Set operator
(`INTERSECT`/`EXCEPT`) when using the `IN_FILTER` runtime filter type.
The main fix ensures that the hash table size used for runtime filter
processing is captured before the probe side can modify the hash table,
preventing errors during query execution. Additionally, regression tests
are added to verify the fix and prevent future regressions.
**Fixes for race condition in Set operator:**
* The hash table size is now snapshotted in
`SetSinkOperatorX<is_intersect>::sink()` before enabling the probe
pipeline, and this saved value is used for runtime filter processing in
`SetSinkLocalState<is_intersect>::close()`. This prevents the probe side
from shrinking the hash table before the runtime filter is processed,
avoiding possible `InternalError` failures.
[[1]](diffhunk://#diff-7658815d4a9a8268b4ef4ad00a93998af07a421b538ad608e3f3a0e20ef805cdR103-R107)
[[2]](diffhunk://#diff-7658815d4a9a8268b4ef4ad00a93998af07a421b538ad608e3f3a0e20ef805cdL48-R47)
[[3]](diffhunk://#diff-1a8671c9fbc97801353bffeffe99e2189a16d275d3f865714e2cc6750ee8c54fR65-R68)
* Added a new member variable `_build_hash_table_size` to
`SetSinkLocalState` to store the snapshotted hash table size.
**Testing and regression coverage:**
* Added a new regression test suite `set_operator_in_filter.groovy` and
its output file to reproduce and verify the race condition, ensuring the
fix is tested for both `INTERSECT` and `EXCEPT` queries with `IN_FILTER`
type and small `max_in_num`.
[[1]](diffhunk://#diff-2ff8fca2d88b291375196153f6f9377e6a0d80a2b8222d63ef67d2dc307cb332R1-R144)
[[2]](diffhunk://#diff-795c4c2d53c199ee4187b5aef698e62a6c993d2aad99014063c0c3540553caf3R1-R23)
**Code cleanup:**
* Removed unnecessary `#include "common/compile_check_begin.h"` and
`#include "common/compile_check_end.h"` lines from several files for
better code clarity.
[[1]](diffhunk://#diff-7658815d4a9a8268b4ef4ad00a93998af07a421b538ad608e3f3a0e20ef805cdL27)
[[2]](diffhunk://#diff-90e895f6474975cbb1d9b2fc276bc6d9e1a22675f5126b836fb83c13fd148eb5L31)
[[3]](diffhunk://#diff-90e895f6474975cbb1d9b2fc276bc6d9e1a22675f5126b836fb83c13fd148eb5L57)
[[4]](diffhunk://#diff-a8e4192eb0bf59708c56d0a59c46f601684a554628105f70c50211784a1c5271L26)
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent c491c8a commit c9e6e79
File tree
4 files changed
+172
-1
lines changed- be/src/exec/operator
- regression-test
- data/query_p0/runtime_filter
- suites/query_p0/runtime_filter
4 files changed
+172
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
103 | 108 | | |
104 | 109 | | |
105 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
63 | 68 | | |
64 | 69 | | |
65 | 70 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
Lines changed: 138 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
0 commit comments