krishvishal commented on code in PR #3746:
URL: https://github.com/apache/iggy/pull/3746#discussion_r3662155122
##########
core/partitions/src/poll_plan.rs:
##########
@@ -486,6 +540,99 @@ impl DiskReadPlan {
}
}
+ /// Resolve the read-only descriptor for `segment`'s file. A sealed segment
+ /// clones its cached fd on a hit (sharing the kernel fd, no syscall) and,
on
+ /// a miss, opens by path and stores the fd back so later polls skip the
+ /// `openat`. The active segment (no cache slot) always opens fresh.
Returns
+ /// `None` only when the open exhausts its retries (the caller fails
closed).
+ async fn resolve_segment_file(
+ &self,
+ segment: &DiskSegment,
+ path: &str,
+ ) -> Option<compio::fs::File> {
+ let Some(handle) = &segment.read_state else {
+ return self.open_segment_with_retry(path).await;
+ };
+ // Borrow only to clone the `Option<File>` out, never across the await.
+ if let Some(cached) = handle.fd.borrow().clone() {
Review Comment:
A cached fd can serve messages from an explicitly purged topic.
`core/partitions/src/poll_plan.rs:557`. A poll plan clones a sealed handle
whose `fd` slot is already populated; the pump then processes `PurgeTopic` into
`purge()` (`core/partitions/src/iggy_partition.rs:2985`), which retires every
segment, unlinks the files, and recreates `00000000000000000000.log`. The
in-flight `Rc` keeps the old inode alive, and `resolve_segment_file` returns
the cached fd without touching the filesystem, so the walk serves purged
messages. The window widens on a multi-segment walk suspended in
`read_chunk_with_retry`. The handle doc at `:31-33` blesses reading the
unlinked inode, which is correct for time and size retention but not for a
user-issued purge. Before this PR the re-open hit the freshly created empty
file and failed closed.
--
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]