Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/server/src/orchestration-v2/ProjectionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3580,6 +3580,14 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
LIMIT 1
)
WHERE t.deleted_at IS NULL
-- The sweep runs every scheduler tick. Without this list the latest-run
-- lookup above sorts every run of every thread, tens of milliseconds
-- for one long thread; only threads with a usage-limit failure qualify.
AND t.thread_id IN (
SELECT failure.thread_id FROM orchestration_v2_projection_turn_items failure
WHERE failure.type = 'error' AND failure.status = 'failed'
AND json_extract(failure.payload_json, '$.failure.class') = 'usage_limit'
)
AND json_extract(t.payload_json, '$.archivedAt') IS NULL
AND json_extract(t.payload_json, '$.settledOverride') IS NOT 'settled'
AND json_extract(item.payload_json, '$.failure.class') = 'usage_limit'
Expand Down
Loading