[service] pdata.useProtoPooling releases fanned-out data before all consumers receive it
Component(s)
service
What happened?
Describe the bug
With +pdata.useProtoPooling, when one pdata is fanned out to multiple consumers, the first consumer can return the data to the pool when it returns.
The following setups are affected:
- A receiver shared by multiple pipelines
- A pipeline with multiple exporters
- A processor that creates new data (e.g. batch) followed by multiple exporters
- A connector that creates new data and routes it to multiple pipelines
When no node owns the data before the fanout, the refconsumer of the first consumer takes ownership and calls Unref when it returns. If no other reference is held, refs drops to 0 and the data is reset and returned to the pool before the remaining consumers receive it.
I propose fixing this in internal/fanoutconsumer take ownership of data that is not owned yet and release it after all consumers have been called.
Steps to reproduce
Share one receiver between two logs pipelines and give each pipeline's exporter a memory queue (queue batching disabled). Then send logs under concurrent load.
receivers:
otlp:
protocols:
http:
exporters:
otlphttp/a:
endpoint: http://127.0.0.1:5318
sending_queue:
batch: null
otlphttp/b:
endpoint: http://127.0.0.1:6318
sending_queue:
batch: null
service:
pipelines:
logs/a:
receivers: [otlp]
exporters: [otlphttp/a]
logs/b:
receivers: [otlp]
exporters: [otlphttp/b]otelcol --config=config.yaml --feature-gates=+pdata.useProtoPoolingWhat did you expect to see?
Every consumer receives the same complete data, and no panic occurs.
What did you see instead?
- Consumers called later receive empty data.
- The exporterhelper queue panics while marshaling with
index out of range,slice bounds out of range, ornil pointer dereference.
Collector version
78b98e74f
Environment information
Environment
OS: darwin/arm64 go 1.26.5
OpenTelemetry Collector configuration
Log output
Additional context
No response
Tip
React with to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
Source: open-telemetry/opentelemetry-collector