[SPARK-51988][SS] Do file checksum verification on read for RocksDB zip file#54493
Open
gnanda wants to merge 3 commits intoapache:masterfrom
Open
[SPARK-51988][SS] Do file checksum verification on read for RocksDB zip file#54493gnanda wants to merge 3 commits intoapache:masterfrom
gnanda wants to merge 3 commits intoapache:masterfrom
Conversation
3e55016 to
bc5b478
Compare
e3435b8 to
747a426
Compare
micheal-o
reviewed
Mar 16, 2026
.../org/apache/spark/sql/execution/streaming/state/RocksDBCheckpointFailureInjectionSuite.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/RocksDBSuite.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/state/StateStoreSuite.scala
Outdated
Show resolved
Hide resolved
b9e71ad to
9492b26
Compare
4b202f5 to
f92fb2b
Compare
…read for RocksDB zip file
f92fb2b to
cb0cd95
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
When the RocksDB state store downloads a checkpoint zip file from DFS, it previously opened the file via fs.open() (a raw Hadoop FileSystem handle), bypassing the CheckpointFileManager abstraction. This meant that even when file checksum
verification was enabled (spark.sql.streaming.stateStore.rocksdb.fileChecksumEnabled), the zip file itself was never verified against its .crc sidecar on read.
This PR fixes that by:
and CRC32C checksum on close(). If the checksum does not match, a CHECKPOINT_FILE_CHECKSUM_VERIFICATION_FAILED error is raised.
Backward compatibility is preserved: if no .crc sidecar exists (e.g. the checkpoint was written before this feature was enabled), the file is opened and read without verification.
Why are the changes needed?
Silent data corruption in checkpoint zip files would previously go undetected. A corrupted or partially-written zip could cause a state store to load incorrect data, leading to wrong query results or obscure failures. Verifying the checksum on
read closes this gap and makes corruption visible immediately at load time, with a clear error condition.
Does this PR introduce any user-facing change?
Yes. When spark.sql.streaming.stateStore.rocksdb.fileChecksumEnabled is true (the default), loading a RocksDB checkpoint zip file whose .crc sidecar does not match will now throw a SparkException with error condition
CHECKPOINT_FILE_CHECKSUM_VERIFICATION_FAILED instead of silently succeeding with corrupt data.
How was this patch tested?
CHECKPOINT_FILE_CHECKSUM_VERIFICATION_FAILED.
from the new checksum enforcement.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code 2.1.58