fix(views): skip converted tables in first-populate REFRESH #16

Merged
jonas merged 1 commit from fix/views-first-populate-skip-converted-tables into main 2026-06-25 13:00:17 +02:00
Owner

Problem

EnsureViewsPopulated (the startup first-populate path) still lists sbom_component_view and dependency_summary_view in its REFRESH MATERIALIZED VIEW loop, but #12 converted both to regular tables (maintained by EnsureDerivedTablesPopulated).

On a cold database the loop fails on REFRESH MATERIALIZED VIEW sbom_component_view (not a matview) on every iteration — before sbom_metadata_view is ever refreshed. So viewsPopulated() never returns true and /api/readyz stays 503 for the full 30-minute populate window, so the pod never becomes Ready and the rollout stalls past its progress deadline.

Impact

  • Existing prod/lab: unaffected — they short-circuit on an already-populated sbom_metadata_view, so the broken refresh is never reached.
  • Fresh DB / new environment / DR rebuild: rollout wedged until the post-loop refresh path self-heals (~30 min), well past the deploy deadline.

Fix

Trim the first-populate list to ["sbom_metadata_view"], matching the already-correct RefreshMaterializedViews. The other two are regular tables and don't belong in a matview REFRESH.

Verification

  • go vet ./internal/db/... clean.
  • Fresh-DB cold start: /api/readyz → 200 on the first poll (was a 503 stall), sbom_metadata_view populated, zero "is not a materialized view" errors (previously logged every 2s).

🤖 Generated with Claude Code

## Problem `EnsureViewsPopulated` (the startup first-populate path) still lists `sbom_component_view` and `dependency_summary_view` in its `REFRESH MATERIALIZED VIEW` loop, but #12 converted both to regular tables (maintained by `EnsureDerivedTablesPopulated`). On a **cold database** the loop fails on `REFRESH MATERIALIZED VIEW sbom_component_view` (not a matview) on every iteration — *before* `sbom_metadata_view` is ever refreshed. So `viewsPopulated()` never returns true and `/api/readyz` stays **503** for the full 30-minute populate window, so the pod never becomes Ready and the rollout stalls past its progress deadline. ## Impact - **Existing prod/lab: unaffected** — they short-circuit on an already-populated `sbom_metadata_view`, so the broken refresh is never reached. - **Fresh DB / new environment / DR rebuild: rollout wedged** until the post-loop refresh path self-heals (~30 min), well past the deploy deadline. ## Fix Trim the first-populate list to `["sbom_metadata_view"]`, matching the already-correct `RefreshMaterializedViews`. The other two are regular tables and don't belong in a matview `REFRESH`. ## Verification - `go vet ./internal/db/...` clean. - Fresh-DB cold start: `/api/readyz` → 200 on the first poll (was a 503 stall), `sbom_metadata_view` populated, zero `"is not a materialized view"` errors (previously logged every 2s). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(views): skip converted tables in first-populate REFRESH
All checks were successful
Build and Deploy / build-repo-runner (push) Successful in 1m17s
Build and Deploy / build-sbom-scanner (push) Successful in 1m17s
Build and Deploy / build-image-scanner (push) Successful in 1m30s
Build and Deploy / build-app (push) Successful in 3m40s
Build and Deploy / deploy-helm (push) Successful in 19s
2a48e4ccfc
EnsureViewsPopulated still listed sbom_component_view and
dependency_summary_view in its REFRESH MATERIALIZED VIEW loop, but both
were converted to regular tables (the derived-tables family, maintained by
EnsureDerivedTablesPopulated). On a cold DB the loop failed on
`REFRESH MATERIALIZED VIEW sbom_component_view` (not a matview) every
iteration before sbom_metadata_view was ever refreshed, so viewsPopulated
never flipped true and /api/readyz stayed 503 for the full 30-minute
populate window — wedging rollouts on any fresh database.

Trim the first-populate list to sbom_metadata_view, matching the
already-correct RefreshMaterializedViews. Existing environments are
unaffected: they short-circuit on an already-populated metadata view.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jonas merged commit bbd446cc6f into main 2026-06-25 13:00:17 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Motstandskraft/spam!16
No description provided.