Copilot commented on code in PR #8851:
URL: https://github.com/apache/hbase/pull/8851#discussion_r4698940650
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileInfo.java:
##########
@@ -343,11 +378,15 @@ ReaderContext createReaderContext(boolean doDropBehind,
long readahead, ReaderTy
String keyNamespace, SystemKeyCache systemKeyCache, ManagedKeyDataCache
managedKeyDataCache)
throws IOException {
FSDataInputStreamWrapper in;
- FileStatus status;
+ Path readerPath;
+ long length;
+ FileStatus statusForOpen;
if (this.link != null) {
// HFileLink
in = new FSDataInputStreamWrapper(fs, this.link, doDropBehind,
readahead);
- status = this.link.getFileStatus(fs);
+ FileStatus linkStatus = this.link.getFileStatus(fs);
+ readerPath = linkStatus.getPath();
Review Comment:
A reference to an HFileLink has both `link` and `reference` set (see
`StoreFileTrackerBase.getStoreFileInfo`), so it enters this branch too.
Previously every reference retained `this.getPath()` as its logical reader
path; this assignment instead uses the physical parent HFile path.
`HFileReaderImpl` derives its name, region, archive classification, and cache
identity from that path, so linked references now acquire the parent's identity
rather than the reference's. Preserve the reference path here while continuing
to use `linkStatus` for the physical length.
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java:
##########
@@ -217,6 +218,44 @@ public static FSDataOutputStream create(Configuration
conf, FileSystem fs, Path
return create(conf, fs, path, perm, favoredNodes, true);
}
+ /**
+ * Opens a file for reading. When {@code fileStatus} is supplied and the
{@link FileSystem}
+ * supports {@code FileSystem.openFile().withFileStatus()}, that path is
used so the client can
+ * skip a redundant metadata lookup (for example {@code getFileInfo}).
+ * @param fs filesystem
+ * @param path file to open
+ * @param fileStatus status from a recent {@code listStatus} / {@code
getFileStatus}, or
+ * {@code null}
+ * @return input stream for the file
+ * @throws IOException if the file cannot be opened
+ */
+ public static FSDataInputStream openForRead(FileSystem fs, Path path,
FileStatus fileStatus)
+ throws IOException {
+ if (fileStatus != null) {
+ try {
+ CompletableFuture<FSDataInputStream> future =
+ fs.openFile(path).withFileStatus(fileStatus).build();
+ try {
+ return future.get();
+ } catch (InterruptedException e) {
+ // The open may still complete asynchronously; close whatever stream
it produces since
+ // the caller will never receive it. Do not cancel the future, as a
cancelled future
+ // would discard a stream that is completed later without closing it.
+ future.whenComplete((in, t) -> IOUtils.cleanupWithLogger(LOG, in));
+ Thread.currentThread().interrupt();
+ throw (InterruptedIOException) new
InterruptedIOException("Interrupted opening " + path)
+ .initCause(e);
+ }
+ } catch (UnsupportedOperationException | ExecutionException e) {
Review Comment:
`ExecutionException` does not mean the builder API is unsupported: it also
wraps actual open failures, including permission errors, missing files, and
storage failures. Catching all of them here silently retries through
`open(path)`, potentially hiding the original failure if the retry succeeds or
replacing its diagnostics if it fails. Please fall back only for
unsupported-operation failures and propagate other causes as `IOException`
(preserving the original cause).
--
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]