Skip to content

[OpAMP] Fix for enabling memory profiling when concurrent JFR recording is in progress - #3238

Closed
robsunday wants to merge 3 commits into
signalfx:mainfrom
robsunday:fix-for-multi-concurrent-jfr-recordings
Closed

robsunday wants to merge 3 commits into
signalfx:mainfrom
robsunday:fix-for-multi-concurrent-jfr-recordings

Conversation

@robsunday

@robsunday robsunday commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

In the following scenario:

  1. Run instrumented application with JFR recording enabled at startup
  2. Enable Always On memory profiling using OpAMP remote config

The following exception was sometimes thrown:

[otel.javaagent 2026-11-30 12:01:27:050 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilerConfiguration - -----------------------
[otel.javaagent 2026-11-30 12:01:27:050 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilerConfiguration - Profiler configuration:
[otel.javaagent 2026-11-30 12:01:27:050 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilerConfiguration -                        Enabled : true
[otel.javaagent 2026-11-30 12:01:27:051 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilerConfiguration -              ProfilerDirectory : /var/folders/cq/94h22h2s4cxchbw727rmzcsm0000gn/T/
[otel.javaagent 2026-11-30 12:01:27:051 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilerConfiguration -              RecordingDuration : 20000ms
[otel.javaagent 2026-11-30 12:01:27:051 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilerConfiguration -                      KeepFiles : false
[otel.javaagent 2026-11-30 12:01:27:052 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilerConfiguration -                   OtlpProtocol : null
[otel.javaagent 2026-11-30 12:01:27:052 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilerConfiguration -                      IngestUrl : null
[otel.javaagent 2026-11-30 12:01:27:052 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilerConfiguration -                  MemoryEnabled : true
[otel.javaagent 2026-11-30 12:01:27:053 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilerConfiguration -                MemoryEventRate : 200/s
[otel.javaagent 2026-11-30 12:01:27:053 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilerConfiguration -       UseAllocationSampleEvent : false
[otel.javaagent 2026-11-30 12:01:27:053 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilerConfiguration -              CallStackInterval : 10ms
[otel.javaagent 2026-11-30 12:01:27:053 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilerConfiguration -     IncludeAgentInternalStacks : false
[otel.javaagent 2026-11-30 12:01:27:054 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilerConfiguration -       IncludeJvmInternalStacks : false
[otel.javaagent 2026-11-30 12:01:27:054 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilerConfiguration -              TracingStacksOnly : false
[otel.javaagent 2026-11-30 12:01:27:054 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilerConfiguration -                   LocksEnabled : false
[otel.javaagent 2026-11-30 12:01:27:055 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilerConfiguration -                     StackDepth : 1024
[otel.javaagent 2026-11-30 12:01:27:055 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilerConfiguration - -----------------------
[otel.javaagent 2026-11-30 12:01:27:078 +0100] [Splunk Profiler] INFO com.splunk.opentelemetry.profiler.ProfilingSupervisor - Profiler is active.
[otel.javaagent 2026-11-30 12:01:27:091 +0100] [JFR Recording Flusher] ERROR com.splunk.opentelemetry.profiler.JfrRecordingHandler - Error parsing JFR recording
java.lang.IllegalStateException: delegate not set
	at com.splunk.opentelemetry.profiler.allocation.sampler.RateLimitingAllocationEventSampler.shouldSample(RateLimitingAllocationEventSampler.java:61)
	at com.splunk.opentelemetry.profiler.TLABProcessor.accept(TLABProcessor.java:65)
	at com.splunk.opentelemetry.profiler.EventProcessingChain.dispatchEvent(EventProcessingChain.java:124)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
	at com.splunk.opentelemetry.profiler.EventProcessingChain.flush(EventProcessingChain.java:78)
	at com.splunk.opentelemetry.profiler.JfrRecordingHandler.accept(JfrRecordingHandler.java:90)
	at com.splunk.opentelemetry.profiler.JfrRecordingHandler.accept(JfrRecordingHandler.java:47)
	at com.splunk.opentelemetry.profiler.JfrRecorder.flushSnapshot(JfrRecorder.java:113)
	at com.splunk.opentelemetry.profiler.PeriodicRecordingFlusher.handleInterval(PeriodicRecordingFlusher.java:75)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:545)
	at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:369)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:310)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1090)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:614)
	at java.base/java.lang.Thread.run(Thread.java:1474)

If exception was not thrown, then then turn off the profiler and turn it on again (repeat if necessary).

Why the exception occurs

JFR shares event data across recordings in the same JVM. If a separate recording enables jdk.ObjectAllocationSample, that event can appear in the profiler’s snapshot even when the profiler is configured to use TLAB events and its own rate limiter.

The rate limiter initializes its delegate only when a chunk contains jdk.ObjectAllocationInNewTLAB or jdk.ObjectAllocationOutsideTLAB. Previously, the allocation processor also passed jdk.ObjectAllocationSample to that sampler. If the sample arrived before any TLAB events had initialized the delegate, the sampler threw IllegalStateException: delegate not set. This aborted processing before later events, including thread dumps, could be handled.

What changed

The allocation processor now accepts only the event types selected by the profiler’s sampling mode. Native sampling accepts jdk.ObjectAllocationSample. TLAB mode accepts the two TLAB event types. The JFR settings and the allocation processor use the same configuration check to select the mode.

@robsunday
robsunday requested review from a team as code owners November 30, 2026 11:57
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-30T11:58:54.564746Z fb059ae PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@robsunday robsunday closed this Nov 30, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant