From e28ab5399bad007c5eaee585e462123ed7d7228c Mon Sep 17 00:00:00 2001 From: huxint Date: Sat, 15 Aug 2026 00:38:57 +0800 Subject: [PATCH] Keep posts created in the same second they are ingested MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit insert_posts drops any post whose created_at is not strictly less than the current wall-clock second. A post whose create event is applied in the same second it was created — normal for a low-latency Kafka pipeline — fails the strict comparison and is silently discarded. The event is not revisited for the lifetime of that serving process: only a restart, which re-reads the topic under a fresh consumer group, would pick the post up again. Until then the freshest in-network content is simply missing from that instance's store. The check exists to reject future-dated timestamps; created_at equal to the current second is not future-dated. Use <= so only genuinely future-dated posts are dropped. The retention arithmetic is unaffected: current_time - created_at is 0 at the boundary, which passes the retention check and cannot underflow in trim_old_posts. --- thunder/posts/post_store.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thunder/posts/post_store.rs b/thunder/posts/post_store.rs index 5a1c1966..4f8a0bfb 100644 --- a/thunder/posts/post_store.rs +++ b/thunder/posts/post_store.rs @@ -131,7 +131,7 @@ impl PostStore { .unwrap_or_default() .as_secs() as i64; posts.retain(|p| { - p.created_at < current_time + p.created_at <= current_time && current_time - p.created_at <= (self.retention_seconds as i64) });