Module 11 · Lesson 5 of 15Detailed study · about 25 min

Independent consumers, retention and stale streams

Each independent consumer should have its own stream offset. Retention limits how long unconsumed change history remains usable.

Understand the idea

Two teams reading one stream do not get two independent acknowledgements. If team A commits a consuming write, team B cannot expect the same stream still to expose that interval. Give independent consumers separate streams.

Key ideas in simple English
ConceptWhat it means
Independent streamA separate bookmark for a separate downstream consumer.
STALE_AFTERA planning boundary for consuming before history becomes unavailable.
Stale streamIts required historical interval is no longer reliably accessible.

A concrete example

In a normal autocommit session A_PENDING is 0 while B_PENDING is 1. Inspect the retention metadata for each stream.

Remember: Recover data and establish a new boundary explicitly; recreation alone is not recovery.

Explain it step by step · full theory

Understand the concept

Two teams reading one stream do not get two independent acknowledgements. If team A commits a consuming write, team B cannot expect the same stream still to expose that interval. Give independent consumers separate streams.

Retention is not an infinite message queue. Inspect STALE and STALE_AFTER, source retention, delayed jobs and task failures. Automatic extensions have limits and do not apply identically to all source types such as shared objects.

Walk through the behavior

A stale stream cannot reconstruct missing changes just by being recreated. Recovery needs an authoritative source snapshot or replayable event log and a controlled new boundary. Otherwise the recreated stream can silently skip the lost interval.

The following proof creates both streams before a new row. One is consumed and the other remains pending. It demonstrates independent progress without changing the main lab objects.

Words used in this lesson
Independent stream
A separate bookmark for a separate downstream consumer.
STALE_AFTER
A planning boundary for consuming before history becomes unavailable.
Stale stream
Its required historical interval is no longer reliably accessible.

See how it works

Choose a step to explore the idea at your own pace.

Open the interactive explanation
Interactive explainer1 / 3

Independent consumers, retention and stale streams

Source data
Change boundary

Start with the source

Each independent consumer should have its own stream offset. Retention limits how long unconsumed change history remains usable.

Automatic playback is off for reduced motion. Select any step or use Previous and Next. Illustrations explain behavior; they are not live measurements.

Read the complete diagram explanation
  1. Start with the source

    Each independent consumer should have its own stream offset. Retention limits how long unconsumed change history remains usable.

  2. Follow the work

    Two teams reading one stream do not get two independent acknowledgements. If team A commits a consuming write, team B cannot expect the same stream still to expose that interval. Give independent consumers separate streams.

  3. Explain the outcome

    Recover data and establish a new boundary explicitly; recreation alone is not recovery.

Try the SQL or command

Read → predict → run in your learning environment → compare. You can also learn by reading without an account.

New to SQL? Where to run it and how to read it

A query is a question written in SQL. Snowflake runs it and returns a result table. This website shows examples; it does not connect to your account.

  1. No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
  2. For SQL practice, use a learning account in Snowsight and select an authorized role and warehouse. A role determines permissions; a warehouse supplies processing power. Follow the example’s database/schema setup when it refers to stored objects.
  3. Read the entire example, including comments beginning with --. Run the selected statement or labeled block in the stated order. Examples labeled Python, shell or HTTP belong in that client, not in a SQL editor.
  4. Compare values and row counts with the explained result. If an example deliberately causes an error, follow its rollback and cleanup steps before continuing.
SELECT / FROM
Choose the values to return / identify their input.
VALUES / COLUMN1
VALUES supplies tiny example rows. COLUMN1 means their first column, COLUMN2 their second.
AS / WITH
AS gives a result a readable name. WITH names a temporary query step within one statement.
NULL / ::
NULL means missing or unknown. The :: notation converts a value to a named data type.
Session
One connection and its settings. Keep related transaction steps in the same session.
Database.schema.table
A full address for stored data. It is separate from the warehouse that processes queries.

Need the L2_OBJECTS_LAB setup? Open the first database-object lesson →

Help with common practice errors
  • No active warehouse: select a warehouse your role can use. Do not assume you need to create a new one.
  • Object missing or not authorized: check the full name, required setup and active role. Ask the account owner for access if needed.
  • Object already exists: setup may already have run. Read the current state or choose a fresh lab name consistently; do not add OR REPLACE blindly.
  • Different result: check whether an earlier INSERT or UPDATE changed the data. VALUES examples provide their own fresh input for each statement.

Before running this lesson

Manual learning lab; nothing runs on this website. Complete lesson 1 setup in L2_OBJECTS_LAB.M11_LAB and follow the lesson order. Use the same authorized role and warehouse for manual SQL. Task templates use <lab_warehouse>: replace it with an approved warehouse name. Do not activate several consumers against the same stream. Each task starts suspended; running or resuming it can consume compute credits.

Two consumers, two bookmarks

SQL · example
CREATE TABLE CONSUMER_SOURCE (ID NUMBER);
CREATE STREAM CONSUMER_A ON TABLE CONSUMER_SOURCE;
CREATE STREAM CONSUMER_B ON TABLE CONSUMER_SOURCE;
CREATE TABLE CONSUMER_A_SINK (ID NUMBER);
INSERT INTO CONSUMER_SOURCE VALUES (10);
INSERT INTO CONSUMER_A_SINK SELECT ID FROM CONSUMER_A;
SELECT COUNT(*) AS A_PENDING FROM CONSUMER_A;
SELECT COUNT(*) AS B_PENDING FROM CONSUMER_B;
SHOW STREAMS IN SCHEMA L2_OBJECTS_LAB.M11_LAB;

What to expect and why

In a normal autocommit session A_PENDING is 0 while B_PENDING is 1. Inspect the retention metadata for each stream.

Check your understanding

Choose an answer, then check your reasoning. This is practice, not a scored test.

Does recreating a stale stream recover the missing history?

Try it yourself

How should two independent downstream targets track their progress?

Compare your reasoning

Use separate streams or a durable fan-out design, not an assumption that one consumed stream serves both independently.

Official sources and curriculum

Module 11 · See module scope