smengcl opened a new pull request, #12171: URL: https://github.com/apache/ozone/pull/12171
Generated-by: Claude Code (Opus 5.5) ## What changes were proposed in this pull request? With incremental snapshot defrag, the SST file list in each snapshot local data YAML file (`db.snapshots/checkpointState/om.db-<id>.yaml`) keeps growing, so the total size of these files grows quadratically with the number of snapshots. On a test cluster with 40K snapshots they took about 945 GB on each OM. HDDS-17934 tracks the growth itself. This PR makes the files about 22x smaller by compressing them with zstd. - Once the new OM version `SNAPSHOT_LOCAL_DATA_ZSTD` is finalized, OM writes snapshot local data YAML files compressed with zstd level 1. Before finalization it keeps writing plain YAML, so downgrade keeps working. - Reads detect the zstd magic bytes, so plain and compressed files are accepted at any time. - After finalization, the existing snapshot local data manager service (`ozone.om.snapshot.local.data.manager.service.interval`, default 5m) compresses the files written before finalization. It compresses the raw bytes in place under the write lock of the snapshot, without parsing them, so the stored checksum stays valid. Every run checks all files, so a file written plain while finalization was in progress is not missed. - Writes go through an atomic temporary file. A failed write keeps the previous file. - `zstd-jni` is already part of the distribution (managed in the root pom, used by `container-service`); `ozone-manager` now depends on it directly. Level 1 was chosen by compressing a sample of YAML files from the 40K snapshot cluster: | Codec | Ratio | Compress | Decompress | |---|---|---|---| | zstd -1 | 21.7x | 697 MB/s | 1714 MB/s | | zstd -3 | 19.0x | 482 MB/s | 1446 MB/s | | zstd -9 | 22.2x | 99 MB/s | | | gzip -6 | 20.1x | 99 MB/s | 258 MB/s | Like other OM version gates, the check happens when a file is written: a file written after the finalize request is applied but before it is flushed is already compressed. ## What is the link to the Apache JIRA https://issues.apache.org/jira/browse/HDDS-17934 ## How was this patch tested? - New unit tests in `TestOmSnapshotLocalDataYaml` and `TestOmSnapshotLocalDataManager`: compressing in place keeps the checksum, compressed round trip, a truncated compressed file fails to load, a failed write keeps the previous file and leaves no temporary file, files stay plain before finalization, plain and compressed files both load at startup, and old files are compressed after finalization with unchanged checksums. - The upgrade acceptance test (2.2.2 to current, HA, non-rolling) now checks the YAML files on every OM: all plain while pre-finalized (2.2.2 then reads them after the downgrade), and all compressed after finalization. Ran it locally, 145 tests passed. Each OM logged `Compressed 4 snapshot local data YAML files, 0 failed` about 10 seconds after finalization, and the snapshot created after finalization was written compressed. - Manually restarted the 3 OMs of the finalized cluster: they started with the compressed files, read keys from all 5 earlier snapshots, ran a snapshot diff, and wrote the new snapshot YAML compressed. - `snapshot-defrag.robot` (compose/ozone) now decompresses the YAML file before checking it. The suite passed locally, where the YAML check is skipped because the macOS build has no rocks-tools native library, so the decompress step was also run in the runner image against a compressed YAML file from the upgrade test. - CI on fork: https://github.com/smengcl/hadoop-ozone/actions/runs/45764108300 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
