Skip to content

Conversation

@BiteTheDDDDt
Copy link
Contributor

@BiteTheDDDDt BiteTheDDDDt commented Dec 22, 2025

What problem does this PR solve?

This pull request introduces a delayed deletion mechanism for QueryContext objects in the fragment manager to ensure that runtime filter merging works correctly after a query reaches its end-of-stream (EOS). The main changes involve adding a new map to retain query contexts temporarily, modifying the lifecycle management of query contexts, and introducing utility methods to support this behavior.

Query Context Lifecycle Management:

  • Added a new member _query_ctx_map_delay_delete to FragmentMgr to keep QueryContext objects alive for a short period after query EOS, ensuring that the runtime filter coordinator can complete its work.
  • Modified FragmentMgr::remove_query_context to erase entries from _query_ctx_map_delay_delete as part of the cleanup process.
  • Updated the QueryContext destructor to call remove_query_context only if the fragment manager is available, preventing issues during unit tests.

Runtime Filter Merge Coordination:

  • In FragmentMgr::_get_or_create_query_ctx, now inserts the QueryContext into _query_ctx_map_delay_delete if the runtime filter merge handler is not empty, ensuring the context is retained for merging.
  • Added an empty() method to RuntimeFilterMergeControllerEntity to check if the filter map is empty, which is used to determine if delayed deletion is needed.

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@BiteTheDDDDt
Copy link
Contributor Author

run buildall

@hello-stephen
Copy link
Contributor

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

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@BiteTheDDDDt
Copy link
Contributor Author

run buildall

@BiteTheDDDDt
Copy link
Contributor Author

run buildall

@hello-stephen
Copy link
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (11/11) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 72.28% (25034/34637)
Line Coverage 59.00% (262697/445220)
Region Coverage 53.83% (218183/405330)
Branch Coverage 55.43% (93658/168954)

if (!handler->empty()) {
_query_ctx_map_delay_delete.insert(query_id, query_ctx);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

should also deal with the timeout logic if FE not send cancel message to BE. like the code at line 974

yiguolei
yiguolei previously approved these changes Dec 25, 2025
@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Dec 25, 2025
@github-actions
Copy link
Contributor

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

@BiteTheDDDDt BiteTheDDDDt changed the title add _query_ctx_map_delay_delete [Chore](query) add _query_ctx_map_delay_delete Dec 29, 2025
@github-actions github-actions bot removed the approved Indicates a PR has been approved by one committer. label Dec 29, 2025
@BiteTheDDDDt
Copy link
Contributor Author

run buildall

@hello-stephen
Copy link
Contributor

BE UT Coverage Report

Increment line coverage 9.09% (1/11) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 53.38% (18949/35500)
Line Coverage 39.26% (175763/447702)
Region Coverage 33.80% (135903/402126)
Branch Coverage 34.75% (58711/168971)

@hello-stephen
Copy link
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (11/11) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 72.13% (25034/34705)
Line Coverage 58.85% (262770/446510)
Region Coverage 53.72% (218254/406291)
Branch Coverage 55.27% (93698/169535)

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Jan 4, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

PR approved by at least one committer and no changes requested.

Copy link
Member

@mrhhsg mrhhsg left a comment

Choose a reason for hiding this comment

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

lgtm

@BiteTheDDDDt BiteTheDDDDt merged commit d86daef into apache:master Jan 4, 2026
30 of 32 checks passed
BiteTheDDDDt added a commit to BiteTheDDDDt/incubator-doris that referenced this pull request Jan 7, 2026
This pull request introduces a delayed deletion mechanism for
`QueryContext` objects in the fragment manager to ensure that runtime
filter merging works correctly after a query reaches its end-of-stream
(EOS). The main changes involve adding a new map to retain query
contexts temporarily, modifying the lifecycle management of query
contexts, and introducing utility methods to support this behavior.

**Query Context Lifecycle Management:**

* Added a new member `_query_ctx_map_delay_delete` to `FragmentMgr` to
keep `QueryContext` objects alive for a short period after query EOS,
ensuring that the runtime filter coordinator can complete its work.
* Modified `FragmentMgr::remove_query_context` to erase entries from
`_query_ctx_map_delay_delete` as part of the cleanup process.
* Updated the `QueryContext` destructor to call `remove_query_context`
only if the fragment manager is available, preventing issues during unit
tests.

**Runtime Filter Merge Coordination:**

* In `FragmentMgr::_get_or_create_query_ctx`, now inserts the
`QueryContext` into `_query_ctx_map_delay_delete` if the runtime filter
merge handler is not empty, ensuring the context is retained for
merging.
* Added an `empty()` method to `RuntimeFilterMergeControllerEntity` to
check if the filter map is empty, which is used to determine if delayed
deletion is needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/4.0.x dev/4.0.x-conflict reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants