[server] Fix NPE when processing table registration change#3431
Open
raoluSmile wants to merge 2 commits into
Open
[server] Fix NPE when processing table registration change#3431raoluSmile wants to merge 2 commits into
raoluSmile wants to merge 2 commits into
Conversation
Skip stale or incomplete table registration change events when the table path is unknown or the old TableInfo is missing from the coordinator context. Add regression tests for unknown tables and missing table info to cover the previous oldTableInfo.getSchemaInfo() NPE.
Contributor
loserwang1024
left a comment
There was a problem hiding this comment.
Thanks for your pr, I have left some comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
This PR fixes a
NullPointerExceptioninCoordinatorEventProcessor.processTableRegistrationChange.When processing a
TableRegistrationChangeEvent, the coordinator needs the oldTableInfoto get the current schema info and build the newTableInfo.However, the old
TableInfomay be unavailable if the event is stale or thecoordinator context is incomplete.
The previous code only checked whether
tableIdwasnull, butCoordinatorContext#getTableIdByPathreturnsTableInfo.UNKNOWN_TABLE_IDwhenthe table path is not found. As a result, an unknown table could still continue
to
getTableInfoById, getnull, and fail atoldTableInfo.getSchemaInfo().Brief change log
TableInfo.UNKNOWN_TABLE_IDas an unregistered table when processingtable registration change events.
TableInfois not availablein
CoordinatorContext.Tests
Added two regression tests in
CoordinatorEventProcessorTest:testTableRegistrationChangeWithUnknownTableCovers the case where a table registration change event is processed after the
table path is no longer present in
CoordinatorContext.CoordinatorContext#getTableIdByPathreturnsTableInfo.UNKNOWN_TABLE_IDfor this case. The previous
tableId == nullcheck did not catch it, so theprocessor continued and eventually dereferenced a null
oldTableInfo.testTableRegistrationChangeWithMissingTableInfoCovers the case where the table path to table id mapping exists, but the
corresponding
TableInfois not available inCoordinatorContext.This represents an incomplete coordinator context state. Since
TableRegistration#toTableInfoneeds the old schema info, the event cannot beapplied safely without the old
TableInfo.Before this fix, both tests failed with an NPE at
oldTableInfo.getSchemaInfo(). After this fix, the stale/incomplete events areskipped safely.
./mvnw -pl fluss-server -am \ -Dtest=CoordinatorEventProcessorTest#testTableRegistrationChangeWithUnknownTable+testTableRegistrationChangeWithMissingTableInfo \ -DfailIfNoTests=false test Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 BUILD SUCCESS