Skip to content

perf(redis): use sorted set index for O(log N) schedule claiming#14

Open
isimisi wants to merge 1 commit into
boringnode:mainfrom
Juristic:feat/zset-due-index
Open

perf(redis): use sorted set index for O(log N) schedule claiming#14
isimisi wants to merge 1 commit into
boringnode:mainfrom
Juristic:feat/zset-due-index

Conversation

@isimisi
Copy link
Copy Markdown

@isimisi isimisi commented May 15, 2026

explanation: #13 (comment)

@RomainLanz
Copy link
Copy Markdown
Member

Hi!

Thanks for the PR.

We need a migration path for existing Redis users before merging this.

With this change, claimDueSchedule() only reads from the new schedules::due ZSET, but users upgrading from the current version will only have the existing schedule hashes plus schedules::index. Those schedules will never be claimed until something manually rewrites them or calls backfillDueIndex().

Can we make the migration automatic/idempotent, or expose and document a required migration step? For example, on startup or first claim, backfill schedules::due from schedules::index for active schedules with next_run_at.

@isimisi
Copy link
Copy Markdown
Author

isimisi commented May 26, 2026

Hey @RomainLanz, great point. I completely missed the migration path for existing users.

I'll add an automatic backfill that runs on startup: on first claimDueSchedule() call (or worker boot), scan schedules::index and populate schedules::due from any schedule that has a next_run_at. I'll make it idempotent so it's safe to run multiple times across worker restarts or multi-instance deployments.

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.

2 participants