Skip to content

SQLite stream retention cutoff on a whole second deletes same-second rows early #464

Open

Description

@LeeroyHannigan

The SQLite retention sweep (cleanup_expired_stream_records in crates/storage-sqlite/src/stream.rs) deletes rows with created_at < cutoff as a text comparison. created_at carries a millisecond fraction (2026-10-23T14:19:07.123Z). The cutoff is format_timestamp(now - 24h), RFC 3339 from the time crate, which renders a whole second with no fraction (2026-10-23T14:19:07Z). When the cutoff lands on an exact whole second, every row in that same second (...07.123Z) sorts before it, because . sorts before Z, and is deleted up to a second early.

Reaching it needs now_utc() to return a zero sub-second on the sweep's read, so it fires rarely. The fix is to render the cutoff in the same millisecond shape as the column (sqlite_util::format_epoch_millis), with a unit test for a cutoff on a whole second.

Found while working on #463, which did not introduce or widen it.

Activity

  1. added this to the 1.0 milestone on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions