Commit 9974909
fix(webapp): use composite keyset cursor for run pagination
listRunIds/listRuns order by the composite key (created_at, run_id) but
the cursor predicate cut on run_id alone. That is only sound when run_id
lexicographic order matches created_at order. When a burst of runs is
created such that the two diverge, keyset pagination both re-includes
already-returned runs (duplicates) and drops runs it should return
(skips). For bulk replay this produced duplicate runs; for the dashboard
and runs.list it could silently skip or repeat runs at page boundaries.
- Encode cursors as the composite (created_at, run_id) key
(v2_<createdAtMs>_<runId>) and cut on the matching tuple predicate
((created_at, run_id) < / > (...)). The ORDER BY is unchanged, so the
table's primary-key alignment (and query performance) is preserved.
- Cursors are server-issued opaque tokens (the SDK just echoes
pagination.next/previous back), so this needs no client update. Legacy
bare-run_id cursors decode to the old run_id-only predicate for
backwards compatibility with in-flight cursors.
- Add listRunIdsWithCursor for forward-only batch iteration (bulk
actions) so the created_at component is sourced from the same query
that orders the rows.
- ClickHouse getTaskRunsQueryBuilder now also selects
toUnixTimestamp64Milli(created_at) AS created_at_ms.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent d1f4302 commit 9974909
7 files changed
Lines changed: 483 additions & 30 deletions
File tree
- .server-changes
- apps/webapp
- app
- services/runsRepository
- v3/services/bulk
- test
- internal-packages/clickhouse/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
Lines changed: 83 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| |||
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
21 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
22 | 36 | | |
23 | 37 | | |
24 | 38 | | |
25 | 39 | | |
26 | 40 | | |
27 | 41 | | |
| 42 | + | |
| 43 | + | |
28 | 44 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
34 | 57 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
39 | 67 | | |
| 68 | + | |
| 69 | + | |
40 | 70 | | |
41 | 71 | | |
42 | 72 | | |
| |||
48 | 78 | | |
49 | 79 | | |
50 | 80 | | |
51 | | - | |
52 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
53 | 106 | | |
54 | 107 | | |
55 | 108 | | |
| |||
76 | 129 | | |
77 | 130 | | |
78 | 131 | | |
79 | | - | |
| 132 | + | |
80 | 133 | | |
81 | 134 | | |
82 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
83 | 141 | | |
84 | 142 | | |
85 | 143 | | |
| |||
88 | 146 | | |
89 | 147 | | |
90 | 148 | | |
91 | | - | |
| 149 | + | |
92 | 150 | | |
93 | | - | |
94 | | - | |
| 151 | + | |
| 152 | + | |
95 | 153 | | |
96 | 154 | | |
97 | 155 | | |
98 | 156 | | |
99 | | - | |
| 157 | + | |
100 | 158 | | |
101 | | - | |
102 | | - | |
| 159 | + | |
| 160 | + | |
103 | 161 | | |
104 | | - | |
| 162 | + | |
105 | 163 | | |
106 | 164 | | |
107 | 165 | | |
108 | 166 | | |
109 | 167 | | |
110 | 168 | | |
111 | | - | |
| 169 | + | |
112 | 170 | | |
113 | | - | |
114 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
115 | 174 | | |
116 | 175 | | |
117 | 176 | | |
| |||
Lines changed: 47 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
133 | 142 | | |
134 | 143 | | |
135 | 144 | | |
| |||
169 | 178 | | |
170 | 179 | | |
171 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
172 | 198 | | |
173 | 199 | | |
174 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
163 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
164 | 166 | | |
165 | 167 | | |
166 | 168 | | |
| |||
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
175 | | - | |
176 | | - | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
295 | | - | |
| 295 | + | |
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
| |||
0 commit comments