acoustic-carpenter-78188
06/24/2026, 8:28 AMWatchActions builds children_phase_counts by upserting every child action into the run-state tree as it streams the initial snapshot. For a 20k-child map task that snapshot is ~20 MB and takes ~25 s to stream. The console's connect-web client closes the WatchActions stream after a few seconds (a client-side stream deadline — confirmed: the backend and ALB both deliver the full 20000 when read without that deadline, via port-forward and via buf curl through the ALB). So the count freezes mid-climb at whatever arrived first (~4.4K).
You fundamentally cannot deliver a 20k-child count by streaming 20k rows under a multi-second client deadline.
Related to #7585 (which fixes the separate Offset paging bug in the same snapshot loop).
What changes were proposed in this pull request?
Seed children_phase_counts up front so it is correct from the first streamed page, instead of climbing as every child streams in:
• New repo method ActionRepo.ListActionPhasesForCounts(runID) — one lightweight query selecting only name, parent_action_name, phase, created_at (no large `action_spec`/`action_details`/... bytea columns), so the whole run loads fast in a single query, ordered created_at ASC, name ASC (parents before children).
• listAndSendAllActions pre-populates the run-state tree from that query before the streaming loop (state only — the per-node updates are discarded; the streaming loop re-sends them with full action data).
• Re-streaming the same rows in the existing loop is count-neutral: `upsertAction`'s update path calls modifyPhaseCounters(parent, newPhase, oldPhase) with newPhase == oldPhase, a net no-op — so the seeded total neither doubles nor regresses. Genuine live phase changes after the snapshot still adjust counts as before.
This mirrors how Union Cloud already serves these counts — via SQL aggregation (COUNT(*) FILTER (WHERE phase = …) GROUP BY …) rather than streaming every child.
The per-action leaf stream (for the tree/list) is unchanged; this PR only fixes the count. Making the full child list robust for huge runs (task grouping + lazy expansion, as cloud does) is a larger follow-up.
ponytail:How was this patch tested? •loads all rows for the run into memory. Fine to ~100k actions; beyond that switch to a recursive SQL CTE or paginate. Noted in a comment at the call site.ListActionPhasesForCounts
TestRunStateManagerSeedThenRestreamIsCountNeutral (no DB): seeds root→mapTask→150 children, asserts counts are correct after seeding (including the transitive count on the root), stay put when the same rows are re-streamed in pages, and still adjust on a real live phase change.
• TestListActionPhasesForCounts (embedded Postgres): root + 120 children with mixed phases; asserts the query returns every action with `name`/`parent`/`phase` populated, correct per-phase totals, and created_at ASC ordering.
• Full runs/service and runs/repository/impl suites pass.
Not deployed yet (load tests in progress on the shared dev cluster).
Labels
• fixed
Check all the applicable boxes
• All new and existing tests passed.
• All commits are signed-off.
flyteorg/flyteacoustic-carpenter-78188
07/15/2026, 11:22 PM