fix(db): replica_fence unit test survives ns-precision clocks - #3226
Open
jeremyd wants to merge 1 commit into
Open
fix(db): replica_fence unit test survives ns-precision clocks#3226jeremyd wants to merge 1 commit into
jeremyd wants to merge 1 commit into
Conversation
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
force-pushed
the
fix/replica-fence-ns-clock
branch
from
July 27, 2026 22:21
3f35a82 to
dc83dc1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_advancefeeds a rawUtc::now()into the fence and asserts exact round-trip equality — but the fence stores microseconds. On platforms whereUtc::now()has nanosecond precision (Linux), the sub-microsecond part is truncated and the assertion fails on essentially every run: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.