Structured Streaming checkpoint portability between local file system and distributed storage
0 reputation · 24 Nov 2020, 16:17 UTC
0 reputation · 24 Nov 2020, 16:17 UTC
Evaluating Structured Streaming state management and checkpointing for fault tolerance in a test integration without production credentials. The goal is to understand how checkpoint metadata and state snapshots behave when a stateful aggregation is exercised against a local file system checkpoint location rather than a production distributed file system.
The relevant constraints are the need to test exactly-once semantics and state recovery without access to HDFS or S3, and the uncertainty around whether checkpoint format and state store persistence are independent of the underlying file system. State cleanup via watermarking and the RocksDB state store provider are part of the design consideration for bounded state growth.
Is checkpoint directory content portable between a local file system and a distributed file system for the same query definition? Does the RocksDB state store provider produce state snapshots that are readable after a change in checkpoint storage backend? What determines safe watermark configuration for state cleanup when checkpointing to a local file system during testing?
34775 reputation · 24 Nov 2020, 21:59 UTC
Yes – the checkpoint directory written by Structured Streaming is portable between a local filesystem and a distributed filesystem (HDFS, S3, etc.) for the same query definition, and the RocksDB state store files can be read after moving the directory, provided the Spark/Structured Streaming version and dependent libraries match.
checkpointLocation to that directory, regardless of whether the directory resides on local disk or a distributed store.The portability stems from Structured Streaming treating the checkpoint location as an opaque URI; it writes files using Hadoop’s FileSystem API, which abstracts the underlying storage. RocksDB stores state as platform‑independent SST and log files, so moving the directory does not alter the binary format. Watermark logic lives in the query plan and does not interact with the filesystem.
file:///tmp/ss-checkpoint). Process a few batches, then stop the query.hdfs://namenode:8020/ss-checkpoint or an S3 bucket) using distcp, aws s3 sync, or a simple cp if mounted.checkpointLocation to the copied URI.Resuming from checkpoint and metric numInputRows matching the previous run).LOG, MANIFEST-*.ldb, *.sst) and metadata files (offsets, commit).Choose a watermark delay that reflects the latency you observe in the test data stream. For example, if your test source emits events with at most 5 seconds of out‑of‑orderness, set withWatermark('eventTime', '5 seconds'). The delay does not need to be adjusted when switching between local and distributed checkpoints.
To give a definitive recommendation, please confirm the Spark/Structured Streaming version (e.g., 3.5.0) used for both the original checkpoint‑writing job and the job that reads the copied checkpoint. Version mismatches can cause deserialization errors even though the filesystem is the same.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.