Commit 2f53dab
feat(cubestore): bound the priority inversion of ADD_AND_RETRIEVE
Priority ordering is enforced by the selection step, not by the claim:
QUEUE PENDING returns items highest priority first and reconcile takes
toProcessLimit off the top of that list. QUEUE RETRIEVE is priority blind and
is safe only because the path it gets comes from that sorted list.
ADD_AND_RETRIEVE selects itself, so it had nothing to compensate for being
priority blind. It now claims the item only while there is almost nothing to
jump over:
| condition | meaning |
|------------------------------------|------------------------------------|
| active < concurrency | a slot is free, as before |
| pending * 2 < concurrency | the backlog is shallow |
A claimed item goes straight to active and never becomes pending, so a burst
onto an idle queue still fast tracks every query. Items start to accumulate in
pending only when the concurrency budget is exhausted, which is exactly when
the fast track should step aside and let reconcile pick by priority.
The condition is written as a multiplication, because concurrency / 2
truncates to 0 for a queue with concurrency 1 (the pre-aggregation build
queue), which would disable the fast track there entirely. An item which is
already pending is not counted as its own backlog, otherwise claiming an
existing item would never happen for the small concurrency queues.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 7a54bee commit 2f53dab
2 files changed
Lines changed: 89 additions & 11 deletions
File tree
- packages/cubejs-query-orchestrator
- rust/cubestore/cubestore/src/cachestore
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
234 | | - | |
| 233 | + | |
| 234 | + | |
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | | - | |
242 | | - | |
243 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
244 | 251 | | |
245 | 252 | | |
246 | 253 | | |
| |||
287 | 294 | | |
288 | 295 | | |
289 | 296 | | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
294 | 309 | | |
295 | 310 | | |
296 | 311 | | |
| |||
Lines changed: 65 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1467 | 1467 | | |
1468 | 1468 | | |
1469 | 1469 | | |
1470 | | - | |
1471 | | - | |
1472 | 1470 | | |
1473 | 1471 | | |
1474 | 1472 | | |
1475 | 1473 | | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
1476 | 1488 | | |
1477 | 1489 | | |
1478 | 1490 | | |
| |||
2945 | 2957 | | |
2946 | 2958 | | |
2947 | 2959 | | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
| 2982 | + | |
| 2983 | + | |
| 2984 | + | |
| 2985 | + | |
| 2986 | + | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
| 2998 | + | |
| 2999 | + | |
| 3000 | + | |
| 3001 | + | |
| 3002 | + | |
| 3003 | + | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
| 3009 | + | |
| 3010 | + | |
2948 | 3011 | | |
2949 | 3012 | | |
2950 | 3013 | | |
| |||
0 commit comments