smengcl commented on code in PR #4418:
URL: https://github.com/apache/ozone/pull/4418#discussion_r1144115232
##########
hadoop-hdds/rocksdb-checkpoint-differ/src/main/java/org/apache/ozone/rocksdiff/RocksDBCheckpointDiffer.java:
##########
@@ -400,13 +403,58 @@ public void setRocksDBForCompactionTracking(DBOptions
rocksOptions)
setRocksDBForCompactionTracking(rocksOptions, new ArrayList<>());
}
+ /**
+ * Set SnapshotInfoTable DB column family handle to be used in DB listener.
+ * @param snapshotInfoTableCFHandle ColumnFamilyHandle
+ */
+ public void setSnapshotInfoTableCFHandle(
+ ColumnFamilyHandle snapshotInfoTableCFHandle) {
+ Preconditions.checkNotNull(snapshotInfoTableCFHandle,
+ "Column family handle should not be null");
+ this.snapshotInfoTableCFHandle = snapshotInfoTableCFHandle;
+ }
+
+ /**
+ * Helper method to check whether the SnapshotInfoTable column family is
empty
+ * in a given DB instance.
+ * @param db RocksDB instance
+ * @return true when column family is empty, false otherwise
+ */
+ private boolean isSnapshotInfoTableEmpty(RocksDB db) {
+ // Can't use metadataManager.getSnapshotInfoTable().isEmpty() or use
+ // any wrapper classes here. Any of those introduces circular dependency.
+ // The solution here is to use raw RocksDB API.
+
+ // There is this small gap when the db is open but the handle is not yet
set
+ // in RDBStore. Compaction could theoretically happen during that small
+ // window. This condition here aims to handle that (falls back to not
+ // skipping compaction tracking).
+ if (snapshotInfoTableCFHandle == null) {
+ LOG.warn("Snapshot info table column family handle is not set!");
+ // Proceed to log compaction in this case
+ return false;
+ }
+
+ // SnapshotInfoTable has table cache, but it wouldn't matter in this case.
Review Comment:
On a second thought we probably do want to check the SnapshotInfoTable table
cache in the case where a snapshot is just "created" in and [added to table
cache](https://github.com/apache/ozone/blob/c7de8d5871209a86e79f8422c6334697b32f113a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/snapshot/OMSnapshotCreateRequest.java#L173-L175)
in `OMSnapshotCreateRequest`, provided we move thing around.
However, [actual
checkpointing](https://github.com/apache/ozone/blob/c7de8d5871209a86e79f8422c6334697b32f113a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/response/snapshot/OMSnapshotCreateResponse.java#L65-L77)
won't happen until double buffer is flushed (albeit should happen very soon as
the flush daemon would be
[signaled](https://github.com/apache/ozone/blob/886fc3d419e07a5736a2112fd748c3b212c2f11f/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerDoubleBuffer.java#L604-L616)).
--
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]