Skip to content

fix: report no MV delta days as NULL in the freshness endpoint - #5528

Merged
themarolt merged 1 commit into
mainfrom
fix/issue-1182-freshness-empty-mv
Dec 5, 2026
Merged

themarolt merged 1 commit into
mainfrom
fix/issue-1182-freshness-empty-mv

Conversation

@themarolt

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #5527 (Cursor Bugbot finding). On an empty activityRelations_enrich_snapshot_MV_ds, min(snapshotId) and max(snapshotId) return 1970-01-01, so mvOldestSnapshotId/mvNewestSnapshotId would show a catch-up window back to the epoch exactly when a missed merge has nothing left to recover from. They now come back NULL.

Changes

  • minOrNull/maxOrNull for the two MV bounds in monitoring_served_layer_freshness.pipe; the description says they are NULL when the MV is empty.

Checked read-only on production: on an empty input min() returns 1970-01-01 and minOrNull() NULL; on today's MV both return 2026-12-05 / 2026-12-06. The columns were already Nullable(DateTime), so the output shape does not change.

Deploy

tb push services/libs/tinybird/pipes/monitoring_served_layer_freshness.pipe --force after merge.

Type of change

  • Bug fix

Related issue

Refs linuxfoundation/lfx-cdp-insights-ops#1182

min() and max() of an empty snapshot MV return 1970-01-01, which read as a
catch-up window back to the epoch when there is nothing to catch up from.

Refs linuxfoundation/lfx-cdp-insights-ops#1182

Signed-off-by: Uroš Marolt <uros@marolt.me>
@themarolt
themarolt requested review from a team and lfx-one as code owners December 5, 2026 20:28
Copilot AI balanced review requested due to automatic review settings December 5, 2026 20:28
@cursor

cursor Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Monitoring-only SQL change in one Tinybird pipe; corrects misleading metrics with no schema or write-path impact.

Overview
Fixes a monitoring freshness bug where mvOldestSnapshotId and mvNewestSnapshotId on the served-layer freshness pipe reported 1970-01-01 when activityRelations_enrich_snapshot_MV_ds had no rows—implying a huge catch-up window exactly when recovery is impossible.

The pipe now uses minOrNull / maxOrNull instead of min / max for those MV bounds, so an empty MV yields NULL (columns were already nullable). The pipe description was updated to document that behavior.

Reviewed by Cursor Bugbot for commit 5fc981a. Bugbot is set up for automated code reviews on this repo. Configure here.

@lfx-one

lfx-one commented Dec 5, 2026 •

Copy link
Copy Markdown

@themarolt I'm starting review 1 of this pull request now (started 2026-12-05 20:28 UTC using review agent v0.1.37). This usually takes a few minutes. I'll update this comment with the summary when I'm done. If there's no summary here after about 45 minutes, the review stopped: push a new commit, or post a comment that begins with a mention of me followed by re-review, to start another. For help with the review agent, see https://github.com/linuxfoundation/lfx-review-agent/issues.


Hi Uros Marolt (@themarolt),

Summary

This pull request makes the two MV bound columns in the served-layer freshness pipe return NULL on an empty MV, instead of 1970-01-01. It is a small, correct, well-scoped fix, and I found no concerns.

Decision

✅ Approved

Details

Overall impression: One-file change to monitoring_served_layer_freshness.pipe. Replacing min/max with minOrNull/maxOrNull is the right ClickHouse fix. The columns were already nullable, so the output shape is unchanged, and the pipe description now documents the NULL case. The PR description also gives a read-only production check. The DCO check passed on the head commit.

Documentation reminder: changed mvOldestSnapshotId and mvNewestSnapshotId. Please check product pages and external docs; the author and maintainers own those updates.

Rule files: read AGENTS.md; skipped none

Questions, problems, or feedback: https://github.com/linuxfoundation/lfx-review-agent/issues

@lfx-one lfx-one left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change is small and correct: minOrNull/maxOrNull make the two MV bounds NULL on an empty MV instead of 1970-01-01, and the pipe description documents it. No findings.

Documentation

This pull request changes behavior that may also be described outside this repository, such as product pages or an external docs site. I can't read those, so please check them; the author and maintainers own those updates. Changed here:

  • mvOldestSnapshotId and mvNewestSnapshotId (now NULL when the MV is empty, instead of 1970-01-01)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the change to return NULL freshness bounds when the delta store is empty.

No open issues 🎉

What changed in this PR

Corrects the Tinybird served-layer freshness endpoint so an empty delta store reports NULL bounds instead of misleading epoch dates.

Changes:

  • Replaces min/max with minOrNull/maxOrNull.
  • Documents the empty-store behavior without changing the output schema.
File Description
services/​libs/​tinybird/​pipes/​monitoring_served_layer_freshness.pipe Returns nullable delta bounds and clarifies their meaning when empty.

Review effort: Balanced

@greptile-apps

greptile-apps Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Low impact] This PR appears safe to merge.

Summary

Updates monitoring_served_layer_freshness.pipe so an empty MV reports no retained delta days.

  • The freshness endpoint marks empty snapshot ranges with NULL bounds.

Reviews (1) · Last reviewed commit: "fix: report no MV delta days as NULL in ..." · Reviewed by Greptile

@themarolt
themarolt merged commit 7839192 into main Dec 5, 2026
17 checks passed
@themarolt
themarolt deleted the fix/issue-1182-freshness-empty-mv branch December 5, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants