seawinde opened a new pull request, #62762:
URL: https://github.com/apache/doris/pull/62762

   ### What problem does this PR solve?
   
   Issue Number: N/A
   
   Related PR: N/A
   
   Problem Summary:
   CIR-20036 reports that FE may throw a `NullPointerException` while
   registering query instances during startup or role switch.
   
   Root cause: In `QeProcessorImpl.registerInstances()`
   (`fe/fe-core/src/main/java/org/apache/doris/qe/QeProcessorImpl.java:164`),
   query instance accounting always updates
   `MetricRepo.USER_COUNTER_QUERY_INSTANCE_BEGIN`, but `MetricRepo.init()` may
   not have completed yet, so the metric mapping is still unavailable.
   
   This PR keeps the existing query-instance accounting logic unchanged and
   only skips the metric increment until the metric repo is initialized.
   
   **Change Summary:**
   
   | File | Change Description |
   |------|-------------------|
   | `fe/fe-core/src/main/java/org/apache/doris/qe/QeProcessorImpl.java` | 
Guard `USER_COUNTER_QUERY_INSTANCE_BEGIN` update with `MetricRepo.isInit` so FE 
does not dereference an uninitialized metric during startup or role switch |
   | `fe/fe-core/src/test/java/org/apache/doris/qe/QeProcessorImplTest.java` | 
Add unit coverage for both pre-init and post-init `registerInstances()` paths |
   
   ### Release note
   
   Fixed an issue where FE could hit a `NullPointerException` when query
   instance metrics were updated before `MetricRepo` initialization completed.
   
   ### Check List (For Author)
   
   - Test
       - [ ] Regression test
       - [ ] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [x] 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.
           - [x] Other reason
   
         Added `QeProcessorImplTest`, but `./run-fe-ut.sh --run 
org.apache.doris.qe.QeProcessorImplTest`
         is currently blocked on upstream `master` by an unrelated FE
         compilation failure in `fe-core` `generate-patterns`
         (`PatternDescribableProcessor` -> `ExpressionTypeMappingGenerator`
         `NoClassDefFoundError`).
   
   - Behavior changed:
       - [x] No.
       - [ ] Yes.
   
   - Does this need documentation?
       - [x] No.
       - [ ] Yes.
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to