HBASE-21355 (addendum) replace the expensive reload storefiles with reading the merge result of compacted storefiles and current storefiles
This commit is contained in:
parent
3b66b65b9f
commit
d0e7367c8d
|
@ -303,6 +303,10 @@ public class HStore implements Store, HeapSize, StoreConfigInformation, Propagat
|
||||||
|
|
||||||
this.storeEngine = createStoreEngine(this, this.conf, this.comparator);
|
this.storeEngine = createStoreEngine(this, this.conf, this.comparator);
|
||||||
List<HStoreFile> hStoreFiles = loadStoreFiles();
|
List<HStoreFile> hStoreFiles = loadStoreFiles();
|
||||||
|
// Move the storeSize calculation out of loadStoreFiles() method, because the secondary read
|
||||||
|
// replica's refreshStoreFiles() will also use loadStoreFiles() to refresh its store files and
|
||||||
|
// update the storeSize in the completeCompaction(..) finally (just like compaction) , so
|
||||||
|
// no need calculate the storeSize twice.
|
||||||
this.storeSize.addAndGet(getStorefilesSize(hStoreFiles, sf -> true));
|
this.storeSize.addAndGet(getStorefilesSize(hStoreFiles, sf -> true));
|
||||||
this.totalUncompressedBytes.addAndGet(getTotalUmcompressedBytes(hStoreFiles));
|
this.totalUncompressedBytes.addAndGet(getTotalUmcompressedBytes(hStoreFiles));
|
||||||
this.storeEngine.getStoreFileManager().loadFiles(hStoreFiles);
|
this.storeEngine.getStoreFileManager().loadFiles(hStoreFiles);
|
||||||
|
@ -1705,26 +1709,16 @@ public class HStore implements Store, HeapSize, StoreConfigInformation, Propagat
|
||||||
@Override
|
@Override
|
||||||
public boolean hasReferences() {
|
public boolean hasReferences() {
|
||||||
List<HStoreFile> reloadedStoreFiles = null;
|
List<HStoreFile> reloadedStoreFiles = null;
|
||||||
|
// Grab the read lock here, because we need to ensure that: only when the atomic
|
||||||
|
// replaceStoreFiles(..) finished, we can get all the complete store file list.
|
||||||
|
this.lock.readLock().lock();
|
||||||
try {
|
try {
|
||||||
// Reloading the store files from file system due to HBASE-20940. As split can happen with an
|
// Merge the current store files with compacted files here due to HBASE-20940.
|
||||||
// region which has references
|
Collection<HStoreFile> allStoreFiles = new ArrayList<>(getStorefiles());
|
||||||
reloadedStoreFiles = loadStoreFiles();
|
allStoreFiles.addAll(getCompactedFiles());
|
||||||
return StoreUtils.hasReferences(reloadedStoreFiles);
|
return StoreUtils.hasReferences(allStoreFiles);
|
||||||
} catch (IOException ioe) {
|
|
||||||
LOG.error("Error trying to determine if store has references, assuming references exists",
|
|
||||||
ioe);
|
|
||||||
return true;
|
|
||||||
} finally {
|
} finally {
|
||||||
if (reloadedStoreFiles != null) {
|
this.lock.readLock().unlock();
|
||||||
for (HStoreFile storeFile : reloadedStoreFiles) {
|
|
||||||
try {
|
|
||||||
storeFile.closeStoreFile(false);
|
|
||||||
} catch (IOException ioe) {
|
|
||||||
LOG.warn("Encountered exception closing " + storeFile + ": " + ioe.getMessage());
|
|
||||||
// continue with closing the remaining store files
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue