-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[improve] Use single buffer for metrics when noUnsafe use #23612
[improve] Use single buffer for metrics when noUnsafe use #23612
Conversation
--- ### Motivation Netty has a property io.netty.noUnsafe which allows to force don't use unsafe api. When this is enabled, the metrics won't collect because of the Unspport operation exception. The root cause is it calls the internalNioBuffer which only allow to call when the buffer count is 1. But when using the composite buffer the buffer count may more than 1. So use the buffer directly when the flag is enabled. The exception: Caused by: java.lang.UnsupportedOperationException at io.netty.buffer.CompositeByteBuf.internalNioBuffer(CompositeByteBuf.java:1657) ~[io.netty-netty-buffer-4.1.113.Final.jar:4.1.113.Final] at io.netty.buffer.ByteBufUtil.writeUtf8(ByteBufUtil.java:924) ~[io.netty-netty-buffer-4.1.113.Final.jar:4.1.113.Final] at io.netty.buffer.ByteBufUtil.writeUtf8(ByteBufUtil.java:900) ~[io.netty-netty-buffer-4.1.113.Final.jar:4.1.113.Final] at io.netty.buffer.AbstractByteBuf.setCharSequence0(AbstractByteBuf.java:707) ~[io.netty-netty-buffer-4.1.113.Final.jar:4.1.113.Final]
@zymap Please add the following content to your PR description and select a checkbox:
|
The PR itself makes sense. However, there shouldn't be a need to ever disable the unsafe API when running Pulsar. It would cause a lot of performance issues if that's used. What would be the motivation for disabling the unsafe API? |
.../src/test/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGeneratorTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the comment on the test.
We hit an issue with following core dump
And set |
...va/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGeneratorWithNoUnsafeTest.java
Outdated
Show resolved
Hide resolved
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #23612 +/- ##
============================================
+ Coverage 73.57% 74.34% +0.77%
- Complexity 32624 34463 +1839
============================================
Files 1877 1944 +67
Lines 139502 147200 +7698
Branches 15299 16240 +941
============================================
+ Hits 102638 109441 +6803
- Misses 28908 29314 +406
- Partials 7956 8445 +489
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 9b79d70)
Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 9b79d70)
Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 9b79d70)
Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 9b79d70) (cherry picked from commit aee413b)
Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 9b79d70) (cherry picked from commit aee413b)
@lhotari Thanks for fixing it! |
Motivation
We have met some core dumps when running pulsar service. Then saw Netty suggested using
io.netty.noUnsafe
to see if it works. netty/netty#2950. After adding that property, the core dump is gone, but the metrics failed to report because of the UnsupportedOpeartion exception.Netty has a property io.netty.noUnsafe which allows disabling use the unsafe api. When this is enabled, the metrics won't collect because of the Unspport operation exception.
The root cause is it calls the internalNioBuffer which only allow to call when the buffer count is 1. But when using the composite buffer the buffer count may more than 1.
So use the buffer directly when the flag is enabled.
The exception:
Caused by: java.lang.UnsupportedOperationException
at io.netty.buffer.CompositeByteBuf.internalNioBuffer(CompositeByteBuf.java:1657) ~[io.netty-netty-buffer-4.1.113.Final.jar:4.1.113.Final]
at io.netty.buffer.ByteBufUtil.writeUtf8(ByteBufUtil.java:924) ~[io.netty-netty-buffer-4.1.113.Final.jar:4.1.113.Final]
at io.netty.buffer.ByteBufUtil.writeUtf8(ByteBufUtil.java:900) ~[io.netty-netty-buffer-4.1.113.Final.jar:4.1.113.Final] at io.netty.buffer.AbstractByteBuf.setCharSequence0(AbstractByteBuf.java:707) ~[io.netty-netty-buffer-4.1.113.Final.jar:4.1.113.Final]
Fixes #xyz
Main Issue: #xyz
PIP: #xyz
Motivation
Modifications
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: