acoustic-carpenter-78188
06/23/2026, 11:56 PMWatchActions under-reported a run's actions / children_phase_counts for large runs:
• Capped at ~100 (only the first page ever loaded), and
• For big runs the initial snapshot was truncated (e.g. an 8K run showed ~4.6K, a 32K run ~11K), with the number wobbling between refreshes.
Root causes
1. Offset ignored. `WatchActions`' initial snapshot (listAndSendAllActions) paged by Offset, but ListActions only implemented keyset (CursorToken) paging and silently ignored Offset — every page re-read the first page.
2. Non-unique ordering. The snapshot sorted by created_at only; a map task bulk-creates thousands of children with identical created_at, so paging over a non-unique ORDER BY skipped/duplicated rows. The `ListActions`/`ListRuns` RPC cursor had the same flaw: it encoded only created_at and used created_at < cursor, skipping rows tied on the boundary.
3. O(n²) snapshot. Even once paging worked, OFFSET re-scans ~offset rows per page, so the snapshot for a large run exceeded the console's ~5.5s stream timeout and was truncated.
Approach
The snapshot now uses keyset (cursor) pagination on (created_at, name) ascending, making it O(n):
• ListResourceInput gains KeysetAfterCreatedAt / `KeysetAfterName`; ListActions emits the Postgres row-value keyset (created_at, name) > (?, ?), and validates the required (created_at ASC, name ASC) sort.
• New index idx_actions_run_created_name (project, domain, run_name, created_at, name) makes each page an index range-scan.
• created_at stays the primary sort so parents insert before children; name is the unique per-run tiebreaker giving a total order, so pages never skip/overlap even under tied created_at.
The `ListActions`/`ListRuns` RPC cursor is now a composite keyset too:
• The token (impl.EncodeActionCursor, opaque base64 JSON) carries the full default sort key `(phase, created_at, run_name, name)`; the repo expands the keyset by hand (Postgres row-value comparison can't mix ASC/DESC). (run_name, name) is unique per row (part of the PK), so tied created_at never skips a page boundary. ListRuns roots are all name="a0", so run_name disambiguates them; ListActions within a run uses name.
• The default ORDER BY gains run_name DESC, name DESC tiebreakers to match; a cursor with a custom sort is rejected.
ListActions supports three mutually-exclusive pagination modes: keyset (KeysetAfter, the snapshot), cursor (CursorToken, the default-sorted RPC paging), and offset (Offset, applied as SQL OFFSET). A negative offset is rejected, and offset can't be combined with keyset/cursor.
Verified on flyte-development
| run size | snapshot time | result |
| -------- | ------------- | ---------------------------------------- |
| 8,000 | ~1.4s | full 8000 |
| 16,000 | ~2.25s | full 16000 |
| 32,001 | ~25s | full 32001 (distinct; DB confirms 32001) |
(Down from ~5s / truncated before.)
Tests
• TestListActions_KeysetPagination — snapshot keyset over tied `created_at`: full coverage + total order + sort/mutual-exclusion validation.
• TestListActions_CursorPaginationTiedCreatedAt — RPC composite cursor over tied `created_at`: full non-overlapping coverage; plus offset paging, negative-offset rejection, and offset/cursor mutual exclusion.
• TestListRuns — service returns/round-trips opaque EncodeActionCursor tokens.
• TestListAndSendAllActionsUsesAscendingSort — snapshot emits (created_at ASC, name ASC).
Note
The remaining cost is O(n) streaming of the snapshot bytes; for extremely large single runs the durable belt-and-suspenders is raising/removing the ~5.5s client timeout in flyteconsole (separate repo).
https://claude.ai/code/session_01AjhEAjx4yGQY9MhpY5DEXd
flyteorg/flyteacoustic-carpenter-78188
07/14/2026, 6:51 PMacoustic-carpenter-78188
07/15/2026, 3:47 AM