Merged
Conversation
Rather than track when the alarm was last fired, set it when the first entry is added to a batch, and delete the alarm if the batch is submitted before the timeout. Previously, there was a bug where we could get unflushed batches as a new alarm wasn't being set in the already-initialized DO. fixes #9, fixes #11
5385d64 to
b9d2f35
Compare
It's possible that when we call the async 'submit_batch' function execution yields to the runtime immediately before the 'take' occurs to replace the batch. Then, two concurrent 'submit_batch' calls could result in a batch that is never submitted. I'm not sure at which point execution of the async 'submit_batch' yields to the runtime, but this change shouldn't hurt, at least.
This is closer to the example at https://developers.cloudflare.com/durable-objects/examples/alarms-api/, and will handle cases where we fail to reset the batch when the alarm is reset.
Contributor
Author
|
After running for some time with the first two commits in this PR, I saw the below errors. It looks like the the Batchers were running into a memory limit, perhaps if the alarm wasn't correctly flushing batches. The two commits I just pushed seem to resolve this issue, but I'll keep monitoring. |
rozbb
pushed a commit
to rozbb/azul
that referenced
this pull request
Jun 3, 2025
Fix and simplify alarm logic
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.
Rather than track when the alarm was last fired, set it when the first
entry is added to a batch, and delete the alarm if the batch is
submitted before the timeout. Previously, there was a bug where we could
get unflushed batches as a new alarm wasn't being set in the
already-initialized DO.
fixes 500 internal server errors #9, fixes Client timeouts and internal server errors #11
Copy HTTP headers from R2 HTTP metadata when serving from Worker
fixes Unicode not displayed correctly in checkpoints served from Worker #12