GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): Prevent lost wakeups in batch processors by adinauer · Pull Request #5756 · getsentry/sentry-java

Conversation

@adinauer

@adinauer adinauer commented Jul 13, 2026 •
edited by markushi
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

📜 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
All reactions
  • 🎉 1 reaction
adinauer and others added 2 commits July 13, 2026 10:53
@adinauer @claude
fix(core): Prevent lost wakeups in batch processors
a916876
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]>
@adinauer
changelog
62e5369
@sentry

sentry Bot commented Jul 13, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.48.0 (1) release

⚙️ sentry-android Build Distribution Settings

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

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
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@adinauer
adinauer marked this pull request as ready for review July 13, 2026 10:04
@adinauer
adinauer requested review from 0xadam-brown, markushi, romtsn and runningcode as code owners July 13, 2026 10:04
markushi
markushi approved these changes Jul 13, 2026
View reviewed changes

@markushi markushi left a comment

Copy link
Copy Markdown
Member

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.

LGTM!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@adinauer
adinauer merged commit 98106dd into main Jul 13, 2026
72 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@adinauer
adinauer deleted the fix/batch-processor-lost-wakeup branch July 13, 2026 12:30
runningcode
runningcode reviewed Jul 15, 2026
View reviewed changes

@runningcode runningcode left a comment

Copy link
Copy Markdown
Contributor

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.

All reactions
Comment thread sentry/src/main/java/io/sentry/logger/LoggerBatchProcessor.java
}
final int flushAfterMs = immediately ? 0 : FLUSH_AFTER_MS;
try {
executorService.schedule(new BatchRunnable(), flushAfterMs);

@runningcode runningcode Jul 15, 2026

Copy link
Copy Markdown
Contributor

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.

All reactions
@sentry-release-bot sentry-release-bot Bot mentioned this pull request Jul 16, 2026
publish: getsentry/[email protected] getsentry/publish#8917
Closed
3 tasks
@github-actions github-actions Bot mentioned this pull request Jul 16, 2026
Lost-wakeup race in the Logs/Metrics batch processor can strand queued events past the flush interval #5739
Closed
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor
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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@runningcode runningcode runningcode left review comments
@markushi markushi markushi approved these changes
@romtsn romtsn Awaiting requested review from romtsn
@0xadam-brown 0xadam-brown Awaiting requested review from 0xadam-brown

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Lost-wakeup race in the Logs/Metrics batch processor can strand queued events past the flush interval

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@adinauer @runningcode @markushi
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.