test(buzz-db): replica_fence unit test fails on Linux due to sub-microsecond Utc::now() precision
- Dominant language
- Rust
- Stars
- 32.7k
- Forks
- 4.3k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 253
Description
## Summary
`replica_fence::tests::fence_starts_closed_and_opens_on_advance` fails deterministically on Linux (glibc), on a clean `main` checkout with no local changes:
```
assertion `left == right` failed
left: Some(2026-07-22T14:04:14.529519Z)
right: Some(2026-07-22T14:04:14.529519155Z)
```
## Cause
The fence stores/returns the verified-through timestamp at **microsecond** precision, but the test compares it against the original `Utc::now()` value. On Linux, `Utc::now()` carries **nanosecond** precision, so `fence.verified_through() == Some(ts)` fails whenever `now()` lands on a non-zero sub-microsecond component (i.e. almost always). On macOS `now()` is microsecond-precision, which is why this passes in local dev and (presumably) CI runners there.
## Repro
```bash
# Linux, clean main (7e34bee)
cargo test -p buzz-db --lib fence_starts_closed
# fails 3/3 runs
```
## Suggested fix
Either truncate the expectation in the test (`ts.trunc_subsecs(6)` / compare through the same storage round-trip), or store nanoseconds in the fence. Test-side truncation is the minimal change if microsecond storage is intentional (matches Postgres `timestamptz` precision).
Contributor guide
Research direction
Start with the `replica_fence::tests::fence_starts_closed_and_opens_on_advance` test and reproduce it with `cargo test -p buzz-db --lib fence_starts_closed`. Check the timestamp precision used by the fence and the expectation in that test. Done means the test passes reliably on Linux while preserving the intended microsecond storage precision.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- databases, testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100