<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Streaming_checkpoint</id>
	<title>Streaming checkpoint - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Streaming_checkpoint"/>
	<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Streaming_checkpoint&amp;action=history"/>
	<updated>2026-12-06T00:13:31Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://openlakehouse.io/w/index.php?title=Streaming_checkpoint&amp;diff=208&amp;oldid=prev</id>
		<title>Open Lakehouse Wiki sync: Sync from open-lakehouse/wiki@7c9abaa</title>
		<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Streaming_checkpoint&amp;diff=208&amp;oldid=prev"/>
		<updated>2026-11-25T00:53:00Z</updated>

		<summary type="html">&lt;p&gt;Sync from open-lakehouse/wiki@7c9abaa&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox concept&lt;br /&gt;
| name            = Streaming checkpoint&lt;br /&gt;
| also_known_as   = Checkpoint location, &amp;lt;code&amp;gt;checkpointLocation&amp;lt;/code&amp;gt;&lt;br /&gt;
| field           = [[Stream processing]]&lt;br /&gt;
| key_parts       = Offset log (&amp;lt;code&amp;gt;offsets/&amp;lt;/code&amp;gt;), commit log (&amp;lt;code&amp;gt;commits/&amp;lt;/code&amp;gt;), state (&amp;lt;code&amp;gt;state/&amp;lt;/code&amp;gt;), query metadata (&amp;lt;code&amp;gt;metadata&amp;lt;/code&amp;gt;)&lt;br /&gt;
| implementations = [[Structured Streaming]] in [[Apache Spark]]&lt;br /&gt;
| related         = [[Checkpointing (Spark)]], [[State store]], [[Exactly-once semantics]], [[Flink checkpoint and savepoint]]&lt;br /&gt;
}}&lt;br /&gt;
{{Verified|2026-11-23|the Spark 4.3.0 Structured Streaming programming guide (recovering from failures, recovery semantics after changes) and miscellaneous notes, and &amp;lt;code&amp;gt;StreamingCheckpointConstants.scala&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StreamingQueryCheckpointMetadata.scala&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;StreamMetadata.scala&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;CommitLog.scala&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;OffsetSeq.scala&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SQLConf.scala&amp;lt;/code&amp;gt; at tag v4.3.0 of apache/spark, the Delta Lake table streaming documentation and the Apache Flink 2.3 &amp;quot;Checkpoints vs. Savepoints&amp;quot; page}}&lt;br /&gt;
&lt;br /&gt;
In [[Apache Spark]] [[Structured Streaming]], a &amp;#039;&amp;#039;&amp;#039;streaming checkpoint&amp;#039;&amp;#039;&amp;#039; is the directory, set with the &amp;lt;code&amp;gt;checkpointLocation&amp;lt;/code&amp;gt; option, where a streaming query records which input offsets each micro-batch covered, which batches finished, and the state of its stateful operators, so that after a failure or a restart the query continues exactly where it stopped.&amp;lt;ref name=&amp;quot;ss-ckpt&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/streaming/apis-on-dataframes-and-datasets.html#recovering-from-failures-with-checkpointing |title=Structured Streaming: Recovering from Failures with Checkpointing (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; A checkpoint belongs to one query. Some changes to the query can be made between restarts from the same checkpoint and others cannot. Lineage checkpoints of RDDs and DataFrames are a different feature; see [[Checkpointing (Spark)]].&lt;br /&gt;
&lt;br /&gt;
== What is inside a streaming checkpoint? ==&lt;br /&gt;
At tag v4.3.0, Spark names four entries under the checkpoint root: &amp;lt;code&amp;gt;offsets&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;commits&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;state&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;metadata&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;consts&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/runtime/StreamingCheckpointConstants.scala |title=StreamingCheckpointConstants.scala (Apache Spark v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Entry !! Contents !! Written&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;offsets/&amp;lt;/code&amp;gt;&lt;br /&gt;
| The offset log: one file per batch with the offsets of every source for that batch, plus a set of session configurations that must stay fixed for the query&amp;lt;ref name=&amp;quot;offsetseq&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/checkpointing/OffsetSeq.scala |title=OffsetSeq.scala (Apache Spark v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
| Before the batch is processed&amp;lt;ref name=&amp;quot;commitlog&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/checkpointing/CommitLog.scala |title=CommitLog.scala (Apache Spark v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;commits/&amp;lt;/code&amp;gt;&lt;br /&gt;
| The commit log: one file per batch that marks the batch as complete&amp;lt;ref name=&amp;quot;commitlog&amp;quot; /&amp;gt;&lt;br /&gt;
| After the batch succeeds, before the next batch starts&amp;lt;ref name=&amp;quot;commitlog&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;state/&amp;lt;/code&amp;gt;&lt;br /&gt;
| Versioned files of the [[state store]], per stateful operator and partition&lt;br /&gt;
| At the end of each batch of a stateful query&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;metadata&amp;lt;/code&amp;gt;&lt;br /&gt;
| The query&amp;#039;s unique id, which stays the same across restarts&amp;lt;ref name=&amp;quot;streammeta&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/runtime/StreamMetadata.scala |title=StreamMetadata.scala (Apache Spark v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
| When the query first starts&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The order of writes is what makes recovery work. For each batch, Spark writes the batch&amp;#039;s offsets to the offset log, processes the batch, and then writes the batch to the commit log.&amp;lt;ref name=&amp;quot;commitlog&amp;quot; /&amp;gt; On restart, a batch that has an offset entry but no commit entry is run again with exactly the same offsets. Combined with a replayable source and an idempotent or transactional sink, this gives the end-to-end guarantee described in [[Exactly-once semantics]].&lt;br /&gt;
&lt;br /&gt;
Spark keeps a bounded history. &amp;lt;code&amp;gt;spark.sql.streaming.minBatchesToRetain&amp;lt;/code&amp;gt; (default 100, since 2.1.1) is the minimum number of batches that stay recoverable; state, offset and commit log files older than that are eligible for cleanup.&amp;lt;ref name=&amp;quot;sqlconf&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala |title=SQLConf.scala (Apache Spark v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The checkpoint location must be a path in an HDFS-compatible, fault-tolerant file system, such as HDFS or an object store.&amp;lt;ref name=&amp;quot;ss-ckpt&amp;quot; /&amp;gt; &amp;lt;code&amp;gt;spark.sql.streaming.checkpointLocation&amp;lt;/code&amp;gt; sets a default parent directory for queries that do not set the option.&amp;lt;ref name=&amp;quot;sqlconf&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== What is safe to change between restarts? ==&lt;br /&gt;
The Spark guide lists which query changes are allowed when restarting from the same checkpoint. &amp;quot;Allowed&amp;quot; means the query starts, but whether the result is well defined depends on the change; &amp;quot;not allowed&amp;quot; means the restart is likely to fail with unpredictable errors.&amp;lt;ref name=&amp;quot;ss-changes&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/streaming/apis-on-dataframes-and-datasets.html#recovery-semantics-after-changes-in-a-streaming-query |title=Structured Streaming: Recovery Semantics after Changes in a Streaming Query (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Change !! Verdict !! Example&lt;br /&gt;
|-&lt;br /&gt;
| Number or type of input sources || Not allowed || Adding a second Kafka source&lt;br /&gt;
|-&lt;br /&gt;
| Source rate limits || Allowed || Adding &amp;lt;code&amp;gt;maxOffsetsPerTrigger&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Subscribed topics or input files || Generally not allowed || &amp;lt;code&amp;gt;subscribe&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;topic&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;newTopic&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Sink type || Some combinations || File sink to Kafka sink is allowed; Kafka sink to file sink is not&lt;br /&gt;
|-&lt;br /&gt;
| File sink output directory || Not allowed || Changing &amp;lt;code&amp;gt;path&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Kafka sink topic || Allowed || Changing &amp;lt;code&amp;gt;topic&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Filters and projections || Allowed; a different output schema only if the sink accepts it || Adding a &amp;lt;code&amp;gt;where&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Stateful operators (aggregation keys or aggregates, deduplication columns, stream-stream join type or keys, user state schema) || Not allowed || Adding a grouping column&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some configurations are also fixed for the life of a checkpoint. The Spark notes name &amp;lt;code&amp;gt;spark.sql.shuffle.partitions&amp;lt;/code&amp;gt; (state is hash-partitioned by key, so the number of state partitions cannot change), &amp;lt;code&amp;gt;spark.sql.streaming.stateStore.providerClass&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;spark.sql.streaming.multipleWatermarkPolicy&amp;lt;/code&amp;gt;; to change them, start a new query with a new checkpoint.&amp;lt;ref name=&amp;quot;misc&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/streaming/additional-information.html |title=Structured Streaming: Miscellaneous Notes (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; Spark stores the values of these and other state-related configurations in the offset log and reuses them on restart, whatever the session sets.&amp;lt;ref name=&amp;quot;offsetseq&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[transformWithState]] is an exception for user state: state variables can be added and removed between runs, and with &amp;lt;code&amp;gt;spark.sql.streaming.stateStore.encodingFormat&amp;lt;/code&amp;gt; set to &amp;lt;code&amp;gt;avro&amp;lt;/code&amp;gt;, fields of a state variable&amp;#039;s value can be added, removed, widened or reordered.&amp;lt;ref name=&amp;quot;tws&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/streaming/structured-streaming-transform-with-state.html#state-schema-evolution |title=Structured Streaming: transformWithState, State Schema Evolution (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== What happens if the checkpoint is deleted? ==&lt;br /&gt;
Without its checkpoint, a query starts as a new query: sources start from their configured starting position, state is empty, and batch ids start again from 0. Sinks that deduplicate by batch id must be told. The [[Delta Lake]] documentation warns that a query restarted with a new checkpoint must use a different &amp;lt;code&amp;gt;txnAppId&amp;lt;/code&amp;gt; in [[foreachBatch]] writes; otherwise its writes are ignored as duplicates.&amp;lt;ref name=&amp;quot;delta&amp;quot;&amp;gt;{{Cite web |url=https://docs.delta.io/latest/delta-streaming.html |title=Table streaming reads and writes |publisher=Delta Lake (Linux Foundation) |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Delta Lake&amp;#039;s &amp;lt;code&amp;gt;VACUUM&amp;lt;/code&amp;gt; skips directories whose names begin with an underscore, so a checkpoint can be kept next to the table it writes, for example in &amp;lt;code&amp;gt;&amp;amp;lt;table&amp;amp;gt;/_checkpoints&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;delta&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
(spark.readStream.format(&amp;quot;kafka&amp;quot;)&lt;br /&gt;
    .option(&amp;quot;kafka.bootstrap.servers&amp;quot;, &amp;quot;broker:9092&amp;quot;)&lt;br /&gt;
    .option(&amp;quot;subscribe&amp;quot;, &amp;quot;orders&amp;quot;)&lt;br /&gt;
    .option(&amp;quot;maxOffsetsPerTrigger&amp;quot;, 100000)   # safe to change between restarts&lt;br /&gt;
    .load()&lt;br /&gt;
    .writeStream&lt;br /&gt;
    .option(&amp;quot;checkpointLocation&amp;quot;, &amp;quot;s3a://lake/checkpoints/orders_bronze&amp;quot;)&lt;br /&gt;
    .toTable(&amp;quot;main.sales.orders_bronze&amp;quot;))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Comparison with Flink checkpoints ==&lt;br /&gt;
[[Apache Flink]] also uses the word checkpoint. A Flink checkpoint is a recovery mechanism for unexpected job failures; Flink creates, owns and releases it without user action, and deletes it when the user terminates the job unless retention is configured. A Flink &amp;#039;&amp;#039;&amp;#039;savepoint&amp;#039;&amp;#039;&amp;#039; is created with the same mechanism but is owned by the user and designed for portability, for example for upgrades and redeployment; the Flink documentation compares the two to backups and recovery logs in a database.&amp;lt;ref name=&amp;quot;flink-cvs&amp;quot;&amp;gt;{{Cite web |url=https://nightlies.apache.org/flink/flink-docs-release-2.3/docs/ops/state/checkpoints_vs_savepoints/ |title=Checkpoints vs. Savepoints (Apache Flink 2.3) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; See [[Flink checkpoint and savepoint]].&lt;br /&gt;
&lt;br /&gt;
A Spark streaming checkpoint is closer to a retained Flink checkpoint: it is a directory the user names, it stays after the query stops, and a restarted or changed query reads it, within the limits listed above.&amp;lt;ref name=&amp;quot;ss-ckpt&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;ss-changes&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Checkpointing (Spark)]]&lt;br /&gt;
* [[State store]]&lt;br /&gt;
* [[Exactly-once semantics]]&lt;br /&gt;
* [[Structured Streaming]]&lt;br /&gt;
* [[Trigger (Structured Streaming)]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Navbox open lakehouse}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Concepts]]&lt;br /&gt;
[[Category:Glossary terms]]&lt;br /&gt;
[[Category:Apache Spark]]&lt;br /&gt;
[[Category:Pipelines and orchestration]]&lt;/div&gt;</summary>
		<author><name>Open Lakehouse Wiki sync</name></author>
	</entry>
</feed>