Repository navigation
events/queue: read ScheduledTime under the lock and match it in execute - #172
Merged
Merged
Conversation
processLoop peeked the front item under the lock but called ScheduledTime after unlocking, so a concurrent Dequeue could hand the item back to its owner first. go-cron reset and reused such items, and the read dereferenced the reset state (nil pointer SIGSEGV in the dapr scheduler under load). The heap already calls ScheduledTime under this lock on every Enqueue, so no new lock order. execute also matched the front item by pointer only. An owner that dequeued an item and enqueued the same pointer with a later time could have it fire at the old time. execute now also requires the scheduled time read by processLoop, and restarts the loop if it changed. Signed-off-by: joshvanl <me@joshvanl.dev>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused synchronization fixes have regression coverage and no identified blocking issues; tests were not run.
0 open findings
What changed in this PR
Fixes queue scheduling races when owners dequeue and reuse items.
Changes:
- Reads scheduled times while holding the processor lock.
- Checks both item identity and scheduled time before execution.
- Adds regression tests for lock protection and rescheduling.
| File | Description |
|---|---|
| events/queue/queue.go | Documents scheduled-time locking guarantees. |
| events/queue/processor.go | Protects reads and rejects stale execution attempts. |
| events/queue/processor_peeklock_test.go | Tests locked reads and reused-item scheduling. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
cicoyle
approved these changes
Oct 16, 2026
This was referenced Oct 19, 2026
dapr-bot
pushed a commit
to karljaxon/dapr
that referenced
this pull request
Oct 19, 2026
Use the tags for 1.19 in place of the main commits that RC3 and RC4 pin. kit v0.19.0 adds dapr/kit#172. durabletask-go v0.15.1 is the commit that is pinned now. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
processLoop peeked the front item under the lock but called ScheduledTime after unlocking, so a concurrent Dequeue could hand the item back to its owner first. go-cron reset and reused such items, and the read dereferenced the reset state (nil pointer SIGSEGV in the dapr scheduler under load). The heap already calls ScheduledTime under this lock on every Enqueue, so no new lock order.
execute also matched the front item by pointer only. An owner that dequeued an item and enqueued the same pointer with a later time could have it fire at the old time. execute now also requires the scheduled time read by processLoop, and restarts the loop if it changed.