From dc367e9232982bbf87235b9756d4fd1f488fbc34 Mon Sep 17 00:00:00 2001 From: Wellington Ramos Chevreuil Date: Thu, 12 May 2022 09:36:46 +0100 Subject: [PATCH] HBASE-27021 StoreFileInfo should set its initialPath in a consistent way (#4419) Change-Id: I3d8a68d73fb91a31e0c8c41f50bf2cc06ff00685 Signed-off-by: Josh Elser Signed-off-by: Duo Zhang --- .../hadoop/hbase/regionserver/StoreEngine.java | 2 +- .../hadoop/hbase/regionserver/StoreFileInfo.java | 2 +- .../hadoop/hbase/regionserver/TestHStore.java | 15 +++++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreEngine.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreEngine.java index 952a8c3fee69..bce5c551c082 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreEngine.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreEngine.java @@ -221,7 +221,7 @@ public StoreFileWriter createWriter(CreateStoreFileWriterParams params) throws I public HStoreFile createStoreFileAndReader(Path p) throws IOException { FileSystem fs = ctx.getRegionFileSystem().getFileSystem(); - StoreFileInfo info = new StoreFileInfo(conf, fs, fs.getFileStatus(p)); + StoreFileInfo info = new StoreFileInfo(conf, fs, p, ctx.isPrimaryReplicaStore()); return createStoreFileAndReader(info); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileInfo.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileInfo.java index 203a2b5c126b..d773a11a4054 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileInfo.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileInfo.java @@ -129,7 +129,7 @@ private StoreFileInfo(final Configuration conf, final FileSystem fs, final FileS this.fs = fs; this.conf = conf; - this.initialPath = initialPath; + this.initialPath = fs.makeQualified(initialPath); this.primaryReplica = primaryReplica; this.noReadahead = this.conf.getBoolean(STORE_FILE_READER_NO_READAHEAD, DEFAULT_STORE_FILE_READER_NO_READAHEAD); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java index 46495b15874b..4a23eea361e3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java @@ -941,13 +941,16 @@ private void archiveStoreFile(int index) throws IOException { private void closeCompactedFile(int index) throws IOException { Collection files = this.store.getStoreEngine().getStoreFileManager().getCompactedfiles(); - HStoreFile sf = null; - Iterator it = files.iterator(); - for (int i = 0; i <= index; i++) { - sf = it.next(); + if (files.size() > 0) { + HStoreFile sf = null; + Iterator it = files.iterator(); + for (int i = 0; i <= index; i++) { + sf = it.next(); + } + sf.closeStoreFile(true); + store.getStoreEngine().getStoreFileManager() + .removeCompactedFiles(Collections.singletonList(sf)); } - sf.closeStoreFile(true); - store.getStoreEngine().getStoreFileManager().removeCompactedFiles(Lists.newArrayList(sf)); } @Test