Repository navigation
fix(admin): keep persisted instance state when local heartbeat is missing (#7697) - #7863
Merged
Merged
Conversation
…sing (apache#7697) The instance list merged persisted rows with the node-local heartbeat cache and dereferenced a missing entry. Followers do not run InstanceCheckService.setup() and are not covered by the /instance/** forward list, so the whole page failed with an NPE. Keep the persisted state when the local entry is absent, and fall back to dateUpdated when lastHeartBeatTime has not been persisted yet.
imDwAaY
force-pushed
the
fix/7697-instance-list-null-beat
branch
from
October 19, 2026 15:19
c083625 to
4d50fb4
Compare
Aias00
approved these changes
Oct 20, 2026
Aias00
left a comment
Contributor
There was a problem hiding this comment.
Review: #7863 fix(admin): keep persisted instance state when local heartbeat is missing
Reviewed the change and the added test.
What's good
- The NPE guard in
InstanceController#queryPluginscorrectly falls back tovo.getDateUpdated()whengetInstanceHealthBeatInforeturnsnull. This keeps the persisted plugin/instance state from losing itslastHeartBeatTimejust because the local heartbeat record is momentarily missing. testQueryPluginsWithMissingHealthBeatInfocovers the new null path, asserting the persisteddateUpdatedis used.
Non-blocking suggestions
- Confirm whether sibling controllers that also call
getInstanceHealthBeatInfo(or other paths that read instance health) can receivenulland would benefit from the same fallback, so the behavior is consistent across the admin UI. - Minor: the fallback mixes two different time sources (heartbeat vs. entity update time); worth a one-line comment in the code explaining the precedence so future readers don't assume they are equivalent.
CI
Green. No failures.
Verdict
APPROVE — focused, low-risk fix with test coverage.
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.
Fixes #7697.
Problem
GET /instanceloads the persistedinstance_inforows, then overrides each row with the node-localInstanceCheckServiceheartbeat cache. The lookup result is dereferenced without a null check.InstanceCheckService.setup()(which callsfetchInstanceData()and fills the cache) only runs on the elected master, and/instance/**is not in the clusterforward-list. A follower therefore serves the list with an empty local cache and every row throws aNullPointerException, failing the whole page with a 500.The same window exists on the master for rows persisted by another Admin writer or inserted after the local snapshot.
Change
instanceStateanddateUpdatedinstead of failing. No freshONLINEstate is fabricated.last_heart_beat_timeis not persisted in this branch, so the DB-mappedlastHeartBeatTimeis0. When it is non-positive, fall back todateUpdated.getTime(); a positive persisted value is kept as-is. Once fix(admin): persist the instance last heartbeat time #7859 persists the column, the fallback stops triggering.Tests
InstanceControllerTest#testQueryPluginsWithMissingHealthBeatInfosends one page with two rows to cover both fallback cases: a missing entry withlastHeartBeatTime=0(falls back todateUpdated) and a persisted positivelastHeartBeatTime(kept as-is). It also asserts the response is200.testQueryPluginsnow asserts that local heartbeat values really override the persisted ones.Validation
./mvnw -pl shenyu-admin -am -Dtest=InstanceControllerTest -DfailIfNoTests=false \ -Djacoco.skip=true -Dmaven.javadoc.skip=true -Drat.skip=true testBUILD SUCCESS,Tests run: 5, Failures: 0, Errors: 0, Skipped: 0./mvnw -o -pl shenyu-admin checkstyle:checkpasses.Scope / follow-ups
dateUpdatedfallback no longer triggers.