Skip to content

fix: Leave StateSince alone when a synchronizer starts - #502

Open
beekld wants to merge 1 commit into
bklimt/SDK-3425/unrecoverable-error-logfrom
bklimt/SDK-3425/private-condition-clock
Open

beekld wants to merge 1 commit into
bklimt/SDK-3425/unrecoverable-error-logfrom
bklimt/SDK-3425/private-condition-clock

Conversation

@beekld

@beekld beekld commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#489 reset the public DataSourceStatus.StateSince to the current time whenever a synchronizer started, even when State didn't change, and without broadcasting the new status. StateSince is documented as the time State most recently changed. An app that measures how long the SDK has been Interrupted had its clock reset on every failover, and status listeners held a different StateSince than GetStatus().

The reset existed so that each synchronizer gets its own fallback and recovery window. The data system now records when the current synchronizer started in a private field. The fallback and recovery conditions measure from the later of that time and StateSince, so their timing is unchanged. StateSince again changes only when State changes.


Note

Overview
DataSourceStatus.StateSince is no longer reset when a synchronizer starts. Starting a synchronizer used to call restartStatusClock(), which bumped StateSince even though State stayed the same (e.g. still Interrupted during failover), breaking apps that measure outage duration and leaving listeners out of sync with GetStatus().

The synchronizer loop now records syncStartedAt when each synchronizer starts. Fallback and recovery predicates still get a per-synchronizer window by evaluating conditionAction against the later of StateSince and syncStartedAt (local copy only—the stored status updates StateSince only when State changes in maybeUpdateStatus).

A regression test asserts that after primary failure and secondary start, StateSince is unchanged.

Reviewed by Cursor Bugbot for commit 3db133f. Bugbot is set up for automated code reviews on this repo. Configure here.

@beekld
beekld added this pull request to stack #503 November 2, 2026 21:04
@beekld
beekld marked this pull request as ready for review November 2, 2026 21:06
@beekld
beekld requested a review from a team as a code owner November 2, 2026 21:06
@beekld
beekld force-pushed the bklimt/SDK-3425/private-condition-clock branch from 9feb2a1 to 940feda Compare November 2, 2026 21:31
@beekld
beekld force-pushed the bklimt/SDK-3425/private-condition-clock branch from 940feda to 0d6372b Compare November 2, 2026 21:59
@beekld
beekld force-pushed the bklimt/SDK-3425/private-condition-clock branch from 0d6372b to 3db133f Compare November 3, 2026 00:05
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