Skip to content

fix(db): replica_fence unit test survives ns-precision clocks - #3226

Open
jeremyd wants to merge 1 commit into
block:mainfrom
jeremyd:fix/replica-fence-ns-clock
Open

fix(db): replica_fence unit test survives ns-precision clocks#3226
jeremyd wants to merge 1 commit into
block:mainfrom
jeremyd:fix/replica-fence-ns-clock

Conversation

@jeremyd

@jeremyd jeremyd commented Jul 27, 2026

Copy link
Copy Markdown

The fence stores microseconds; the test fed a raw Utc::now() and asserted exact round-trip equality — passes on macOS (us clock), fails on Linux (ns clock). Truncate the input to the fence's own precision.

replica_fence::tests::fence_starts_closed_and_opens_on_advance feeds a raw Utc::now() into the fence and asserts exact round-trip equality — but the fence stores microseconds. On platforms where Utc::now() has nanosecond precision (Linux), the sub-microsecond part is truncated and the assertion fails on essentially every run:

assertion `left == right` failed
  left: Some(2026-07-27T21:51:31.284163Z)
 right: Some(2026-07-27T21:51:31.284163384Z)

On macOS the system clock reports microseconds, so the test passes there — which is presumably why it hasn't been noticed.

Fix: truncate the test's input timestamp to the fence's own precision (DateTime::from_timestamp_micros(now.timestamp_micros())), so round-trip equality holds regardless of platform clock resolution. Test-only change, one file.

@jeremyd
jeremyd requested a review from a team as a code owner July 27, 2026 22:19
The fence stores microseconds; the test fed a raw Utc::now() and asserted
exact round-trip equality — passes on macOS (us clock), fails on Linux
(ns clock). Truncate the input to the fence's own precision.

Signed-off-by: cloudfodder <cloudfodder@relay.tools>
@jeremyd
jeremyd force-pushed the fix/replica-fence-ns-clock branch from 3f35a82 to dc83dc1 Compare July 27, 2026 22:21
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