Cumulative counters, daily deltas, and the data you can lose forever
Music data arrives as a running total, so daily numbers have to be derived. The three bugs that derivation produces, one of which destroys data permanently.
Danny Starr
Co-founder, Backline · 10 August 2026 · 3 min read
In short
- Public music metrics are cumulative counters. Daily numbers are derived by subtracting consecutive snapshots, and that derivation has sharp edges.
- The dangerous bug is advancing the baseline when a downstream write failed, which loses a day's data permanently with no error anywhere.
- Track whether each snapshot was successfully used as a confirmed baseline, and only ever compute against confirmed ones.
- When a gap is filled later, spread the difference across the days it covers and flag those points as estimated rather than dumping it on one day.
- Cap how far back a gap fill can reach. A corrupted or very old baseline can otherwise generate hundreds of fabricated days.
Music platforms report totals. A track has streams since release, an artist has followers, a video has views. Nobody publishes a dated daily series, so a system that wants one has to snapshot the total daily and subtract.
Simple, and it fails in three specific ways.
Failure one: advancing the baseline on a failed write
This is the expensive one.
The pipeline reads today's total, computes the difference against yesterday's stored total, and sends that daily figure somewhere: an analytics service, a downstream store, a chart. Then it stores today's total as the new baseline.
If that send fails and the baseline is stored anyway, tomorrow's difference is computed from the new baseline as though nothing was missed. The day that failed to send is gone. Not delayed, not retried, gone, and nothing errored because from the pipeline's point of view everything succeeded.
We shipped that. The fix is one column.
The same failed write, with and without a confirmed baseline flag
Illustrative| Without the flag | With the flag | |
|---|---|---|
| Mon: read 1,000, send 40, write ok | Baseline 1,000 | Baseline 1,000, confirmed |
| Tue: read 1,055, send fails | Baseline 1,055 | Snapshot 1,055 stored, not confirmed |
| Wed: read 1,090 | Difference is 35. Tuesday's 55 is gone | Difference is 90 against Monday. Nothing lost |
| What is downstream | 40 and 35. Total 75, actual 90 | 40, then 90 spread across two days. Total 130 |
| What errored | Nothing | Nothing, and nothing needed to |
Store a flag on each snapshot recording whether that reading was successfully used as a confirmed baseline. The baseline lookup only considers confirmed rows. Now a failed send leaves the previous confirmed baseline in place, and tomorrow's run computes a two day difference covering the gap. Nothing is lost, and the retry is automatic.
Failure two: dumping a multi-day gap on one day
Once gaps are retried, the naive version dumps the entire missed period onto the day the pipeline recovered.
Charted, that is a spike. Interpreted, it is a marketing win that never happened, and someone will reforecast on it.
The honest treatment is to spread the difference evenly across the real days in the gap, put the remainder on the last day so the total still reconciles, and flag every generated point as estimated. The flag is what matters: downstream consumers, chart tooltips and AI summaries can then say the value was spread across a span rather than measured.
Even spreading is a guess. It is the least wrong guess available, and being clear that it is a guess is the difference between a defensible number and a fabricated one.
Failure three: unbounded gap fill
A corrupted baseline, or a project onboarded with an ancient reading, produces a difference spanning hundreds of days. Spread that and you have manufactured a year of fake daily data in one run.
Cap it. Ours refuses to spread across more than 90 days and records the event instead. Beyond that horizon the honest answer is that the history is not recoverable from a counter, and something else has to supply it.
Clamping, and when not to
Counters are monotonic upstream, so a negative difference means an upstream correction: fraud filtering, a restatement, a merge of duplicate identifiers.
For a counter, clamp at zero. Negative streams are not a thing, and the correction is not a day's activity.
For a level, such as a follower count, never clamp. Followers genuinely fall, and hiding that is a worse error than showing an unflattering week. This is the same distinction as in the 7 day problem.
Deriving a daily figure safely
Illustrative- 1Find the last confirmed baselineOnly snapshots that were successfully used downstream count. Never the very first reading.
- 2SubtractToday's total minus that baseline. Clamp at zero for counters, keep the sign for levels.
- 3Check the spanIf more than one day, this covers a gap. If more than the cap, refuse and record it.
- 4Spread across the gapEvenly, remainder on the last day so the total reconciles. Flag every generated point as estimated.
- 5Send, then confirmOnly mark the snapshot confirmed after the downstream write succeeds. Use a deterministic id so retries deduplicate.
The first snapshot is not a baseline
When a source is first connected, the first reading may be partial, may lag, or may be a warm-up value from an upstream crawl.
If that reading becomes a baseline, the second day's difference includes the warm-up error and produces a spectacular fake first day. Skip it: never let the earliest stored reading serve as a window or delta baseline. It costs one day of history and removes a whole class of onboarding artefact.
Idempotency
Runs get retried, sometimes twice in a day. Two things make that safe.
Write snapshots with an upsert keyed by source, identifier and date, so a second run in the same day overwrites rather than duplicating.
Give every downstream event a deterministic identifier derived from the same key, so a duplicate send is deduplicated rather than double counted.
Without those, an ordinary retry after a timeout produces double the day's numbers, which is a harder bug to notice than a missing day and a worse one to explain.
Common questions
- Why do streaming pipelines lose data silently?
- Because they advance the baseline after computing a daily difference, whether or not the downstream write succeeded. The next run then computes from the new baseline as though nothing was missed, so the failed day disappears with no error anywhere. The fix is a flag marking whether each snapshot was successfully used, and computing only against confirmed ones.
- What should happen when a data sync misses several days?
- The recovered difference should be spread evenly across the days it covers, with the remainder on the last day so the total reconciles, and every generated point flagged as estimated. Dumping the whole gap on the recovery day produces a spike that looks like a marketing result.
- Should a negative daily figure ever be shown?
- For counters such as streams, no: clamp at zero, because a negative difference means an upstream correction rather than negative activity. For levels such as follower counts, yes: followers genuinely fall, and hiding that is worse than showing an unflattering week.
Sources
- 1Spotify for Artists, Reviewed August 2026. Data in Spotify for Artists
- 2Google, Reviewed August 2026. Analytics Data API: report basics
Danny Starr
Co-founder, Backline
Danny Starr is a co-founder of Backline and builds the platform. He writes about the data engineering behind music analytics: ingestion, identity, honesty in charts, and the AI layer on top of it.
Backline does this for the projects you run
Streaming, audience, social, advertising, website, search, ticketing and press data in one dashboard per project, with an AI assistant that answers questions about your own connected data. Invite-only.
Keep reading
Data engineering
Reporting lag: the two days nobody accounts for
Third-party streaming totals describe a day that already passed. Uncorrected, every chart and every correlation is offset, and the error is invisible.
Danny Starr · 3 min read
Data engineering
Weekly reporting sources and the phantom spike
Some music data only moves once a week. Charted daily it produces a spike every seventh day that looks like a marketing win. How to detect the pattern and what to do about it.
Danny Starr · 3 min read
Analytics foundations
The 7 day problem in music dashboards
Why so many music dashboards show the same streaming figure for every date range, what the correct arithmetic is, and how to tell whether a tool has done it.
Danny Starr · 4 min read

