atharvalade commented on issue #2924: URL: https://github.com/apache/iggy/issues/2924#issuecomment-4050596633
(offset skipping): The time-based message cleaner (`delete_expired_segments_for_partition`) doesn't check `min_committed_offset` before deleting segments, unlike `delete_oldest_segments` which does. So when segments expire, the cleaner just nukes them even if consumers haven't read those messages yet. Next poll with `PollingStrategy::next()` then jumps over the gap to the next surviving segment, which explains the random offset skips. https://github.com/apache/iggy/blob/261d25557d9aabdd51cb071ed8f62422ccb70c90/core/server/src/shard/system/segments.rs#L128-L133 ```rust segments .iter() .enumerate() .filter(|(idx, seg)| *idx != last_idx && seg.is_expired(now, expiry)) // ^ no min_committed_offset check here, unlike delete_oldest_segments (L294-L308) .map(|(_, seg)| seg.start_offset) .collect() ``` (premature deletion after restart): During bootstrap, if a segment's index file is empty (which can happen after a crash when `enforce_fsync = false`), `start_timestamp` and `end_timestamp` both get set to 0. Then `is_expired()` evaluates `0 + 10min <= now` as true, so the cleaner deletes those segments on the very first run after restart, even though the messages aren't actually expired. https://github.com/apache/iggy/blob/261d25557d9aabdd51cb071ed8f62422ccb70c90/core/server/src/bootstrap.rs#L333-L340 ```rust let (start_timestamp, end_timestamp) = if loaded_indexes.count() == 0 { (0, 0) // <-- segments with empty indexes get timestamp 0, instantly "expired" } else { ( loaded_indexes.get(0).unwrap().timestamp(), loaded_indexes.last().unwrap().timestamp(), ) }; ``` Still digging deeper, especially around the memory leak side of things, but wanted to share this early since it explains the post-restart behavior pretty clearly. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
