wuchong commented on code in PR #1482:
URL: https://github.com/apache/fluss/pull/1482#discussion_r2329507487
##########
fluss-server/src/test/java/org/apache/fluss/server/replica/ReplicaTest.java:
##########
@@ -604,6 +704,39 @@ private void verifyGetKeyValues(
assertThat(kvTablet.multiGet(keys)).containsExactlyElementsOf(expectValues);
}
+ /**
+ * Simulate a broken snapshot by deleting its local metadata file while
keeping ZK metadata.
+ * This simulates the scenario where snapshot files are corrupted or
accidentally deleted but
+ * ZooKeeper still has the snapshot metadata.
+ */
+ private void simulateBrokenSnapshot(CompletedSnapshot snapshot) throws
Exception {
+ // Delete the snapshot metadata file (_METADATA) to simulate file
corruption
+ File metadataFile = new File(snapshot.getMetadataFilePath().getPath());
+ if (metadataFile.exists()) {
Review Comment:
The test cases can't reproduce the exception mentioned in the issue.
That's because this method doesn't correctly delete metadata and SST files,
because the file name of snapshot metadata&SST files uses UUID in remote
storage. `_METADATA` is only used when the files are in local. So all the
condition of `exists()` returns false.
We can simplify use `snapshot.getKvSnapshotHandle().discard();` to simulate
the broken snapshot. It will delete all the metadata files and unshared SST
files of this snapshot.
--
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]