Skip to content

[DEV] fix: use Stopwatch for INFO durations#1779

Merged
badrishc merged 2 commits intodevfrom
fix/info-durations-stopwatch-dev
May 9, 2026
Merged

[DEV] fix: use Stopwatch for INFO durations#1779
badrishc merged 2 commits intodevfrom
fix/info-durations-stopwatch-dev

Conversation

@kevin-montrose
Copy link
Copy Markdown
Contributor

dev targeting version of #1771

Copilot AI review requested due to automatic review settings May 8, 2026 14:40
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 updates Garnet’s INFO duration reporting to use a monotonic clock (Stopwatch) instead of wall-clock tick deltas, preventing negative/incorrect durations when system time changes (e.g., NTP adjustments). This aligns uptime_in_seconds and master_sync_last_io_seconds_ago with their intended “elapsed time since X” semantics.

Changes:

  • Anchor server startup time using Stopwatch.GetTimestamp() and compute INFO server uptime via Stopwatch.GetElapsedTime(...).
  • Track replica primary-sync “last I/O” time with Stopwatch timestamps for INFO replication (master_sync_last_io_seconds_ago).
  • Add a regression test asserting uptime_in_seconds increases across successive INFO SERVER calls.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/Garnet.test/RespInfoTests.cs Adds a test to validate monotonic uptime across INFO SERVER calls.
libs/server/StoreWrapper.cs Replaces wall-clock startup ticks with a Stopwatch timestamp anchor.
libs/server/Metrics/Info/GarnetInfoMetrics.cs Computes uptime_in_seconds / uptime_in_days using monotonic elapsed time.
libs/cluster/Server/Replication/ReplicationManager.cs Switches replica “last primary sync I/O” duration math to monotonic time.

Comment thread libs/cluster/Server/Replication/ReplicationManager.cs
@badrishc badrishc merged commit c927b02 into dev May 9, 2026
22 checks passed
@badrishc badrishc deleted the fix/info-durations-stopwatch-dev branch May 9, 2026 00:50
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.

4 participants