Copilot commented on code in PR #3606:
URL: https://github.com/apache/fluss/pull/3606#discussion_r3607762496
##########
fluss-server/src/main/java/org/apache/fluss/server/replica/ReplicaManager.java:
##########
@@ -1529,6 +1545,37 @@ public Map<TableBucket, LogReadResult> readFromLog(
return logReadResult;
}
+ private @Nullable FetchLogResultForBucket tryFetchRemoteFirst(
+ Replica replica, long fetchOffset) {
+ TableBucket tb = replica.getTableBucket();
+ long normalizedFetchOffset =
+ fetchOffset == FetchParams.FETCH_FROM_EARLIEST_OFFSET
+ ? replica.getLogStartOffset()
+ : fetchOffset;
+ if (!canFetchFromRemoteLog(replica, normalizedFetchOffset)) {
+ return null;
+ }
+
+ try {
+ RemoteLogFetchInfo remoteLogFetchInfo =
+ fetchLogFromRemote(replica, normalizedFetchOffset);
+ if (remoteLogFetchInfo != null) {
+ return new FetchLogResultForBucket(
+ tb, remoteLogFetchInfo, replica.getLogHighWatermark());
+ }
+ return new FetchLogResultForBucket(
+ tb,
+ ApiError.fromThrowable(
+ new LogOffsetOutOfRangeException(
+ String.format(
+ "The fetch offset %s is covered by
remote log range for table bucket %s, "
+ + "but no remote log
segment is available.",
+ normalizedFetchOffset, tb))));
+ } catch (Exception e) {
+ return new FetchLogResultForBucket(tb, ApiError.fromThrowable(e));
+ }
Review Comment:
`tryFetchRemoteFirst` turns a remote-metadata miss into a hard fetch
failure: when `canFetchFromRemoteLog(...)` is true but
`fetchLogFromRemote(...)` returns null (no relevant segments), it returns
`ApiError` wrapping `LogOffsetOutOfRangeException`. For a *preference*
(`REMOTE_FIRST`), this is brittle because local log may still be able to serve
the request; transient remote manifest gaps would surface as user-visible
errors instead of falling back to local reads.
##########
fluss-common/src/main/java/org/apache/fluss/rpc/protocol/FetchLogReadPreference.java:
##########
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.fluss.rpc.protocol;
+
+import org.apache.fluss.annotation.Internal;
+
+/** Read preference for fetch log requests. */
+@Internal
+public enum FetchLogReadPreference {
+ LOCAL_FIRST(0, "local-first"),
+ REMOTE_FIRST(1, "remote-first");
+
Review Comment:
`FetchLogReadPreference` is used in a public `ConfigOption`
(`ConfigOptions.CLIENT_SCANNER_LOG_READ_PREFERENCE`) and referenced by
client/server code, so marking it `@Internal` is inconsistent with the API
surface it exposes. Consider marking it `@PublicEvolving` (similar to other
rpc.protocol enums like `MergeMode`) to avoid signaling that external use is
unsupported.
--
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]