Repository navigation
fix(admin): persist the instance last heartbeat time - #7859
Conversation
The instance mapper's column list, result map, insert and update omitted last_heart_beat_time, so the last reported heartbeat never reached the database: reads and restart restores saw 0, and the create path never copied the VO value either. Add the column (bigint NOT NULL DEFAULT 0) to the H2/MySQL/PG/Oracle init schemas and the five 2.7.1->2.7.2 upgrade scripts, persist it through the mapper XML, copy it in buildInstanceInfoDO, and add mapper round-trip regression tests plus service-path tests.
Aias00
left a comment
There was a problem hiding this comment.
Clean, complete change for #7723. The last_heart_beat_time column is added across all dialects (mysql / oracle / pg / h2) plus the 2.7.1→2.7.2 upgrade scripts and the upgrade guide; the InstanceInfoDO builder and instance-info-sqlmap.xml are wired through; and the mapper / service round-trip tests confirm persistence. The 0 default (no durable observation yet; real value stored on the next heartbeat) is documented correctly in the upgrade guide.
One note (non-blocking): no CI check runs are reported on this head commit — it looks like the workflow was not triggered. Please kick off a run (e.g. re-run the checks or a blank push) so the gates are recorded before merge.
Approving the change itself.
|
pls add my wechat: aias00 |
Fixes #7723
Problem
InstanceInfoServiceImplassignslastHeartBeatTimeon the update path andInstanceCheckService.handleBeatInfostamps it on every accepted heartbeat, but the value never reached the database:instance-info-sqlmap.xmlomitslast_heart_beat_timefromBaseResultMap,Base_Column_List,insertandupdateById.InstanceInfoDO.buildInstanceInfoDO) never copies the VO value.Every read path — including the restart/master-handover restore in
InstanceCheckService.fetchInstanceData— therefore sees0, and the checker ages restored instances from epoch zero.Solution
last_heart_beat_time(bigint NOT NULL DEFAULT 0) through the mapper XML (result map, column list, insert, update).buildInstanceInfoDOvia a new builder method.0("no durable observation yet") and are refreshed on the next heartbeat report; upgrade behavior documented indb/upgrade/upgrade-guide.md.Compatibility
NOT NULL DEFAULT 0; no existing statement changes semantics.resultTypeselects map through the globally enabledmapUnderscoreToCamelCase; theresultMapcovers the remaining queries.Tests
InstanceInfoMapperTest:insertRoundTripsLastHeartBeatTime/updateRoundTripsLastHeartBeatTimeround-trip a fixed nonzero timestamp on H2 through insert and update, covering bothresultTypeauto-mapping (selectById,selectOneByQuery) and theresultMappath (findAllByNamespaceId).InstanceInfoServiceImplTest:testCreatePersistsReportedHeartBeatTime/testUpdatePersistsReportedHeartBeatTimeverify 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=truereactor build succeeds; the unrelatedshenyu-plugin-tracingmodule (no dependency on the touched modules) has one pre-existing failure (TraceContinuityTest) that reproduces identically on pristinemasterin this environment, so it was excluded from the local run.Make sure that:
./mvnw clean install -Dmaven.javadoc.skip=true.