raoluSmile opened a new pull request, #3431:
URL: https://github.com/apache/fluss/pull/3431

     ## What is the purpose of the change
   
     This PR fixes a `NullPointerException` in
     `CoordinatorEventProcessor.processTableRegistrationChange`.
   
     When processing a `TableRegistrationChangeEvent`, the coordinator needs 
the old
     `TableInfo` to get the current schema info and build the new `TableInfo`.
     However, the old `TableInfo` may be unavailable if the event is stale or 
the
     coordinator context is incomplete.
   
     The previous code only checked whether `tableId` was `null`, but
     `CoordinatorContext#getTableIdByPath` returns `TableInfo.UNKNOWN_TABLE_ID` 
when
     the table path is not found. As a result, an unknown table could still 
continue
     to `getTableInfoById`, get `null`, and fail at 
`oldTableInfo.getSchemaInfo()`.
   
     ## Brief change log
   
     - Treat `TableInfo.UNKNOWN_TABLE_ID` as an unregistered table when 
processing
       table registration change events.
     - Skip table registration change events if the old `TableInfo` is not 
available
       in `CoordinatorContext`.
     - Add regression tests for stale/incomplete coordinator context states.
   
     ## Tests
   
     Added two regression tests in `CoordinatorEventProcessorTest`:
   
     - `testTableRegistrationChangeWithUnknownTable`
   
       Covers the case where a table registration change event is processed 
after the
       table path is no longer present in `CoordinatorContext`.
   
       `CoordinatorContext#getTableIdByPath` returns 
`TableInfo.UNKNOWN_TABLE_ID`
       for this case. The previous `tableId == null` check did not catch it, so 
the
       processor continued and eventually dereferenced a null `oldTableInfo`.
   
     - `testTableRegistrationChangeWithMissingTableInfo`
   
       Covers the case where the table path to table id mapping exists, but the
       corresponding `TableInfo` is not available in `CoordinatorContext`.
   
       This represents an incomplete coordinator context state. Since
       `TableRegistration#toTableInfo` needs the old schema info, the event 
cannot be
       applied safely without the old `TableInfo`.
   
     Before this fix, both tests failed with an NPE at
     `oldTableInfo.getSchemaInfo()`. After this fix, the stale/incomplete 
events are
     skipped safely.
   
     ```bash
     ./mvnw -pl fluss-server -am \
       
-Dtest=CoordinatorEventProcessorTest#testTableRegistrationChangeWithUnknownTable+testTableRegistrationChangeWithMissingTableInfo
 \
       -DfailIfNoTests=false test
   
     Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
     BUILD SUCCESS


-- 
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]

Reply via email to