Skip to content

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

Open
grodowski wants to merge 1 commit into
github:masterfrom
Shopify:fix-uninitialized-hb-lag-gh
Open

Do not report extremely high HeartbeatLag values until the first heartbeat is read#1682
grodowski wants to merge 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.

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.

2 participants