swamirishi commented on code in PR #7200:
URL: https://github.com/apache/ozone/pull/7200#discussion_r1767659475
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotUtils.java:
##########
@@ -242,4 +242,44 @@ public static String
getOzonePathKeyForFso(OMMetadataManager metadataManager,
final long bucketId = metadataManager.getBucketId(volumeName, bucketName);
return OM_KEY_PREFIX + volumeId + OM_KEY_PREFIX + bucketId + OM_KEY_PREFIX;
}
+
+ /**
+ * Returns merged repeatedKeyInfo entry with the existing deleted entry in
the table.
+ * @param snapshotMoveKeyInfos keyInfos to be added.
+ * @param metadataManager metadataManager for a store.
+ * @return
+ * @throws IOException
+ */
+ public static RepeatedOmKeyInfo
createMergedRepeatedOmKeyInfoFromDeletedTableEntry(
+ OzoneManagerProtocolProtos.SnapshotMoveKeyInfos snapshotMoveKeyInfos,
OMMetadataManager metadataManager) throws
+ IOException {
+ String dbKey = snapshotMoveKeyInfos.getKey();
+ List<OmKeyInfo> keyInfoList = new ArrayList<>();
+ for (OzoneManagerProtocolProtos.KeyInfo info :
snapshotMoveKeyInfos.getKeyInfosList()) {
+ OmKeyInfo fromProtobuf = OmKeyInfo.getFromProtobuf(info);
+ keyInfoList.add(fromProtobuf);
+ }
+ // When older version of keys are moved to the next snapshot's deletedTable
+ // The newer version might also be in the next snapshot's deletedTable and
+ // it might overwrite the existing value which inturn could lead to orphan
block in the system.
+ // Checking the keyInfoList with the last n versions of the omKeyInfo
versions would ensure all versions are
+ // present in the list and would also avoid redundant additions to the
list if the last n versions match, which
+ // can happen on om transaction replay on snapshotted rocksdb.
+ RepeatedOmKeyInfo result = metadataManager.getDeletedTable().get(dbKey);
+ if (result == null) {
+ result = new RepeatedOmKeyInfo(keyInfoList);
+ } else if (!isSameAsLatestOmKeyInfo(keyInfoList, result)) {
+ keyInfoList.forEach(result::addOmKeyInfo);
+ }
+ return result;
+ }
+
+ private static boolean isSameAsLatestOmKeyInfo(List<OmKeyInfo> omKeyInfos,
Review Comment:
explained offline
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]