Skip to content

HDDS-13218. Add integration tests for snapshot defrag checkpoint footprint savings - #11094

Open
arunsarin85 wants to merge 3 commits into
apache:masterfrom
arunsarin85:HDDS-13218
Open

HDDS-13218. Add integration tests for snapshot defrag checkpoint footprint savings#11094
arunsarin85 wants to merge 3 commits into
apache:masterfrom
arunsarin85:HDDS-13218

Conversation

@arunsarin85

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

  • Adds TestOmSnapshotDefragSpaceSavings, a new integration test class validating that snapshot defrag reduces checkpoint disk footprint.
  • Covers OBS and FSO bucket layouts, full vs incremental defrag paths, middle-snapshot purge with re-defrag, single-snapshot full defrag, and repeated defrag idempotency.

Please describe your PR in detail:
Added correctness coverage in TestOmSnapshotCheckpointDbContent; this PR adds space savings / footprint coverage in a separate test class.

Measurement approach

  • Version-0 checkpoints hardlink to AOS SST files, so their on-disk byte totals are not comparable to materialized post-defrag checkpoints.
  • Savings are validated by cross-snapshot SST reference reduction: duplicate-inclusive pre-defrag totals (each snapshot counted independently) vs inode-deduped post-defrag chain totals.
  • Footprint helpers mirror OMSnapshotDirectoryMetrics inode deduplication so hardlinked SSTs are not double-counted across snapshot dirs.

Test scenarios (4 tests)

Test Scenario
testSnapshotDefragReducesCheckpointFootprintWithChurn Three-snapshot chain (S1/S2/S3) with AOS compactDB() plus insert/overwrite/delete churn. Runs on OBS, then after restartCluster() on FSO. Asserts SST redundancy drops after defrag. OBS pass also verifies one full defrag (chain head) and two incremental defrags (S2, S3) via OmSnapshotInternalMetrics and pathPreviousSnapshotId.
testObsSnapshotDefragReducesFootprintAfterMiddleSnapshotPurge After initial defrag on a three-snapshot OBS chain, deletes middle snapshot S2, waits for purge, triggers follow-up defrag on S3. Asserts S3 footprint does not grow materially and the remaining S1+S3 chain footprint shrinks vs the original three-snapshot chain.
testObsSingleSnapshotFullDefragReducesCheckpointFootprint Lone OBS snapshot with churn runs the full defrag path: version advances to 1, v0 checkpoint dir is removed, defrag completes (needsDefrag=false).
testObsRepeatedDefragDoesNotIncreaseCheckpointFootprint Second defrag pass on an already-defragged three-snapshot OBS chain is idempotent: bytes, SST count, and snapshot local-data versions unchanged.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-13218

(Parent epic: https://issues.apache.org/jira/browse/HDDS-13003)

How was this patch tested?

https://github.com/arunsarin85/ozone/actions/runs/32661013503

@chihsuan chihsuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! @arunsarin85 I left a couple of inline comments.

One broader thought: the suite ends up building five 3-datanode clusters, and every assertion is on OM-side checkpoint dirs, so I wonder if we can trim the runtime a bit.

I also noticed that quite a bit of the test scaffolding overlaps with TestOmSnapshotCheckpointDbContent. Consolidating the shared helpers might make a good follow-up task under HDDS-13003.

int s2Version = readSnapshotVersion(snapshots.get(1));
int s3Version = readSnapshotVersion(snapshots.get(2));

triggerDefragUntilDone(snapshots);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This second pass looks like doesn't actually runs a defrag. triggerDefragUntilDone returns early once every snapshot is already defrag-complete, which is exactly the state the first call leaves behind. Would calling om.triggerSnapshotDefrag(false) directly here work for what you had in mind?

}
try {
om.triggerSnapshotDefrag(false);
} catch (IOException e) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we preserve the last IOException while polling and include it in the timeout failure? At the moment, a real defrag error may appear as “not completed yet” and only surface as a generic timeout after 10 minutes, which could make CI failures difficult to diagnose.

*/
@Test
public void testSnapshotDefragReducesCheckpointFootprintWithChurn() throws Exception {
runChurnFootprintScenario(BucketLayout.OBJECT_STORE);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since both layouts run in one @Test and the messages in assertDefragReducedChainFootprint don't carry the layout, a CI failure wouldn't tell us whether OBS or FSO broke. Could we parameterize this test by bucket layout, or include the layout in the assertion messages?

conf.setInt(SNAPSHOT_DEFRAG_LIMIT_PER_TASK, 10);
conf.setTimeDuration(OZONE_SNAPSHOT_DELETING_SERVICE_INTERVAL, 1, TimeUnit.SECONDS);

cluster = MiniOzoneCluster.newBuilder(conf).setNumDatanodes(3).build();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Since these assertions only inspect OM checkpoint state and do not depend on block replication, could the test use a single datanode with replication factor one? This may reduce the runtime considerably, given that the suite starts several clusters.

@adoroszlai

Copy link
Copy Markdown
Contributor

One broader thought: the suite ends up building five 3-datanode clusters,

Why do we need a new cluster for each test?

@adoroszlai adoroszlai added test snapshot https://issues.apache.org/jira/browse/HDDS-6517 labels Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

snapshot https://issues.apache.org/jira/browse/HDDS-6517 test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants