konlue opened a new pull request, #7780:
URL: https://github.com/apache/shenyu/pull/7780
Fixes #7763.
## Summary
`InstanceCheckService#fetchInstanceData` (startup / master election)
unconditionally overwrites the live map with persisted observations, racing
`handleBeatInfo` on request threads.
Because heartbeat time is not persisted, a restored observation is always
older than a heartbeat accepted in the meantime, so the restore can roll a live
instance back to a stale snapshot (status and last-heartbeat time included).
## Modifications
- Replace the unconditional `put` with `putIfAbsent`: a persisted
observation only fills identities that have no live entry.
- Add regression tests: a heartbeat accepted before the restore keeps its
heartbeat time and ONLINE state; identities absent from the map are still
restored.
## Verifying this change
- [x] Red-green: `testFetchInstanceDataKeepsLiveHeartbeatOverStaleSnapshot`
fails on the current code (the stale snapshot replaces the live entry) and
passes with `putIfAbsent`; full `InstanceCheckServiceTest` 14/14 green with no
regressions.
- [x] Targeted tests pass:
```bash
./mvnw -B -ntp -pl shenyu-admin test -Dtest=InstanceCheckServiceTest
```
14/14 green.
- [x] Checkstyle passes:
```bash
./mvnw -B -ntp -pl shenyu-admin checkstyle:check
```
clean.
## Notes
The fix does not depend on heartbeat-time persistence (#7723): even once
that lands, "do not clobber a live entry" remains the correct ordering rule.
Local entries continue to be aged out by `doCheck`, so nothing can be frozen by
skipping the overwrite.
--
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]