Skip to content

fix(sync-service): Prevent negative replication lag statistics#3795

Merged
magnetised merged 1 commit intomainfrom
magnetised/receive-lag-clockskew
Feb 23, 2026
Merged

fix(sync-service): Prevent negative replication lag statistics#3795
magnetised merged 1 commit intomainfrom
magnetised/receive-lag-clockskew

Conversation

@magnetised
Copy link
Contributor

Detect clock skew that presents as transaction commit timestamps being after the current system time and use the diff in the final replication lag calculation.

As noted this removes information but in the presence of detectable clock skew this information is unhelpful.

Clock skew make a mockery of our idea that the replication lag calculation in any way represents the actual time between a commit in pg and a write in electric. With this at least we get an end to end time for the processing of a transaction and can monitor trends.

@netlify
Copy link

netlify bot commented Jan 28, 2026

Deploy Preview for electric-next ready!

Name Link
🔨 Latest commit 7de2f88
🔍 Latest deploy log https://app.netlify.com/projects/electric-next/deploys/6984c78f1c09cb00087ef115
😎 Deploy Preview https://deploy-preview-3795--electric-next.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link

codecov bot commented Jan 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.06%. Comparing base (be42de5) to head (7067f48).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3795   +/-   ##
=======================================
  Coverage   87.06%   87.06%           
=======================================
  Files          25       25           
  Lines        2343     2343           
  Branches      592      595    +3     
=======================================
  Hits         2040     2040           
  Misses        301      301           
  Partials        2        2           
Flag Coverage Δ
packages/experimental 87.73% <ø> (ø)
packages/react-hooks 86.48% <ø> (ø)
packages/start 82.83% <ø> (ø)
packages/typescript-client 91.81% <ø> (ø)
packages/y-electric 56.05% <ø> (ø)
typescript 87.06% <ø> (ø)
unit-tests 87.06% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@magnetised magnetised force-pushed the magnetised/receive-lag-clockskew branch from bb120cb to 7de2f88 Compare February 5, 2026 16:38
Copy link
Member

@alco alco left a comment

Choose a reason for hiding this comment

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

Brilliant!

Detect clock skew that presents as transaction commit timestamps being
after the current system time and use the diff in the final replication
lag calculation.

As noted this removes information but in the presence of detectable
clock skew this information is unhelpful.

Clock skew make a mockery of our idea that the replication lag
calculation in any way represents the actual time between a commit in pg
and a write in electric. With this at least we get an end to end time
for the processing of a transaction and can monitor trends.
@magnetised magnetised force-pushed the magnetised/receive-lag-clockskew branch from 7de2f88 to 7067f48 Compare February 23, 2026 14:34
@blacksmith-sh

This comment has been minimized.

@magnetised magnetised merged commit 8f2f7bd into main Feb 23, 2026
53 of 55 checks passed
@magnetised magnetised deleted the magnetised/receive-lag-clockskew branch February 23, 2026 14:59
@github-actions
Copy link
Contributor

This PR has been released! 🚀

The following packages include changes from this PR:

  • @core/sync-service@1.4.7

Thanks for contributing to Electric!

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