nanhe17 opened a new pull request, #7859:
URL: https://github.com/apache/shenyu/pull/7859
Fixes #7723
### Problem
`InstanceInfoServiceImpl` assigns `lastHeartBeatTime` on the update path and
`InstanceCheckService.handleBeatInfo` stamps it on every accepted heartbeat,
but the value never reached the database:
- `instance-info-sqlmap.xml` omits `last_heart_beat_time` from
`BaseResultMap`, `Base_Column_List`, `insert` and `updateById`.
- The initialization schemas (H2, MySQL, PostgreSQL, Oracle) and the
2.7.1→2.7.2 upgrade scripts lack the column.
- The create path (`InstanceInfoDO.buildInstanceInfoDO`) never copies the VO
value.
Every read path — including the restart/master-handover restore in
`InstanceCheckService.fetchInstanceData` — therefore sees `0`, and the checker
ages restored instances from epoch zero.
### Solution
- Persist `last_heart_beat_time` (`bigint NOT NULL DEFAULT 0`) through the
mapper XML (result map, column list, insert, update).
- Copy the reported heartbeat in `buildInstanceInfoDO` via a new builder
method.
- Add the column to the H2/MySQL/PG/Oracle init schemas and to the five
2.7.1→2.7.2 upgrade scripts (mysql/ob/og/oracle/pg). Historical rows backfill
to `0` ("no durable observation yet") and are refreshed on the next heartbeat
report; upgrade behavior documented in `db/upgrade/upgrade-guide.md`.
### Compatibility
- New column is `NOT NULL DEFAULT 0`; no existing statement changes
semantics. `resultType` selects map through the globally enabled
`mapUnderscoreToCamelCase`; the `resultMap` covers the remaining queries.
- No public API or configuration change.
### Tests
- `InstanceInfoMapperTest`: `insertRoundTripsLastHeartBeatTime` /
`updateRoundTripsLastHeartBeatTime` round-trip a fixed nonzero timestamp on H2
through insert and update, covering both `resultType` auto-mapping
(`selectById`, `selectOneByQuery`) and the `resultMap` path
(`findAllByNamespaceId`).
- `InstanceInfoServiceImplTest`: `testCreatePersistsReportedHeartBeatTime` /
`testUpdatePersistsReportedHeartBeatTime` verify the service passes the
reported heartbeat to the mapper on both paths.
Local verification (Windows, JDK 21): `./mvnw -pl shenyu-admin -am test` —
InstanceInfoMapperTest 11/11, InstanceInfoServiceImplTest 4/4,
InstanceInfoMapperOracleSqlTest 1/1, InstanceInfoServiceTest 8/8, checkstyle
passing. The full `./mvnw clean install -Dmaven.javadoc.skip=true` reactor
build succeeds; the unrelated `shenyu-plugin-tracing` module (no dependency on
the touched modules) has one pre-existing failure (`TraceContinuityTest`) that
reproduces identically on pristine `master` in this environment, so it was
excluded from the local run.
Make sure that:
- [x] You have read the [contribution
guidelines](https://shenyu.apache.org/community/contributor-guide).
- [x] You submit test cases (unit or integration tests) that back your
changes.
- [ ] Your local test passed `./mvnw clean install
-Dmaven.javadoc.skip=true`.
--
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]