GeezerVison is showing github.com — fix(core): Prevent lost wakeups in batch processors by adinauer · Pull Request #5756 · getsentry/sentry-java
Conversation
adinauer
commented
Jul 13, 2026
•
edited by markushi
Loading
Uh oh!
There was an error while loading. Please reload this page.
📜 Description
Use an atomic scheduling state for the logs and metrics batch processors. A producer now claims delayed flush scheduling with compare-and-set, while a completed flush releases that claim before checking whether more events arrived.
This removes the lock and Future lifecycle checks that allowed an event to be queued without a pending flush. Regression tests verify that both processors schedule another flush after the previous flush has run.
💡 Motivation and Context
An event added while a flush was transitioning from an empty queue to resetting its scheduling flag could remain queued indefinitely. The running flush did not observe it, and the producer saw scheduling as already claimed.
Fixes #5739
💚 How did you test it?
./gradlew spotlessApply apiDump
./gradlew :sentry:test --tests 'io.sentry.logger.LoggerBatchProcessorTest' --tests 'io.sentry.metrics.MetricsBatchProcessorTest'
📝 Checklist
- I added GH Issue ID & Linear ID
- I added tests to verify the changes.
- No new PII added or SDK only sends newly added PII if
sendDefaultPII is enabled.
- I updated the docs if needed.
- I updated the wizard if needed.
- Review from the native team if needed.
- No breaking change or entry added to the changelog.
- No breaking change for hybrid SDKs or communicated to hybrid SDKs.
- Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
🔮 Next steps
None.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
sentry[bot] reacted with hooray emoji
Coordinate log and metric flush scheduling through an atomic state transition. This ensures events added while a flush completes always have a pending task instead of relying on the running Future's completion state.
Fixes #5739
Co-Authored-By: Claude <[email protected]>
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Performance metrics 🚀
| |
Plain |
With Sentry |
Diff |
| Startup time |
402.42 ms |
487.10 ms |
84.68 ms |
| Size |
0 B |
0 B |
0 B |
Baseline results on branch: main
Startup times
| Revision |
Plain |
With Sentry |
Diff |
| 6b019b7 |
319.84 ms |
333.15 ms |
13.31 ms |
| eb95ded |
317.51 ms |
369.08 ms |
51.57 ms |
| 319f256 |
317.53 ms |
370.83 ms |
53.29 ms |
| b3d8889 |
420.46 ms |
453.71 ms |
33.26 ms |
| 6b019b7 |
403.90 ms |
546.09 ms |
142.19 ms |
| 889ecea |
367.58 ms |
437.52 ms |
69.94 ms |
| d15471f |
303.49 ms |
439.08 ms |
135.59 ms |
| d364ace |
384.53 ms |
453.51 ms |
68.98 ms |
| 6ea4329 |
309.06 ms |
353.48 ms |
44.42 ms |
| c8125f3 |
383.82 ms |
441.66 ms |
57.84 ms |
App size
| Revision |
Plain |
With Sentry |
Diff |
| 6b019b7 |
0 B |
0 B |
0 B |
| eb95ded |
0 B |
0 B |
0 B |
| 319f256 |
1.58 MiB |
2.19 MiB |
619.79 KiB |
| b3d8889 |
1.58 MiB |
2.10 MiB |
535.07 KiB |
| 6b019b7 |
0 B |
0 B |
0 B |
| 889ecea |
1.58 MiB |
2.11 MiB |
539.75 KiB |
| d15471f |
1.58 MiB |
2.13 MiB |
559.54 KiB |
| d364ace |
1.58 MiB |
2.11 MiB |
539.75 KiB |
| 6ea4329 |
1.58 MiB |
2.29 MiB |
719.82 KiB |
| c8125f3 |
1.58 MiB |
2.10 MiB |
532.32 KiB |
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MetricsBatchProcessor and LoggerBatchProcessor share a lot of complicated scheduling logic, is there a way we can share it?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
}
|
|
|
final int flushAfterMs = immediately ? 0 : FLUSH_AFTER_MS;
|
|
|
try {
|
|
|
executorService.schedule(new BatchRunnable(), flushAfterMs);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is hasScheduled supposed to be reset to false at some point?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Fails |
| 🚫 |
Please consider adding a changelog entry for the next release. |
Instructions and example for changelog
Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.
Example:
## Unreleased
### Fixes
- Prevent lost wakeups in batch processors ([#5756](https://github.com/getsentry/sentry-java/pull/5756))
If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.
Generated by 🚫 dangerJS against 62e5369
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
markushi
markushi approved these changes
romtsn
Awaiting requested review from romtsn
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|