Skip to content

[BUG] Instance last heartbeat time is never persisted or restored #7723

Closed

Description

@Aias00

Current behavior

InstanceInfoServiceImpl.createOrUpdate assigns lastHeartBeatTime on the Java entity for updates, but the instance mapper's column list, result map, insert and update statements contain no heartbeat timestamp. The reviewed initialization schemas also lack this column. The create conversion does not copy the value either. Database reads therefore produce the Java default 0 for a primitive long.

The instance list overlays this with a live local map, masking the omission. Detail queries read the database, and InstanceCheckService.fetchInstanceData restores database values on startup/master election. A restored record consequently has no durable last-seen observation, and the checker can age it from epoch zero if no new report arrives. Do not use date_updated as a substitute: periodic persistence updates that field independently of receiving a heartbeat.

Source evidence

A local XML inspection confirmed that Base_Column_List, BaseResultMap, insert and updateById omit this field. No database/runtime reproduction was executed during issue preparation.

Acceptance criteria

  • Define durable last-seen semantics and persist/read the heartbeat observation consistently through create, update, list and detail paths.
  • Add initialization/upgrade changes for supported database dialects and explicit handling of historical rows with no observation.
  • Mapper integration tests round-trip a fixed nonzero timestamp through insert and update; mock-only service tests are insufficient.
  • Test Admin restart/master handover, with and without a subsequent heartbeat; unknown/stale observations are represented explicitly rather than fabricated as fresh.
  • Preserve namespace identity and distinguish last report time from last persistence time.

Related: #7697 concerns missing local-map entries; #7718 concerns readiness; neither repairs the persistence contract.

Database verification update (2026-10-17)

Reproduced using the H2 instance-table DDL and MyBatis XML mapper from 66d7d954ca37d651a5ad916f988a8081157a7ab4, plus recompiled current InstanceInfoServiceImpl, entity, VO and mapper interface. This probe used a real H2 database and MyBatis sessions, not a mocked mapper.

A nonzero heartbeat (1700000000000) was supplied on create; the database-backed entity and detail service read 0. Updating the heartbeat to 1700000009999 still read 0. Assertions confirmed both insert and update round-trip omission.

No production source was modified. Other database dialects and Admin restart were not executed; this verifies the persistence omission underlying those scenarios.

Activity

  1. nanhe17 commented on Oct 19, 2026

    @nanhe17
    Contributor

    你好,我想认领这个 issue。我已在 master 上确认了问题:instance-info-sqlmap.xml 的结果映射、列清单、insert 和 update 语句都遗漏了 last_heart_beat_time,各数据库方言的初始化/升级脚本也缺少该列,并且 create 路径从未拷贝 VO 中的心跳时间——导致所有数据库读取和重启恢复看到的都是 0。

    计划:端到端补上该列(mapper XML + H2/MySQL/PG/Oracle 初始化 schema + 五个 2.7.1→2.7.2 升级脚本),create 路径补上值拷贝,并增加 mapper 回环回归测试和服务层路径测试。改动已在本地实现并验证通过,PR 将随后提交。


    Hi, I'd like to work on this issue. I've confirmed the gap on master: instance-info-sqlmap.xml omits last_heart_beat_time from the result map, column list, insert and update, the init/upgrade schemas for all dialects lack the column, and the create path never copies the VO's heartbeat value — so every DB read and restart restore sees 0.

    Plan: add the column end-to-end (mapper XML + H2/MySQL/PG/Oracle init schemas + the five 2.7.1→2.7.2 upgrade scripts), copy it on the create path, and add mapper round-trip regression tests plus service-path tests. The change is implemented and verified locally; PR will follow shortly.

    /assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions