Skip to content

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

Open
magnetised wants to merge 1 commit intomainfrom
magnetised/receive-lag-clockskew
Open

fix(sync-service): Prevent negative replication lag statistics#3795
magnetised wants to merge 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.41%. Comparing base (586bd4c) to head (7de2f88).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3795      +/-   ##
==========================================
+ Coverage   87.36%   87.41%   +0.04%     
==========================================
  Files          23       23              
  Lines        2050     2050              
  Branches      543      544       +1     
==========================================
+ Hits         1791     1792       +1     
+ Misses        257      256       -1     
  Partials        2        2              
Flag Coverage Δ
packages/experimental 87.73% <ø> (ø)
packages/react-hooks 86.48% <ø> (ø)
packages/start 82.83% <ø> (ø)
packages/typescript-client 93.36% <ø> (+0.07%) ⬆️
packages/y-electric 56.05% <ø> (ø)
typescript 87.41% <ø> (+0.04%) ⬆️
unit-tests 87.41% <ø> (+0.04%) ⬆️

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.

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 bb120cb to 7de2f88 Compare February 5, 2026 16:38
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.

1 participant