Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug](runtime-filter) send ignored rf when hash join build closed early #41667

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions be/src/exprs/runtime_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,10 @@ class RuntimePredicateWrapper {
const TExpr& probe_expr);

Status merge(const RuntimePredicateWrapper* wrapper) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'merge' has cognitive complexity of 74 (threshold 50) [readability-function-cognitive-complexity]

    Status merge(const RuntimePredicateWrapper* wrapper) {
           ^
Additional context

be/src/exprs/runtime_filter.cpp:474: +1, including nesting penalty of 0, nesting level increased to 1

        if (wrapper->is_ignored()) {
        ^

be/src/exprs/runtime_filter.cpp:480: +1

                _filter_type == RuntimeFilterType::IN_OR_BLOOM_FILTER &&
                                                                      ^

be/src/exprs/runtime_filter.cpp:485: +1

        bool can_not_merge_other = _filter_type != RuntimeFilterType::IN_OR_BLOOM_FILTER &&
                                                                                         ^

be/src/exprs/runtime_filter.cpp:488: +1

        CHECK(!can_not_merge_in_or_bloom && !can_not_merge_other)
                                         ^

be/src/exprs/runtime_filter.cpp:493: +1, including nesting penalty of 0, nesting level increased to 1

        switch (_filter_type) {
        ^

be/src/exprs/runtime_filter.cpp:497: +2, including nesting penalty of 1, nesting level increased to 2

            if (_max_in_num >= 0 && _context->hybrid_set->size() >= _max_in_num) {
            ^

be/src/exprs/runtime_filter.cpp:507: +2, including nesting penalty of 1, nesting level increased to 2

            RETURN_IF_ERROR(_context->minmax_func->merge(wrapper->_context->minmax_func.get()));
            ^

be/src/common/status.h:629: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/exprs/runtime_filter.cpp:507: +3, including nesting penalty of 2, nesting level increased to 3

            RETURN_IF_ERROR(_context->minmax_func->merge(wrapper->_context->minmax_func.get()));
            ^

be/src/common/status.h:631: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

be/src/exprs/runtime_filter.cpp:511: +2, including nesting penalty of 1, nesting level increased to 2

            RETURN_IF_ERROR(
            ^

be/src/common/status.h:629: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/exprs/runtime_filter.cpp:511: +3, including nesting penalty of 2, nesting level increased to 3

            RETURN_IF_ERROR(
            ^

be/src/common/status.h:631: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

be/src/exprs/runtime_filter.cpp:519: +2, including nesting penalty of 1, nesting level increased to 2

            if (other_filter_type == RuntimeFilterType::IN_OR_BLOOM_FILTER) {
            ^

be/src/exprs/runtime_filter.cpp:523: +2, including nesting penalty of 1, nesting level increased to 2

            if (real_filter_type == RuntimeFilterType::IN_FILTER) {
            ^

be/src/exprs/runtime_filter.cpp:527: +3, including nesting penalty of 2, nesting level increased to 3

                if (other_filter_type == RuntimeFilterType::IN_FILTER) {
                ^

be/src/exprs/runtime_filter.cpp:529: +4, including nesting penalty of 3, nesting level increased to 4

                    if (_max_in_num >= 0 && _context->hybrid_set->size() >= _max_in_num) {
                    ^

be/src/exprs/runtime_filter.cpp:531: +5, including nesting penalty of 4, nesting level increased to 5

                        RETURN_IF_ERROR(_context->bloom_filter_func->init_with_fixed_length());
                        ^

be/src/common/status.h:629: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/exprs/runtime_filter.cpp:531: +6, including nesting penalty of 5, nesting level increased to 6

                        RETURN_IF_ERROR(_context->bloom_filter_func->init_with_fixed_length());
                        ^

be/src/common/status.h:631: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

be/src/exprs/runtime_filter.cpp:532: +5, including nesting penalty of 4, nesting level increased to 5

                        RETURN_IF_ERROR(change_to_bloom_filter());
                        ^

be/src/common/status.h:629: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/exprs/runtime_filter.cpp:532: +6, including nesting penalty of 5, nesting level increased to 6

                        RETURN_IF_ERROR(change_to_bloom_filter());
                        ^

be/src/common/status.h:631: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

be/src/exprs/runtime_filter.cpp:534: +1, nesting level increased to 3

                } else {
                  ^

be/src/exprs/runtime_filter.cpp:537: +4, including nesting penalty of 3, nesting level increased to 4

                    RETURN_IF_ERROR(change_to_bloom_filter());
                    ^

be/src/common/status.h:629: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/exprs/runtime_filter.cpp:537: +5, including nesting penalty of 4, nesting level increased to 5

                    RETURN_IF_ERROR(change_to_bloom_filter());
                    ^

be/src/common/status.h:631: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

be/src/exprs/runtime_filter.cpp:539: +1, nesting level increased to 2

            } else {
              ^

be/src/exprs/runtime_filter.cpp:540: +3, including nesting penalty of 2, nesting level increased to 3

                if (other_filter_type == RuntimeFilterType::IN_FILTER) {
                ^

be/src/exprs/runtime_filter.cpp:543: +1, nesting level increased to 3

                } else {
                  ^

be/src/exprs/runtime_filter.cpp:545: +4, including nesting penalty of 3, nesting level increased to 4

                    RETURN_IF_ERROR(_context->bloom_filter_func->merge(
                    ^

be/src/common/status.h:629: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/exprs/runtime_filter.cpp:545: +5, including nesting penalty of 4, nesting level increased to 5

                    RETURN_IF_ERROR(_context->bloom_filter_func->merge(
                    ^

be/src/common/status.h:631: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

if (is_ignored() || wrapper->is_ignored()) {
_context->ignored = true;
if (wrapper->is_ignored()) {
return Status::OK();
}
_context->ignored = false;

bool can_not_merge_in_or_bloom =
_filter_type == RuntimeFilterType::IN_OR_BLOOM_FILTER &&
Expand Down
12 changes: 8 additions & 4 deletions be/src/exprs/runtime_filter_slots.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,16 @@ class VRuntimeFilterSlots {
return Status::OK();
}

Status ignore_all_filters() {
for (auto filter : _runtime_filters) {
filter->set_ignored();
}
return Status::OK();
}

Status init_filters(RuntimeState* state, uint64_t local_hash_table_size) {
// process IN_OR_BLOOM_FILTER's real type
for (auto filter : _runtime_filters) {
if (filter->get_ignored()) {
continue;
}
if (filter->type() == RuntimeFilterType::IN_OR_BLOOM_FILTER &&
get_real_size(filter.get(), local_hash_table_size) >
state->runtime_filter_max_in_num()) {
Expand Down Expand Up @@ -141,7 +145,7 @@ class VRuntimeFilterSlots {
}

// publish runtime filter
Status publish(bool publish_local = false) {
Status publish(bool publish_local) {
for (auto& pair : _runtime_filters_map) {
for (auto& filter : pair.second) {
RETURN_IF_ERROR(filter->publish(publish_local));
Expand Down
32 changes: 20 additions & 12 deletions be/src/pipeline/exec/hashjoin_build_sink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,28 @@ Status HashJoinBuildSinkLocalState::close(RuntimeState* state, Status exec_statu
if (!_runtime_filter_slots || _runtime_filters.empty() || state->is_cancelled()) {
return Base::close(state, exec_status);
}
auto* block = _shared_state->build_block.get();
uint64_t hash_table_size = block ? block->rows() : 0;
{
SCOPED_TIMER(_runtime_filter_init_timer);
if (_should_build_hash_table) {
RETURN_IF_ERROR(_runtime_filter_slots->init_filters(state, hash_table_size));

if (!_eos) {
if (p._shared_hashtable_controller) {
_runtime_filter_slots->copy_to_shared_context(p._shared_hash_table_context);
}
RETURN_IF_ERROR(_runtime_filter_slots->send_filter_size(state, 0, _finish_dependency));
RETURN_IF_ERROR(_runtime_filter_slots->ignore_all_filters());
} else {
auto* block = _shared_state->build_block.get();
uint64_t hash_table_size = block ? block->rows() : 0;
{
SCOPED_TIMER(_runtime_filter_init_timer);
if (_should_build_hash_table) {
RETURN_IF_ERROR(_runtime_filter_slots->init_filters(state, hash_table_size));
}
RETURN_IF_ERROR(_runtime_filter_slots->ignore_filters(state));
}
if (_should_build_hash_table && hash_table_size > 1) {
SCOPED_TIMER(_runtime_filter_compute_timer);
_runtime_filter_slots->insert(block);
}
RETURN_IF_ERROR(_runtime_filter_slots->ignore_filters(state));
}
if (_should_build_hash_table && hash_table_size > 1) {
SCOPED_TIMER(_runtime_filter_compute_timer);
_runtime_filter_slots->insert(block);
}

SCOPED_TIMER(_publish_runtime_filter_timer);
RETURN_IF_ERROR(_runtime_filter_slots->publish(!_should_build_hash_table));
return Base::close(state, exec_status);
Expand Down
3 changes: 3 additions & 0 deletions be/src/runtime/runtime_filter_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ Status RuntimeFilterMgr::register_local_merge_producer_filter(
RETURN_IF_ERROR(IRuntimeFilter::create(_state, &desc, &options,
RuntimeFilterRole::PRODUCER, -1, &merge_filter,
build_bf_exactly, true));
merge_filter->set_ignored();
iter->second.filters.emplace_back(merge_filter);
}
iter->second.merge_time++;
Expand Down Expand Up @@ -234,6 +235,7 @@ Status RuntimeFilterMergeControllerEntity::_init_with_desc(
auto filter_id = runtime_filter_desc->filter_id;
RETURN_IF_ERROR(cnt_val->filter->init_with_desc(&cnt_val->runtime_filter_desc, query_options,
-1, false));
cnt_val->filter->set_ignored();
_filter_map.emplace(filter_id, cnt_val);
return Status::OK();
}
Expand All @@ -252,6 +254,7 @@ Status RuntimeFilterMergeControllerEntity::_init_with_desc(
cnt_val->filter = cnt_val->pool->add(new IRuntimeFilter(_state, runtime_filter_desc));
auto filter_id = runtime_filter_desc->filter_id;
RETURN_IF_ERROR(cnt_val->filter->init_with_desc(&cnt_val->runtime_filter_desc, query_options));
cnt_val->filter->set_ignored();

std::unique_lock<std::shared_mutex> guard(_filter_map_mutex);
_filter_map.emplace(filter_id, cnt_val);
Expand Down
Loading