Skip to content

Sort ListWorkers by (TaskQueue, StartTime, WorkerInstanceKey)#10543

Draft
rkannan82 wants to merge 3 commits into
kannan/count-workersfrom
kannan/list-workers-sort
Draft

Sort ListWorkers by (TaskQueue, StartTime, WorkerInstanceKey)#10543
rkannan82 wants to merge 3 commits into
kannan/count-workersfrom
kannan/list-workers-sort

Conversation

@rkannan82

@rkannan82 rkannan82 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

What

Change ListWorkers pagination sort order from WorkerInstanceKey-only to a composite key: (TaskQueue asc, StartTime asc, WorkerInstanceKey asc).

Why

WorkerInstanceKey is an opaque UUID — sorting by it produces a random-looking order that isn't meaningful to users and shuffles when workers restart. The new sort groups workers by task queue, orders by start time (oldest first) within each group, and uses WorkerInstanceKey as a unique tiebreaker. Both TaskQueue and StartTime are immutable for a worker's lifetime, so the ordering is stable across page refreshes.

How did you test it?

  • Unit tests covering multi-field sort order (task queue grouping, start time ordering, key tiebreaker), cursor-based pagination across pages, and deleted-cursor recovery.

🤖 Generated with Claude Code

rkannan82 and others added 3 commits June 4, 2026 18:42
Replaces the previous WorkerInstanceKey-only sort with a composite key
that groups workers by task queue and orders by start time (oldest first)
within each group. This provides stable ordering across page refreshes
since both TaskQueue and StartTime are immutable for a worker's lifetime.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Stale tokens from the old sort order will have zero-value fields,
causing the cursor to land at position 0 — the client gets page 1
again. This is acceptable during the narrow rolling-deploy window.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant