Study FAQ
How do I prevent and recover from a stale Snowflake stream?
Also asked as 2
- What does STALE_AFTER mean, and what can I do before and after a Snowflake stream goes stale?
- How can I keep a Snowflake stream current or recover when unconsumed changes expire?
Answer
Monitor STALE_AFTER using SHOW STREAMS or DESCRIBE STREAM and commit a qualifying consumption transaction before that time. A stream becomes stale once the source history required by its offset is unavailable. Recreate a stale stream to track new changes and handle any old gap through a separate backfill or reconciliation.
The deadline depends on source retention and any extension that applies. On eligible tables with short retention, Snowflake can temporarily extend retention to keep the offset available, by default up to 14 days under the documented conditions. MAX_DATA_EXTENSION_TIME_IN_DAYS controls the extension ceiling. Shared sources do not receive this extension. Extended retention can increase storage use, so monitor both stream lag and storage. Treat the displayed timestamp as a prediction and alert before it.
Calling SYSTEM$STREAM_HAS_DATA helps keep an empty stream from becoming stale when it returns FALSE. A plain SELECT on a stream waiting to be consumed leaves its offset in place. If it goes stale, check for a separate recoverable snapshot or source log, identify the missing interval, reconcile the target, and resume consumption using a newly created stream.
Full explanation
Snowflake SQL Transformation, Streams, Tasks, and Pipeline Patterns
Study guide · COF-C03
Read the full explanation