A scenario for a data engineer · Senior and up
The stream gets slower every week
Beep · On call
Thursday, 02:30
A Structured Streaming job on Databricks drops duplicate events by event id. It has run for three months, its state holds every id it has ever seen, and each batch is slower than the last.
What do you do?
Tap the one you would do. The answer opens below.
Show the best callThe best call
Deduplicate inside a watermark, so ids older than the lateness you expect are forgotten.
The state stops growing. Duplicates that arrive inside the window are still caught.
Why
Dropping duplicates in a stream means remembering keys. Without a watermark the stream has to remember all of them for ever. With one, dropDuplicatesWithinWatermark keeps a key only as long as a duplicate could still arrive.
Read it in the Databricks docs (opens in a new tab)The other two
- Works, at a price. Give the workers more memory and disk, so the state store can hold more ids.
- It copes for some months more, at a higher price. The state still grows without end.
- A poor call. Restart the stream with a new checkpoint every month to clear the state.
- The state is empty, and so is the stream's place in its source. It starts over, and every id it had seen is new again.
The words in this scenario
- Watermark.
- In a stream, how long to wait for events that arrive late. Once the watermark has passed a time window, the window is final and later rows for it are dropped. In the docs (opens in a new tab)
- Checkpoint.
- The place where a stream records how far it has read and what it is keeping in memory, so that after a stop it carries on from the same point. In the docs (opens in a new tab)
Go deeper on brickster.ai
- Structured Streaming: what changed recentlyNews, releases, videos and questions on it, gathered daily.
More scenarios
- Where should the new pipeline read from? · data engineer
- The hourly totals come up short · data engineer
- The stream stopped on a new column · data engineer
- All 47 scenarios
Had one like this at work? Send it to us: the best tickets come from real incidents.
Checked against the Databricks documentation on . brickster.ai is independent and is not affiliated with Databricks.