Nicklee007 opened a new pull request, #18747:
URL: https://github.com/apache/pulsar/pull/18747
### Motivation
To avoid OOM exception not trigger `PulsarByteBufAllocator
outOfMemoryListener`, we should use `PulsarByteBufAllocator.DEFAULT` to replace
`ByteBufAllocator.DEFAULT` to allocate memory;
In our case, broker.conf set as `skipBrokerShutdownOnOOM=false`
and the prometheus-stats-39-1 throw OOM exception, but not trigger broker
shutdown.
```
[prometheus-stats-39-1] ERROR
org.apache.bookkeeper.common.util.SafeRunnable - Unexpected throwable caught
java.lang.Error: java.lang.reflect.InvocationTargetException
Caused by: java.lang.OutOfMemoryError: Java heap space
at
jdk.internal.misc.Unsafe.allocateUninitializedArray(Unsafe.java:1269) ~[?:?]
at jdk.internal.reflect.GeneratedMethodAccessor18.invoke(Unknown
Source) ~[?:?]
at
jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at
io.netty.util.internal.PlatformDependent0.allocateUninitializedArray(PlatformDependent0.java:575)
at
io.netty.util.internal.PlatformDependent.allocateUninitializedArray(PlatformDependent.java:287)
at
io.netty.buffer.PoolArena$HeapArena.newByteArray(PoolArena.java:567)
at
io.netty.buffer.PoolArena$HeapArena.newUnpooledChunk(PoolArena.java:583)
at io.netty.buffer.PoolArena.allocateHuge(PoolArena.java:214)
at io.netty.buffer.PoolArena.allocate(PoolArena.java:141)
at io.netty.buffer.PoolArena.reallocate(PoolArena.java:287)
at io.netty.buffer.PooledByteBuf.capacity(PooledByteBuf.java:122)
at
io.netty.buffer.AbstractByteBuf.ensureWritable0(AbstractByteBuf.java:305)
at
io.netty.buffer.AbstractByteBuf.writeByte(AbstractByteBuf.java:984)
at
org.apache.pulsar.common.util.SimpleTextOutputStream.write(SimpleTextOutputStream.java:57)
at
org.apache.pulsar.broker.stats.prometheus.TopicStats.appendRequiredLabels(TopicStats.java:453)
at
org.apache.pulsar.broker.stats.prometheus.TopicStats.metric(TopicStats.java:385)
at
org.apache.pulsar.broker.stats.prometheus.TopicStats.printTopicStats(TopicStats.java:128)
at
org.apache.pulsar.broker.stats.prometheus.NamespaceStatsAggregator.lambda$generate$0(NamespaceStatsAggregator.java:84)
at
org.apache.pulsar.broker.stats.prometheus.NamespaceStatsAggregator$$Lambda$1115/0x00000008009d5840.accept(Unknown
Source) ~[?:?]
at
org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap$Section.forEach(ConcurrentOpenHashMap.java:544)
at
org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap.forEach(ConcurrentOpenHashMap.java:272)
at
org.apache.pulsar.broker.stats.prometheus.NamespaceStatsAggregator.lambda$generate$1(NamespaceStatsAggregator.java:75)
at
org.apache.pulsar.broker.stats.prometheus.NamespaceStatsAggregator$$Lambda$1114/0x00000008009d4840.accept(Unknown
Source) ~[?:?]
at
org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap$Section.forEach(ConcurrentOpenHashMap.java:544)
at
org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap.forEach(ConcurrentOpenHashMap.java:272)
at
org.apache.pulsar.broker.stats.prometheus.NamespaceStatsAggregator.lambda$generate$2(NamespaceStatsAggregator.java:74)
at
org.apache.pulsar.broker.stats.prometheus.NamespaceStatsAggregator$$Lambda$1113/0x00000008009d3440.accept(Unknown
Source) ~[?:?]
at
org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap$Section.forEach(ConcurrentOpenHashMap.java:544)
at
org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap.forEach(ConcurrentOpenHashMap.java:272)
at
org.apache.pulsar.broker.stats.prometheus.NamespaceStatsAggregator.generate(NamespaceStatsAggregator.java:70)
at
org.apache.pulsar.broker.stats.prometheus.PrometheusMetricsGenerator.generate(PrometheusMetricsGenerator.java:110)
```
### Modifications
1. Use `PulsarByteBufAllocator.DEFAULT` replace `ByteBufAllocator.DEFAULT`
in `PrometheusMetricsGenerator/PrometheusMetricsGeneratorUtils/SchemaUtils`.
### Documentation
- [X] `doc-not-needed` <!-- Your PR changes do not impact docs -->
--
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]