Kaixuan-Duan commented on code in PR #3132:
URL: https://github.com/apache/fluss/pull/3132#discussion_r3224043187
##########
fluss-server/src/main/java/org/apache/fluss/server/kv/RemoteLogFetcher.java:
##########
@@ -333,12 +555,202 @@ private void advance() {
}
}
+ /**
+ * Obtain the local file for {@code segment}, ideally reusing a
prefetched download. On
+ * success the ring head is consumed and a refill is triggered, so the
window stays full as
+ * long as more segments remain.
+ */
+ private File fetchSegmentFile(RemoteLogSegment segment) throws
IOException {
+ // Invariant: fillPrefetchWindow() and advance() walk the same
pre-filtered
+ // `segments` list in strict order with identical skip rules;
consumption is
+ // single-threaded FIFO; prefetchNum >= 1 (Math.max(1, ...) in the
ctor). So
+ // the ring head is *always* the segment advance() is asking for.
+ int headSlot = nextConsumeIndex % prefetchNum;
+ RemoteLogSegment headSegment = prefetchSegments[headSlot];
+ assert isSameSegmentId(segment, headSegment)
+ : "prefetch ring head "
+ + (headSegment == null ? "null" :
headSegment.remoteLogSegmentId())
+ + " does not match requested "
+ + segment.remoteLogSegmentId();
+ Future<File> headFuture = prefetchSlots[headSlot];
+ // Eagerly null the slot refs so the ring never keeps stale
references even if the
+ // consumer throws below — also releases the RemoteLogSegment for
GC early.
+ prefetchSlots[headSlot] = null;
+ prefetchSegments[headSlot] = null;
+ nextConsumeIndex++;
+ try {
+ return headFuture.get();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new IOException(
+ "Interrupted while waiting for remote log segment
download: "
+ + segment.remoteLogSegmentId(),
+ e);
+ } catch (CancellationException e) {
+ LOG.warn(
+ "Prefetched segment {} was cancelled, fallback to sync
download.",
+ segment.remoteLogSegmentId(),
+ e);
+ return downloadSegmentWithRetry(segment);
+ } catch (ExecutionException e) {
Review Comment:
You're right — the async worker already exhausts retries via
downloadSegmentWithRetry(). Removed the redundant sync retry in catch
(ExecutionException); now propagates directly as IOException.
--
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]