Skip to content

Fix whole-second timestamp ordering in the SQLite store#269

Merged
samrusani merged 1 commit into
mainfrom
fix-sqlite-timestamp-precision
Jul 9, 2026
Merged

Fix whole-second timestamp ordering in the SQLite store#269
samrusani merged 1 commit into
mainfrom
fix-sqlite-timestamp-precision

Conversation

@samrusani

Copy link
Copy Markdown
Owner

Found by a probe run during round-2 benchmark work: _utc_now_iso() drops the fractional part when a write lands on exactly a whole second (~1e-6 of inserts), and the resulting ...59Z string sorts lexicographically after every ...59.000123Z sibling — corrupting timestamp ordering. timespec="microseconds" pins the format; regression test included.

🤖 Generated with Claude Code

…n SQLite

datetime.isoformat() omits the fractional part when microsecond == 0, so
the ~1e-6 of writes landing on a whole second produced '...59Z', which
sorts lexicographically AFTER every '...59.000123Z' in the same second —
corrupting created_at/updated_at ordering (surfaced as rare crashes in
offline benchmark replays). timespec='microseconds' pins the format.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

@samrusani samrusani merged commit 520031d into main Jul 9, 2026
8 checks passed
@samrusani samrusani deleted the fix-sqlite-timestamp-precision branch July 9, 2026 21:14
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