Skip to content

Commit 84cb443

Browse files
rabi-kumarsaintstack
authored andcommitted
HBASE-22899 logging improvements for snapshot operations w/large manifests (#547)
Signed-off-by: Jan Hentschel <jan.hentschel@ultratendency.com>
1 parent bf12348 commit 84cb443

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/RestoreSnapshotHelper.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ private void restoreRegion(final RegionInfo regionInfo,
501501
getRegionHFileReferences(regionManifest);
502502

503503
String tableName = tableDesc.getTableName().getNameAsString();
504+
final String snapshotName = snapshotDesc.getName();
504505

505506
// Restore families present in the table
506507
for (Path familyDir: FSUtils.getFamilyDirs(fs, regionDir)) {
@@ -523,20 +524,21 @@ private void restoreRegion(final RegionInfo regionInfo,
523524
// Remove hfiles not present in the snapshot
524525
for (String hfileName: familyFiles) {
525526
Path hfile = new Path(familyDir, hfileName);
526-
LOG.trace("Removing hfile=" + hfileName +
527+
LOG.trace("Removing HFile=" + hfileName + " not present in snapshot=" + snapshotName+
527528
" from region=" + regionInfo.getEncodedName() + " table=" + tableName);
528529
HFileArchiver.archiveStoreFile(conf, fs, regionInfo, tableDir, family, hfile);
529530
}
530531

531532
// Restore Missing files
532533
for (SnapshotRegionManifest.StoreFile storeFile: hfilesToAdd) {
533-
LOG.debug("Adding HFileLink " + storeFile.getName() +
534-
" to region=" + regionInfo.getEncodedName() + " table=" + tableName);
534+
LOG.debug("Restoring missing HFileLink " + storeFile.getName() +
535+
" of snapshot=" + snapshotName+
536+
" to region=" + regionInfo.getEncodedName() + " table=" + tableName);
535537
restoreStoreFile(familyDir, regionInfo, storeFile, createBackRefs);
536538
}
537539
} else {
538540
// Family doesn't exists in the snapshot
539-
LOG.trace("Removing family=" + Bytes.toString(family) +
541+
LOG.trace("Removing family=" + Bytes.toString(family) + " in snapshot=" + snapshotName +
540542
" from region=" + regionInfo.getEncodedName() + " table=" + tableName);
541543
HFileArchiver.archiveFamilyByFamilyDir(fs, conf, regionInfo, familyDir, family);
542544
fs.delete(familyDir, true);
@@ -552,7 +554,8 @@ private void restoreRegion(final RegionInfo regionInfo,
552554
}
553555

554556
for (SnapshotRegionManifest.StoreFile storeFile: familyEntry.getValue()) {
555-
LOG.trace("Adding HFileLink " + storeFile.getName() + " to table=" + tableName);
557+
LOG.trace("Adding HFileLink (Not present in the table) " + storeFile.getName()
558+
+ " of snapshot " + snapshotName + " to table=" + tableName);
556559
restoreStoreFile(familyDir, regionInfo, storeFile, createBackRefs);
557560
}
558561
}
@@ -584,6 +587,7 @@ private RegionInfo[] cloneHdfsRegions(final ThreadPoolExecutor exec,
584587
if (regions == null || regions.isEmpty()) return null;
585588

586589
final Map<String, RegionInfo> snapshotRegions = new HashMap<>(regions.size());
590+
final String snapshotName = snapshotDesc.getName();
587591

588592
// clone region info (change embedded tableName with the new one)
589593
RegionInfo[] clonedRegionsInfo = new RegionInfo[regions.size()];
@@ -596,7 +600,8 @@ private RegionInfo[] cloneHdfsRegions(final ThreadPoolExecutor exec,
596600
String snapshotRegionName = snapshotRegionInfo.getEncodedName();
597601
String clonedRegionName = clonedRegionsInfo[i].getEncodedName();
598602
regionsMap.put(Bytes.toBytes(snapshotRegionName), Bytes.toBytes(clonedRegionName));
599-
LOG.info("clone region=" + snapshotRegionName + " as " + clonedRegionName);
603+
LOG.info("clone region=" + snapshotRegionName + " as " + clonedRegionName +
604+
" in snapshot " + snapshotName);
600605

601606
// Add mapping between cloned region name and snapshot region info
602607
snapshotRegions.put(clonedRegionName, snapshotRegionInfo);
@@ -640,10 +645,12 @@ private void cloneHdfsMobRegion(final Map<String, SnapshotRegionManifest> region
640645
private void cloneRegion(final Path regionDir, final RegionInfo snapshotRegionInfo,
641646
final SnapshotRegionManifest manifest) throws IOException {
642647
final String tableName = tableDesc.getTableName().getNameAsString();
648+
final String snapshotName = snapshotDesc.getName();
643649
for (SnapshotRegionManifest.FamilyFiles familyFiles: manifest.getFamilyFilesList()) {
644650
Path familyDir = new Path(regionDir, familyFiles.getFamilyName().toStringUtf8());
645651
for (SnapshotRegionManifest.StoreFile storeFile: familyFiles.getStoreFilesList()) {
646-
LOG.info("Adding HFileLink " + storeFile.getName() + " to table=" + tableName);
652+
LOG.info("Adding HFileLink " + storeFile.getName() +" from cloned region "
653+
+ "in snapshot " + snapshotName + " to table=" + tableName);
647654
restoreStoreFile(familyDir, snapshotRegionInfo, storeFile, createBackRefs);
648655
}
649656
}

hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotManifest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ public void addMobRegion(RegionInfo regionInfo) throws IOException {
185185
@VisibleForTesting
186186
protected void addMobRegion(RegionInfo regionInfo, RegionVisitor visitor) throws IOException {
187187
// 1. dump region meta info into the snapshot directory
188-
LOG.debug("Storing mob region '" + regionInfo + "' region-info for snapshot.");
188+
final String snapshotName = desc.getName();
189+
LOG.debug("Storing mob region '" + regionInfo + "' region-info for snapshot=" + snapshotName);
189190
Object regionData = visitor.regionOpen(regionInfo);
190191
monitor.rethrowException();
191192

@@ -232,7 +233,8 @@ public void addRegion(final HRegion region) throws IOException {
232233
@VisibleForTesting
233234
protected void addRegion(final HRegion region, RegionVisitor visitor) throws IOException {
234235
// 1. dump region meta info into the snapshot directory
235-
LOG.debug("Storing '" + region + "' region-info for snapshot.");
236+
final String snapshotName = desc.getName();
237+
LOG.debug("Storing '" + region + "' region-info for snapshot=" + snapshotName);
236238
Object regionData = visitor.regionOpen(region.getRegionInfo());
237239
monitor.rethrowException();
238240

@@ -256,7 +258,8 @@ protected void addRegion(final HRegion region, RegionVisitor visitor) throws IOE
256258
monitor.rethrowException();
257259

258260
// create "reference" to this store file.
259-
LOG.debug("Adding reference for file (" + (i+1) + "/" + sz + "): " + storeFile.getPath());
261+
LOG.debug("Adding reference for file (" + (i+1) + "/" + sz + "): " + storeFile.getPath() +
262+
" for snapshot=" + snapshotName);
260263
visitor.storeFile(regionData, familyData, storeFile.getFileInfo());
261264
}
262265
visitor.familyClose(regionData, familyData);

0 commit comments

Comments
 (0)