{{ message }}
Repository navigation
Keep SortedEntry's in-memory score in sync after reschedule - #7017
Merged
mperham merged 1 commit intoMay 29, 2026
Merged
Conversation
SortedEntry#reschedule writes the new score to Redis via zincrby but never updates @score, so the in-memory entry returns the stale (pre- reschedule) value from #score and #at. Other SortedEntry mutators (add_to_queue/retry/kill/delete) remove the entry from its set, so a stale entry there is moot — but reschedule keeps the job in the same set with a new score, making the drift between in-memory state and Redis a real footgun: entry = Sidekiq::ScheduledSet.new.first entry.reschedule(Time.now + 500) entry.score # => stale (the original score) entry.at # => stale Set @score = at.to_f after the zincrby. Adds an api_test that fails before the change and passes after; existing reschedule test still passes because it re-iterates the set (fresh entries from Redis).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Sidekiq::SortedEntry#reschedulewrites the new score to Redis viazincrbybut never updates@score, so the in-memory entry's#scoreand#atkeep returning the stale (pre-reschedule) values:The other
SortedEntrymutators (add_to_queue/retry/kill/delete) all remove the entry from its set, so a stale entry there is moot.rescheduleis the only mutator that keeps the job alive in the same set with a new score — making the drift between in-memory state and Redis a real footgun specifically here.Fix: set
@score = at.to_fafter thezincrby.Testing
Adds a focused regression test that re-reads
entry.score/entry.atafterrescheduleand asserts they reflect the new time. Fails before the change and passes after. The existing"can reschedule jobs"test is unaffected (it re-iterates the set, so it always sees fresh entries from Redis).bundle exec rakeis green (standard + lint:herb + full suite).