Skip to content

Do not report extremely high HeartbeatLag values until the first heartbeat is read#1682

Merged
meiji163 merged 1 commit into
github:masterfrom
Shopify:fix-uninitialized-hb-lag-gh
May 19, 2026
Merged

Do not report extremely high HeartbeatLag values until the first heartbeat is read#1682
meiji163 merged 1 commit into
github:masterfrom
Shopify:fix-uninitialized-hb-lag-gh

Conversation

@grodowski
Copy link
Copy Markdown
Contributor

Description

Discovered it's possible to log uninitialized time values of lastHeartbeatOnChangelogTime before the first heartbeat arrives.

[gh-ost] : Copy: 0/0 100.0%; Applied: 0; Backlog: 0/1000; Time: 0s(total), 0s(copy); streamer: binlog.1350661:30466581; Lag: 0.00s, HeartbeatLag: 9223372036.85s, State: migrating; ETA: due

In case this PR introduced Go code changes:

  • contributed code is using same conventions as original code
  • script/cibuild returns with no formatting errors, build errors or unit test errors.

Copilot AI review requested due to automatic review settings May 19, 2026 14:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents HeartbeatLag from showing extremely large values caused by an uninitialized lastHeartbeatOnChangelogTime before the first heartbeat event is processed, by initializing the value when a migration/revert starts.

Changes:

  • Initialize lastHeartbeatOnChangelogTime to StartTime at the beginning of Migrator.Migrate() and Migrator.Revert().
  • Add assertions in TestRevertEmpty to ensure TimeSinceLastHeartbeatOnChangelog() is reasonable after Migrate() and after Revert().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
go/logic/migrator.go Initializes heartbeat timestamp at start of migrate/revert to avoid reporting uninitialized lag.
go/logic/migrator_test.go Adds regression assertions to catch uninitialized/huge heartbeat lag durations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@meiji163 meiji163 merged commit fe459a9 into github:master May 19, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants