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

[opt](spill) handle oom exception in spill tasks (#35025) #35171

Merged
merged 1 commit into from
Jul 15, 2024

Conversation

mrhhsg
Copy link
Member

@mrhhsg mrhhsg commented May 22, 2024

Proposed changes

pick #35025

Further comments

If this is a relatively large or complex change, kick off the discussion at [email protected] by explaining why you chose the solution you did and what alternatives you considered, etc...

@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

@mrhhsg
Copy link
Member Author

mrhhsg commented May 22, 2024

run buildall

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

_spill_write_wait_io_timer);
}

Status PartitionedHashJoinProbeLocalState::spill_probe_blocks(RuntimeState* state) {
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 'spill_probe_blocks' has cognitive complexity of 59 (threshold 50) [readability-function-cognitive-complexity]

Status PartitionedHashJoinProbeLocalState::spill_probe_blocks(RuntimeState* state) {
                                           ^
Additional context

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:169: nesting level increased to 1

    auto spill_func = [query_id, state, submit_timer, this] {
                      ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:174: +2, including nesting penalty of 1, nesting level increased to 2

        for (uint32_t partition_index = 0; partition_index != p._partition_count;
        ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:178: +3, including nesting penalty of 2, nesting level increased to 3

            if (partitioned_block && partitioned_block->allocated_bytes() >=
            ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:178: +1

            if (partitioned_block && partitioned_block->allocated_bytes() >=
                                  ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:185: +3, including nesting penalty of 2, nesting level increased to 3

            if (!spilling_stream) {
            ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:186: +4, including nesting penalty of 3, nesting level increased to 4

                RETURN_IF_ERROR(ExecEnv::GetInstance()->spill_stream_mgr()->register_spill_stream(
                ^

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

    do {                                \
    ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:186: +5, including nesting penalty of 4, nesting level increased to 5

                RETURN_IF_ERROR(ExecEnv::GetInstance()->spill_stream_mgr()->register_spill_stream(
                ^

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

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

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:190: +4, including nesting penalty of 3, nesting level increased to 4

                RETURN_IF_ERROR(spilling_stream->prepare_spill());
                ^

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

    do {                                \
    ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:190: +5, including nesting penalty of 4, nesting level increased to 5

                RETURN_IF_ERROR(spilling_stream->prepare_spill());
                ^

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

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

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:197: +3, including nesting penalty of 2, nesting level increased to 3

            while (!blocks.empty() && !state->is_cancelled()) {
            ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:197: +1

            while (!blocks.empty() && !state->is_cancelled()) {
                                   ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:200: +4, including nesting penalty of 3, nesting level increased to 4

                RETURN_IF_ERROR(spilling_stream->spill_block(state, block, false));
                ^

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

    do {                                \
    ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:200: +5, including nesting penalty of 4, nesting level increased to 5

                RETURN_IF_ERROR(spilling_stream->spill_block(state, block, false));
                ^

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

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

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:211: nesting level increased to 1

    auto exception_catch_func = [query_id, mem_tracker, shared_state_holder, execution_context,
                                ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:216: +2, including nesting penalty of 1, nesting level increased to 2

        if (shared_state_sptr) {
        ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:219: +2, including nesting penalty of 1, nesting level increased to 2

        if (!shared_state_sptr || !execution_context_lock) {
        ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:219: +1

        if (!shared_state_sptr || !execution_context_lock) {
                               ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:225: nesting level increased to 2

        auto status = [&]() { RETURN_IF_CATCH_EXCEPTION({ return spill_func(); }); }();
                      ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:225: +3, including nesting penalty of 2, nesting level increased to 3

        auto status = [&]() { RETURN_IF_CATCH_EXCEPTION({ return spill_func(); }); }();
                              ^

be/src/common/exception.h:89: expanded from macro 'RETURN_IF_CATCH_EXCEPTION'

    do {                                                                                         \
    ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:225: +4, including nesting penalty of 3, nesting level increased to 4

        auto status = [&]() { RETURN_IF_CATCH_EXCEPTION({ return spill_func(); }); }();
                              ^

be/src/common/exception.h:94: expanded from macro 'RETURN_IF_CATCH_EXCEPTION'

        } catch (const doris::Exception& e) {                                                    \
          ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:225: +5, including nesting penalty of 4, nesting level increased to 5

        auto status = [&]() { RETURN_IF_CATCH_EXCEPTION({ return spill_func(); }); }();
                              ^

be/src/common/exception.h:95: expanded from macro 'RETURN_IF_CATCH_EXCEPTION'

            if (e.code() == doris::ErrorCode::MEM_ALLOC_FAILED) {                                \
            ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:227: +2, including nesting penalty of 1, nesting level increased to 2

        if (!status.ok()) {
        ^

_spill_write_wait_io_timer);
}

Status PartitionedHashJoinProbeLocalState::spill_probe_blocks(RuntimeState* state) {
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 'spill_probe_blocks' exceeds recommended size/complexity thresholds [readability-function-size]

Status PartitionedHashJoinProbeLocalState::spill_probe_blocks(RuntimeState* state) {
                                           ^
Additional context

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:155: 81 lines including whitespace and comments (threshold 80)

Status PartitionedHashJoinProbeLocalState::spill_probe_blocks(RuntimeState* state) {
                                           ^

@mrhhsg
Copy link
Member Author

mrhhsg commented May 22, 2024

run buildall

2 similar comments
@mrhhsg
Copy link
Member Author

mrhhsg commented May 23, 2024

run buildall

@mrhhsg
Copy link
Member Author

mrhhsg commented May 24, 2024

run buildall

@mrhhsg
Copy link
Member Author

mrhhsg commented May 31, 2024

run buildall

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

_spill_write_wait_io_timer);
}

Status PartitionedHashJoinProbeLocalState::spill_probe_blocks(RuntimeState* state) {
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 'spill_probe_blocks' has cognitive complexity of 59 (threshold 50) [readability-function-cognitive-complexity]

Status PartitionedHashJoinProbeLocalState::spill_probe_blocks(RuntimeState* state) {
                                           ^
Additional context

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:169: nesting level increased to 1

    auto spill_func = [query_id, state, submit_timer, this] {
                      ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:174: +2, including nesting penalty of 1, nesting level increased to 2

        for (uint32_t partition_index = 0; partition_index != p._partition_count;
        ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:178: +3, including nesting penalty of 2, nesting level increased to 3

            if (partitioned_block && partitioned_block->allocated_bytes() >=
            ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:178: +1

            if (partitioned_block && partitioned_block->allocated_bytes() >=
                                  ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:185: +3, including nesting penalty of 2, nesting level increased to 3

            if (!spilling_stream) {
            ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:186: +4, including nesting penalty of 3, nesting level increased to 4

                RETURN_IF_ERROR(ExecEnv::GetInstance()->spill_stream_mgr()->register_spill_stream(
                ^

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

    do {                                \
    ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:186: +5, including nesting penalty of 4, nesting level increased to 5

                RETURN_IF_ERROR(ExecEnv::GetInstance()->spill_stream_mgr()->register_spill_stream(
                ^

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

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

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:190: +4, including nesting penalty of 3, nesting level increased to 4

                RETURN_IF_ERROR(spilling_stream->prepare_spill());
                ^

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

    do {                                \
    ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:190: +5, including nesting penalty of 4, nesting level increased to 5

                RETURN_IF_ERROR(spilling_stream->prepare_spill());
                ^

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

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

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:197: +3, including nesting penalty of 2, nesting level increased to 3

            while (!blocks.empty() && !state->is_cancelled()) {
            ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:197: +1

            while (!blocks.empty() && !state->is_cancelled()) {
                                   ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:200: +4, including nesting penalty of 3, nesting level increased to 4

                RETURN_IF_ERROR(spilling_stream->spill_block(state, block, false));
                ^

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

    do {                                \
    ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:200: +5, including nesting penalty of 4, nesting level increased to 5

                RETURN_IF_ERROR(spilling_stream->spill_block(state, block, false));
                ^

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

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

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:211: nesting level increased to 1

    auto exception_catch_func = [query_id, mem_tracker, shared_state_holder, execution_context,
                                ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:216: +2, including nesting penalty of 1, nesting level increased to 2

        if (shared_state_sptr) {
        ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:219: +2, including nesting penalty of 1, nesting level increased to 2

        if (!shared_state_sptr || !execution_context_lock) {
        ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:219: +1

        if (!shared_state_sptr || !execution_context_lock) {
                               ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:225: nesting level increased to 2

        auto status = [&]() { RETURN_IF_CATCH_EXCEPTION({ return spill_func(); }); }();
                      ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:225: +3, including nesting penalty of 2, nesting level increased to 3

        auto status = [&]() { RETURN_IF_CATCH_EXCEPTION({ return spill_func(); }); }();
                              ^

be/src/common/exception.h:89: expanded from macro 'RETURN_IF_CATCH_EXCEPTION'

    do {                                                                                         \
    ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:225: +4, including nesting penalty of 3, nesting level increased to 4

        auto status = [&]() { RETURN_IF_CATCH_EXCEPTION({ return spill_func(); }); }();
                              ^

be/src/common/exception.h:94: expanded from macro 'RETURN_IF_CATCH_EXCEPTION'

        } catch (const doris::Exception& e) {                                                    \
          ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:225: +5, including nesting penalty of 4, nesting level increased to 5

        auto status = [&]() { RETURN_IF_CATCH_EXCEPTION({ return spill_func(); }); }();
                              ^

be/src/common/exception.h:95: expanded from macro 'RETURN_IF_CATCH_EXCEPTION'

            if (e.code() == doris::ErrorCode::MEM_ALLOC_FAILED) {                                \
            ^

be/src/pipeline/exec/partitioned_hash_join_probe_operator.cpp:227: +2, including nesting penalty of 1, nesting level increased to 2

        if (!status.ok()) {
        ^

@mrhhsg
Copy link
Member Author

mrhhsg commented Jun 2, 2024

run buildall

@mrhhsg
Copy link
Member Author

mrhhsg commented Jun 6, 2024

run buildall

@mrhhsg
Copy link
Member Author

mrhhsg commented Jun 17, 2024

run buildall

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 36.28% (9132/25169)
Line Coverage: 27.78% (74257/267309)
Region Coverage: 26.71% (38319/143467)
Branch Coverage: 23.41% (19412/82926)
Coverage Report: http://coverage.selectdb-in.cc/coverage/feaf7b2bd96b84390e1eddfda4900ab526319f2f_feaf7b2bd96b84390e1eddfda4900ab526319f2f/report/index.html

@mrhhsg mrhhsg merged commit 351ba4a into apache:branch-2.1 Jul 15, 2024
19 of 21 checks passed
@mrhhsg mrhhsg deleted the pick_35025 branch July 15, 2024 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants