[fix](fetype) Commit FE type only after transition completes - #68302
Conversation
### What problem does this PR solve?
Issue Number: N/A
Related PR: N/A
Problem Summary: A non-master FE transition can be interrupted when a newer BDB state is queued while the listener waits for metadata readiness. The listener previously still committed the target FE type even though non-master initialization, including metrics initialization, had not run. A repeated state notification was then treated as redundant, leaving the FE ready to serve with incomplete initialization. Make the transition report completion and update feType only after all initialization finishes; interrupted transitions keep the previous committed state so the queued event retries from the actual initialized state.
### Release note
Fix FE state transitions that could leave a follower or observer serving queries before non-master initialization completed.
### Check List (For Author)
- Test: Unit Test
- ./run-fe-ut.sh --run org.apache.doris.catalog.EnvStateListenerTest
- cd fe && mvn checkstyle:check -pl fe-core
- Behavior changed: Yes. Interrupted non-master transitions no longer publish an incomplete FE type.
- Does this need documentation: No
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
|
/review |
There was a problem hiding this comment.
Static review of PR 68302 at commit 6994426 found one blocking FE lifecycle issue; the inline finding below requests a readiness gate for the retained-state UNKNOWN path.
Review checkpoints:
- Goal and correctness: The repeated FOLLOWER/OBSERVER retry case is addressed, but an UNKNOWN notification can still expose an incompletely initialized non-master FE.
- Lifecycle and concurrency: The listener is synchronized and the queue/replayer paths were traced. The remaining defect is a real race between the replayer publishing readiness and the retained-state UNKNOWN no-op/equality handling.
- Locking, exceptions, persistence, compatibility, and configuration: No additional issue found; this change does not alter a protocol or persisted format.
- Parallel paths and observability: BDBStateChangeListener, startup waitForReady(), canRead-based query forwarding, and the UNKNOWN transition path were checked.
- Test coverage: The new unit test deterministically covers a repeated FOLLOWER event, but it does not cover INIT/UNKNOWN -> FOLLOWER/OBSERVER interrupted by UNKNOWN or a later retry.
- Validation status: Static-only review as required by the review prompt; no builds or tests were run.
- User focus: No additional focus points were provided.
Please address the inline issue and add the UNKNOWN interruption regression coverage before merging.
TPC-H: Total hot run time: 27861 ms |
TPC-DS: Total hot run time: 152265 ms |
ClickBench: Total hot run time: 24.05 s |
FE UT Coverage ReportIncrement line coverage |
|
Context guide for reviewers: what this PR fixes, in plain terms TL;DR: this fixes a race in the FE role state machine. When a FOLLOWER/OBSERVER transition is interrupted, the old code still marked the FE as "already FOLLOWER", so the real initialization never got a second chance and the FE stayed half-initialized until a restart. Background: how an FE changes its role
What
Step 2 has an escape hatch: if another role notification is already waiting in the queue, it returns The bug When the escape hatch fired, Next the listener processes the queued notification that caused the interruption. If it is another FOLLOWER (BDBJE can deliver the same state more than once), the listener sees Why it matters
The fix
The test
|
### What problem does this PR solve? Problem Summary: A non-master FE transition can be interrupted when a newer BDB state is queued while the listener waits for metadata readiness. The listener previously still committed the target FE type even though non-master initialization, including MetricRepo.init(), had not run. A repeated FOLLOWER or OBSERVER notification was then treated as redundant, leaving the FE in an incompletely initialized state. This change makes transferToNonMaster() report whether the transition completed and updates feType only after all initialization finishes. An interrupted transition retains the previous committed state so the queued event is evaluated against the state that was actually initialized and can retry the transition. ### Release note Fix FE state transitions that could leave a follower or observer serving queries before non-master initialization completed.
What problem does this PR solve?
Issue Number: N/A
Related PR: N/A
Problem Summary:
A non-master FE transition can be interrupted when a newer BDB state is queued while the listener waits for metadata readiness. The listener previously still committed the target FE type even though non-master initialization, including MetricRepo.init(), had not run. A repeated FOLLOWER or OBSERVER notification was then treated as redundant, leaving the FE in an incompletely initialized state.
This change makes transferToNonMaster() report whether the transition completed and updates feType only after all initialization finishes. An interrupted transition retains the previous committed state so the queued event is evaluated against the state that was actually initialized and can retry the transition.
Release note
Fix FE state transitions that could leave a follower or observer serving queries before non-master initialization completed.
Check List (For Author)