Houlong66 commented on issue #10240:
URL: https://github.com/apache/rocketmq/issues/10240#issuecomment-4177016432

   ## Follow-up: Fix for `ArrayIndexOutOfBoundsException` during OTLP export
   
   In addition to the original gRPC 32MB payload limit issue, we discovered a 
related concurrent modification bug in production:
   
   ```
   java.lang.ArrayIndexOutOfBoundsException: Index 9689 out of bounds for 
length 9689
       at 
io.opentelemetry.exporter.internal.otlp.metrics.NumberDataPointMarshaler.createRepeated(NumberDataPointMarshaler.java:35)
   ```
   
   **Root cause**: The OTel SDK's `NumberDataPointMarshaler.createRepeated` 
allocates an array based on `points.size()`, then iterates to fill it. If 
callback threads concurrently add data points between the `size()` call and 
iteration completion, the iterator yields more elements than the array can 
hold, causing AIOOBE.
   
   **Fix**: Added a defensive snapshot step at the start of 
`BatchSplittingMetricExporter.export()` — all data point collections are copied 
into new `ArrayList` instances before being passed to the delegate exporter. 
This ensures the OTel SDK marshaling code always works with immutable 
snapshots, regardless of concurrent callback activity.
   
   The snapshot is a shallow copy (references only, ~800KB for 100K data 
points), created once per export cycle (~60s) and immediately GC-eligible after 
export completes. Negligible overhead.
   
   See commit: 81915011cc


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to