[fix](be) Fix exchange receiver dependency race#62777
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
/review |
There was a problem hiding this comment.
No blocking findings in the reviewed changes.
Critical Checkpoints
- Goal and correctness: The PR fixes the lost ready-notification window between receiver registration and
set_dependency().SenderQueue::set_dependency()now rechecks queue and EOS state under_lock, and the two added unit tests cover both "data before dependency" and "EOS before dependency". I found no remaining correctness issue in the modified flow. - Scope: The change is small and focused to the receiver readiness race, the sink buffer mutex protection, and targeted tests.
- Concurrency: The modified receiver path now uses
SenderQueue::_lockconsistently for_source_dependency,_block_queue,_num_remaining_senders, and_is_cancelledwhen deciding readiness. The sink buffer now readsrpc_channel_is_turn_offunderinstance_data.mutex, removing an unsynchronized access. I found no new lock-order or deadlock issue. - Lifecycle: No new special lifecycle or static-initialization risk. The existing create-and-register ordering window in
VDataStreamMgris the race being fixed. - Config and compatibility: No new config, protocol, symbol, or storage compatibility concern.
- Parallel paths: I checked analogous dependency-based queue code and did not find another path with the same externally visible registration race in this PR scope.
- Conditions and comments: The new recheck in
set_dependency()is documented and matches the actual race window. - Test coverage: The new BE unit tests are appropriate for the receiver race. There is no dedicated test for the sink-buffer mutex move, but I did not find a behavioral regression there. I attempted to run
./run-be-ut.sh --run --filter=DataStreamRecvrTest.TestEosBeforeSetDependency:DataStreamRecvrTest.TestDataBeforeSetDependencyWithRemainingSendersin this runner, but the build failed before compilation becausethirdparty/installed/bin/protocis missing. - Observability: The added teardown log is acceptable and does not hide failures.
- Transactions, persistence, data writes, and FE-to-BE variable passing: Not applicable.
- Performance: No meaningful regression; the added locking work is negligible.
User Focus
- No additional user-provided review focus was supplied.
|
run buildall |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
Issue Number: None
Related PR: None
Problem Summary: Data or EOS could arrive after the receiver is registered but before its source dependency is installed. In that window, ready notification was lost and the exchange source could remain blocked. Recheck the queue state when setting the dependency and protect channel turn-off checks with the instance mutex.
Fix a potential query hang caused by an exchange receiver dependency ready-notification race.
- Test: Unit Test / Manual test
- Unit Test: ./run-be-ut.sh --run --filter=DataStreamRecvrTest.TestEosBeforeSetDependency:DataStreamRecvrTest.TestDataBeforeSetDependencyWithRemainingSenders
- Manual test: build-support/check-format.sh
- Static analysis attempted: build-support/run-clang-tidy.sh --build-dir be/ut_build_ASAN failed because clang-tidy could not analyze the files due to environment/pre-existing diagnostics, including missing stddef.h from system/libstdc++ headers and an existing unmatched NOLINTEND in be/src/core/types.h
- Behavior changed: Yes. Exchange source dependencies are now marked ready if queued data or EOS arrived before set_dependency().
- Does this need documentation: No
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
|
run buildall |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
### What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary: Data or EOS could arrive after the receiver is
registered but before its source dependency is installed. In that
window, ready notification was lost and the exchange source could remain
blocked. Recheck the queue state when setting the dependency and protect
channel turn-off checks with the instance mutex.
### Release note
Fix a potential query hang caused by an exchange receiver dependency
ready-notification race.
### Check List (For Author)
- Test: Unit Test / Manual test
- Unit Test: ./run-be-ut.sh --run
--filter=DataStreamRecvrTest.TestEosBeforeSetDependency:DataStreamRecvrTest.TestDataBeforeSetDependencyWithRemainingSenders
- Manual test: build-support/check-format.sh
- Static analysis attempted: build-support/run-clang-tidy.sh --build-dir
be/ut_build_ASAN failed because clang-tidy could not analyze the files
due to environment/pre-existing diagnostics, including missing stddef.h
from system/libstdc++ headers and an existing unmatched NOLINTEND in
be/src/core/types.h
- Behavior changed: Yes. Exchange source dependencies are now marked
ready if queued data or EOS arrived before set_dependency().
- Does this need documentation: No
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] 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 <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
apache/doris-website#1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary: Data or EOS could arrive after the receiver is registered but before its source dependency is installed. In that window, ready notification was lost and the exchange source could remain blocked. Recheck the queue state when setting the dependency and protect channel turn-off checks with the instance mutex.
Release note
Fix a potential query hang caused by an exchange receiver dependency ready-notification race.
Check List (For Author)
What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)