-
Notifications
You must be signed in to change notification settings - Fork 623
HDDS-14876. Make snapshot diff progress more granular #10901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -62,6 +62,7 @@ | |||||||
| import static org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse.SubStatus.DIFF_REPORT_GEN; | ||||||||
| import static org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse.SubStatus.OBJECT_ID_MAP_GEN_FSO; | ||||||||
| import static org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse.SubStatus.OBJECT_ID_MAP_GEN_OBS; | ||||||||
| import static org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse.SubStatus.PATH_RESOLUTION_FSO; | ||||||||
|
|
||||||||
| import com.google.common.annotations.VisibleForTesting; | ||||||||
| import com.google.common.collect.ImmutableMap; | ||||||||
|
|
@@ -141,6 +142,7 @@ | |||||||
| import org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse.SubStatus; | ||||||||
| import org.apache.hadoop.ozone.snapshot.SubmitSnapshotDiffResponse; | ||||||||
| import org.apache.hadoop.ozone.util.ClosableIterator; | ||||||||
| import org.apache.hadoop.util.Time; | ||||||||
| import org.apache.logging.log4j.util.Strings; | ||||||||
| import org.apache.ozone.rocksdb.util.SstFileInfo; | ||||||||
| import org.apache.ozone.rocksdiff.RocksDBCheckpointDiffer; | ||||||||
|
|
@@ -1112,27 +1114,27 @@ void generateSnapshotDiffReport(final String jobKey, | |||||||
| // repetition while constantly checking if the job is cancelled. | ||||||||
| Callable<Void>[] methodCalls = new Callable[]{ | ||||||||
| () -> { | ||||||||
| recordActivity(jobKey, OBJECT_ID_MAP_GEN_OBS); | ||||||||
| getDeltaFilesAndDiffKeysToObjectIdToKeyMap(fsKeyTable, tsKeyTable, | ||||||||
| fsInfo, tsInfo, performNonNativeDiff, tablePrefixes, | ||||||||
| objectIdToKeyNameMapForFromSnapshot, | ||||||||
| objectIdToKeyNameMapForToSnapshot, objectIdToIsDirMap, | ||||||||
| oldParentIds, newParentIds, deltaFileComputer, jobKey); | ||||||||
| oldParentIds, newParentIds, deltaFileComputer, jobKey, jobId); | ||||||||
| return null; | ||||||||
| }, | ||||||||
| () -> { | ||||||||
| if (bucketLayout.isFileSystemOptimized()) { | ||||||||
| recordActivity(jobKey, OBJECT_ID_MAP_GEN_FSO); | ||||||||
| getDeltaFilesAndDiffKeysToObjectIdToKeyMap(fsDirTable, tsDirTable, | ||||||||
| fsInfo, tsInfo, performNonNativeDiff, tablePrefixes, | ||||||||
| objectIdToKeyNameMapForFromSnapshot, | ||||||||
| objectIdToKeyNameMapForToSnapshot, objectIdToIsDirMap, | ||||||||
| oldParentIds, newParentIds, deltaFileComputer, jobKey); | ||||||||
| oldParentIds, newParentIds, deltaFileComputer, jobKey, jobId); | ||||||||
| } | ||||||||
| return null; | ||||||||
| }, | ||||||||
| () -> { | ||||||||
| if (bucketLayout.isFileSystemOptimized()) { | ||||||||
| recordActivity(jobKey, PATH_RESOLUTION_FSO); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Progress capture for |
||||||||
| long pathResolutionStart = Time.monotonicNow(); | ||||||||
| long bucketId = toSnapshot.getMetadataManager() | ||||||||
| .getBucketId(volumeName, bucketName); | ||||||||
| String tablePrefix = tablePrefixes.getTablePrefix(fromSnapshot.getMetadataManager() | ||||||||
|
|
@@ -1145,11 +1147,19 @@ void generateSnapshotDiffReport(final String jobKey, | |||||||
| tablePrefix, bucketId, | ||||||||
| toSnapshot.getMetadataManager().getDirectoryTable()) | ||||||||
| .getAbsolutePathForObjectIDs(newParentIds, true)); | ||||||||
| if (LOG.isDebugEnabled()) { | ||||||||
| LOG.debug("Completed FSO path resolution for snapshot diff, resolved {} out of {} parent IDs, " + | ||||||||
| "elapsed: {}ms, jobId: {}", | ||||||||
| oldParentIdPathMap.get().size() + newParentIdPathMap.get().size(), | ||||||||
| oldParentIds.get().size() + newParentIds.get().size(), | ||||||||
| Time.monotonicNow() - pathResolutionStart, jobId); | ||||||||
| } | ||||||||
| } | ||||||||
| return null; | ||||||||
| }, | ||||||||
| () -> { | ||||||||
| recordActivity(jobKey, DIFF_REPORT_GEN); | ||||||||
| long reportGenStart = Time.monotonicNow(); | ||||||||
| Pair<Long, String> reportEntries = generateDiffReport(jobId, | ||||||||
| fsKeyTable, | ||||||||
| tsKeyTable, | ||||||||
|
|
@@ -1166,6 +1176,10 @@ void generateSnapshotDiffReport(final String jobKey, | |||||||
| if (reportEntries.getKey() >= 0 && | ||||||||
| areDiffJobAndSnapshotsActive(volumeName, bucketName, | ||||||||
| fromSnapshotName, toSnapshotName)) { | ||||||||
| if (LOG.isDebugEnabled()) { | ||||||||
| LOG.debug("Generated snapshot diff report, entry count: {}, elapsed: {}ms, jobId: {}", | ||||||||
| reportEntries.getKey(), Time.monotonicNow() - reportGenStart, jobId); | ||||||||
| } | ||||||||
| updateJobStatusToDone(jobKey, reportEntries.getKey(), reportEntries.getValue()); | ||||||||
| } | ||||||||
| return null; | ||||||||
|
|
@@ -1221,17 +1235,22 @@ private void getDeltaFilesAndDiffKeysToObjectIdToKeyMap( | |||||||
| final PersistentMap<byte[], byte[]> newObjIdToKeyMap, | ||||||||
| final PersistentMap<byte[], Boolean> objectIdToIsDirMap, | ||||||||
| final Optional<Set<Long>> oldParentIds, final Optional<Set<Long>> newParentIds, | ||||||||
| final DeltaFileComputer deltaFileComputer, final String jobKey) throws IOException, RocksDBException { | ||||||||
| final DeltaFileComputer deltaFileComputer, final String jobKey, | ||||||||
| final String jobId) throws IOException, RocksDBException { | ||||||||
|
|
||||||||
| long deltaFilesStart = Time.monotonicNow(); | ||||||||
| Set<String> tablesToLookUp = Collections.singleton(fsTable.getName()); | ||||||||
| Collection<Pair<Path, SstFileInfo>> deltaFiles = deltaFileComputer.getDeltaFiles(fsInfo, tsInfo, | ||||||||
| tablesToLookUp); | ||||||||
| if (LOG.isDebugEnabled()) { | ||||||||
| LOG.debug("Computed Delta SST File Set, Total count = {} ", deltaFiles.size()); | ||||||||
| LOG.debug("Computed Delta SST File Set for table '{}', file count: {}, elapsed: {}ms, jobId: {}", | ||||||||
| fsTable.getName(), deltaFiles.size(), Time.monotonicNow() - deltaFilesStart, jobId); | ||||||||
| } | ||||||||
| recordActivity(jobKey, | ||||||||
| fsTable.getName().equals(DIRECTORY_TABLE) ? OBJECT_ID_MAP_GEN_FSO : OBJECT_ID_MAP_GEN_OBS); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the path @rhalm. The sub status here would be |
||||||||
| addToObjectIdMap(fsTable, tsTable, deltaFiles.stream().map(Pair::getLeft).collect(Collectors.toList()), | ||||||||
| !skipNativeDiff, oldObjIdToKeyMap, newObjIdToKeyMap, objectIdToIsDirMap, oldParentIds, | ||||||||
| newParentIds, tablePrefixes, jobKey); | ||||||||
| newParentIds, tablePrefixes, jobKey, jobId); | ||||||||
| } | ||||||||
|
|
||||||||
| @VisibleForTesting | ||||||||
|
|
@@ -1244,10 +1263,14 @@ void addToObjectIdMap(Table<String, ? extends WithParentObjectId> fsTable, | |||||||
| PersistentMap<byte[], Boolean> objectIdToIsDirMap, | ||||||||
| Optional<Set<Long>> oldParentIds, | ||||||||
| Optional<Set<Long>> newParentIds, | ||||||||
| TablePrefixInfo tablePrefixes, String jobKey) throws IOException, RocksDBException { | ||||||||
| TablePrefixInfo tablePrefixes, String jobKey, | ||||||||
| String jobId) throws IOException, RocksDBException { | ||||||||
| updateProgress(jobKey, 0.0); | ||||||||
| if (deltaFiles.isEmpty()) { | ||||||||
| return; | ||||||||
| } | ||||||||
| long objectIdMapStart = Time.monotonicNow(); | ||||||||
| AtomicLong keysProcessed = new AtomicLong(0); | ||||||||
| String tablePrefix = tablePrefixes.getTablePrefix(fsTable.getName()); | ||||||||
| boolean isDirectoryTable = fsTable.getName().equals(DIRECTORY_TABLE); | ||||||||
| SstFileSetReader sstFileReader = new SstFileSetReader(deltaFiles); | ||||||||
|
|
@@ -1266,7 +1289,6 @@ void addToObjectIdMap(Table<String, ? extends WithParentObjectId> fsTable, | |||||||
| : sstFileReader.getKeyStream(sstFileReaderLowerBound, sstFileReaderUpperBound); | ||||||||
| TableMergeIterator<String, WithParentObjectId> tableMergeIterator = new TableMergeIterator<>(keysToCheck, | ||||||||
| tablePrefix, (Table<String, WithParentObjectId>) fsTable, (Table<String, WithParentObjectId>) tsTable)) { | ||||||||
| AtomicLong keysProcessed = new AtomicLong(0); | ||||||||
| while (tableMergeIterator.hasNext()) { | ||||||||
| Table.KeyValue<String, List<WithParentObjectId>> kvs = tableMergeIterator.next(); | ||||||||
| String key = kvs.getKey(); | ||||||||
|
|
@@ -1312,6 +1334,10 @@ void addToObjectIdMap(Table<String, ? extends WithParentObjectId> fsTable, | |||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In most cases
Suggested change
|
||||||||
| if (LOG.isDebugEnabled()) { | ||||||||
| LOG.debug("Generated object ID map for table '{}', keys scanned: {}, elapsed: {}ms, jobId: {}", | ||||||||
| fsTable.getName(), keysProcessed.get(), Time.monotonicNow() - objectIdMapStart, jobId); | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| private void validateEstimatedKeyChangesAreInLimits( | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may need to add this in
hadoop-ozone/interface-client/src/main/resources/proto.lockas well.