Checkpoints
A checkpoint is persisted state of a running streaming query, used to recover processing after failures. YDB periodically checkpoints all running streaming queries.
Checkpoint contents
A checkpoint contains:
- Offsets in input topics — positions up to which events were read and processed;
- Aggregation state — intermediate results such as accumulators for GROUP BY HOP.
YDB stores read offsets in its own checkpoints and does not rely on external consumer offsets. When a query is removed (DROP STREAMING QUERY), offsets are removed with the checkpoint — external systems are not aware how far the query read in the topic.
Recovery after failure
When processing fails (compute node restart, network interruption, timeout), the query restarts automatically and restores state from the latest checkpoint: it resumes reading from saved offsets and restores aggregation state.
Events that arrived between the last checkpoint and the failure are processed again. That provides at-least-once delivery — each event is processed at least once.
Saving and selecting checkpoints for recovery is automatic. Old checkpoints are removed after a new one is saved successfully.
Checkpoint deleted when recreating a query
When you delete a query (DROP STREAMING QUERY), its checkpoint is deleted with it. Because offsets live only in the checkpoint, a new query (CREATE STREAMING QUERY) has no saved position and starts reading from the end of the topic. Events that arrived between deleting the old query and starting the new one are not read.
The same happens if data referenced by an offset in the checkpoint has already been removed from the topic due to TTL.
For how this affects delivery guarantees, see Lost events when recreating a query.
Disabling checkpoints
To reduce overhead, you can disable checkpointing with pragma ydb.DisableCheckpoints.
Warning
With checkpoints disabled there are no consistency guarantees across user or internal restarts. Use only for debugging.
CREATE STREAMING QUERY query_without_checkpoints AS
DO BEGIN
PRAGMA ydb.DisableCheckpoints = "TRUE";
INSERT INTO
ydb_source.output_topic
SELECT
*
FROM
ydb_source.input_topic;
END DO
See also
- Delivery guarantees — delivery guarantees and anomalies.
- Streaming queries — streaming queries overview.