-
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
[fix][client] Cache empty schema version in ProducerImpl schemaCache. #19929
[fix][client] Cache empty schema version in ProducerImpl schemaCache. #19929
Conversation
When read from schemaCache, check if the schema version means empty. when use Schema.BYTES consumer and enable retry and dlq policy. need cache the empty schema version to avoid send a lot of GetOrCreateSchema request to retrieve the schema version.
Why the BYTES schema consumer's retry producer and dlq consumer keeps sending GetOrCreateSchema to broker?
pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java Lines 653 to 660 in ec102fb
so when each message is send to broker. an GetOrCreateSchema rpc is also send to broker. |
@BewareMyPower @poorbarcode @Technoboy- can you take a look ? this is a problem occur on master code and in our prod environment. |
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.
Could you also add a unit test for it? I think we can use a mocked ServerCnx
to record the number of the CommandGetOrCreateSchema requests received.
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.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 also add the test mentioned in #19928
c66bc27
to
131dcbe
Compare
@BewareMyPower @Technoboy- unit test added, please take a look |
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ProducerEmptySchemaCacheTest.java
Outdated
Show resolved
Hide resolved
ping @BewareMyPower @Technoboy- @congbobo184 @liangyepianzhou can you take a look ? thank you : - ) |
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ProducerEmptySchemaCacheTest.java
Show resolved
Hide resolved
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ProducerEmptySchemaCacheTest.java
Outdated
Show resolved
Hide resolved
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ProducerEmptySchemaCacheTest.java
Show resolved
Hide resolved
1. send more messages 2. make send case more like deadLetterProducer
Since we will start the RC version of
So drag this PR to |
Codecov Report
@@ Coverage Diff @@
## master #19929 +/- ##
=============================================
+ Coverage 61.50% 72.85% +11.35%
- Complexity 25755 31623 +5868
=============================================
Files 1859 1861 +2
Lines 136792 137503 +711
Branches 15043 15143 +100
=============================================
+ Hits 84129 100177 +16048
+ Misses 44857 29366 -15491
- Partials 7806 7960 +154
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…#19929) Co-authored-by: wangjinlong <[email protected]> (cherry picked from commit cff3f9b)
…#19929) Co-authored-by: wangjinlong <[email protected]> (cherry picked from commit cff3f9b)
…apache#19929) Co-authored-by: wangjinlong <[email protected]> (cherry picked from commit cff3f9b) (cherry picked from commit a46acef)
Fixes #19928
Motivation
When use Schema.BYTES consumer and enable retry and dlq policy.
need cache the empty schema version to avoid send a lot of GetOrCreateSchema request to retrieve the schema version.
Modifications
Cache empty schema version in ProducerImpl schemaCache.
When read from schemaCache, check if the schema version means empty.
Verifying this change
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: