Skip to content

fix(spring): Prevent Reactor pool scope chain leaks - #6283

Merged
adinauer merged 5 commits into
mainfrom
fix/reactor-pool-scope-leak
Oct 27, 2026
Merged

adinauer merged 5 commits into
mainfrom
fix/reactor-pool-scope-leak

Conversation

@adinauer

@adinauer adinauer commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

📜 Description

Exclude Reactor Netty pool maintenance runnables from SentryScheduleHook scope propagation. The exclusions cover HTTP/1.1 and HTTP/2 background eviction as well as inactive-pool disposal across all Spring integrations.

💡 Motivation and Context

These maintenance tasks schedule their next run while the current wrapped run is still active. Each scheduling pass therefore forks from the previous pass and retains it through parentScopes, creating an unbounded scope chain. In the production report, 63 connection pools retained approximately 4 GB after 12.8 days.

Infrastructure maintenance tasks do not need request scope propagation, so narrowly excluding their runtime class prefixes prevents the chain without affecting normal Reactor scheduler boundaries such as publishOn and subscribeOn. The standalone Reactor Pool SimpleDequePool is intentionally not excluded because it uses the same lambda class prefix for request-carrying acquisition delivery.

Partially addresses #6248
Refs JAVA-773

💚 How did you test it?

Ran the issue's real Reactor Netty ConnectionProvider.evictInBackground reproduction locally for 100 eviction schedules. Scope depth reached 103 without the exclusions and remained below 10 with them. A real H2C client reproduction reached depth 100 without the HTTP/2 exclusion and remained at depth 2 with it.

Added exclusion-matching tests for the Spring Boot 2, 3, and 4 integrations, including numbered and unnumbered JVM lambda class names and request-carrying negative cases.

  • ./gradlew :sentry-spring:test :sentry-spring-jakarta:test :sentry-spring-7:test --tests='*SentryScheduleHookTest' --info
  • ./gradlew spotlessApply apiDump

📝 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

Investigate a generic task-scope retention fix for the next major version.

Skip scope propagation for Reactor pool maintenance tasks that reschedule themselves indefinitely. This prevents each run from retaining the previous run through the parent scope chain.

Add a Reactor Netty connection pool regression test that verifies background eviction keeps scope depth bounded.

Fixes GH-6248
Refs JAVA-773
Co-Authored-By: Claude <noreply@anthropic.com>
@linear-code

linear-code Bot commented Oct 19, 2026

Copy link
Copy Markdown

JAVA-773

adinauer and others added 2 commits October 19, 2026 12:38
Remove the Reactor Netty integration test and its test-only Truth dependency.

Co-Authored-By: Claude <noreply@anthropic.com>
@sentry

sentry Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

Exclude HTTP/2 eviction lambdas and narrow the existing Reactor Netty
matches to maintenance lambdas. Keep standalone Reactor Pool acquisition
delivery wrapped so request scopes continue to propagate.

Add coverage for supported lambda class name shapes and request-carrying
negative cases across all Spring integrations.

Refs GH-6248
Refs JAVA-773
Co-Authored-By: Claude <noreply@anthropic.com>
@adinauer
adinauer marked this pull request as ready for review October 22, 2026 14:11

@lbloder lbloder left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@adinauer
adinauer merged commit 28e2389 into main Oct 27, 2026
62 of 66 checks passed
@adinauer
adinauer deleted the fix/reactor-pool-scope-leak branch October 27, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants