Repository navigation
Commit a404106
perf!(redis): use sorted set index for O(log N) schedule claiming (#14)
* perf(redis): use sorted set index for O(log N) schedule claiming
* fix(redis): auto-backfill due index on first schedule claim
Existing users upgrading will have schedules in the legacy format
(hashes + SET) but not in the new ZSET. Run backfillDueIndex() once
per worker process on the first claimDueSchedule() call so schedules
keep firing without manual intervention.
* perf(redis): update claim schedule script to use sorted set index
* feat(adapter): add migrate() to interface, validate hash in claim script
Replace auto-backfill with an explicit migrate() lifecycle method on the
Adapter interface. Remove #ensureDueIndex() and #dueIndexReady from
RedisAdapter — users call migrate() once after upgrading to populate the
schedules::due ZSET from pre-existing data.
The Lua claim script now validates the hash's next_run_at before claiming,
repairing stale ZSET scores on sight. This keeps the hash canonical and
the ZSET as a derived index.
* fix(redis): harden due schedule index migration
Keep paused and exhausted schedules out of the derived due index, rebuild it idempotently during migration, and restore the Adapter contract after merging current main.
Document the breaking Redis migration and cover schedule lifecycle consistency across adapters.
* chore: remove released changelog entries
* docs: add Redis schedule index changelog
* fix(redis): make schedule index updates atomic
Move schedule upserts, updates, and due-index backfills into Lua so canonical hashes and the derived ZSET cannot diverge under concurrent writes.
Add regression coverage for resume, upsert, and migration interleavings.
* fix(redis): guard cron claim finalization
Finalize cron schedules only when the claimed canonical state is still current, preventing concurrent pause or delete operations from being undone.
Repair malformed due scores during claiming so they cannot block valid schedules.
* fix(redis): reject superseded cron finalization
* style(redis): clarify claim script nesting
* docs: note Redis schedule race safeguards
* fix(redis): preserve schedules across concurrent updates
* fix(redis): guard cron claim ownership
* fix(redis): preserve cron next run during concurrent pause
---------
Co-authored-by: Romain Lanz <romain.lanz@pm.me>1 parent 52b38f0 commit a404106
16 files changed
Lines changed: 1145 additions & 184 deletions
File tree
- .changelog
- src
- contracts
- drivers
- tests
- _mocks
- _utils
This file was deleted.
This file was deleted.
This file was deleted.
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
337 | 357 | | |
338 | 358 | | |
339 | 359 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
226 | 236 | | |
227 | 237 | | |
228 | 238 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
407 | 411 | | |
408 | 412 | | |
409 | 413 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
| 126 | + | |
125 | 127 | | |
126 | 128 | | |
127 | 129 | | |
| |||
0 commit comments