Skip to content
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

[Bug] Producer fails to send message size equals to maxMessageSize in topic policy setting. #12958

Closed
Jason918 opened this issue Nov 24, 2021 · 2 comments
Labels
type/bug The PR fixed a bug or issue reported a bug

Comments

@Jason918
Copy link
Contributor

Jason918 commented Nov 24, 2021

Describe the bug
See the following unit test code to reproduce this issue.

The root cause of this is that in topic policy setting, it limits the size of message header and payload.
See

if (isExceedMaximumMessageSize(headersAndPayload.readableBytes())) {

To Reproduce
Steps to reproduce the behavior:
Add this unit test code in org.apache.pulsar.broker.admin.TopicPoliciesTest

    @Test
    public void testTopicMaxMessageSizeThreshHold() throws Exception {
        @Cleanup
        Producer<byte[]> p = pulsarClient.newProducer().topic(testTopic).create();
        admin.topicPolicies().setMaxMessageSize(testTopic,1000);
        Awaitility.await().until(() -> pulsar.getTopicPoliciesService().getTopicPolicies(TopicName.get(testTopic)) != null);
        p.send(new byte[1000]);
    }

Got the following error:

org.apache.pulsar.client.api.PulsarClientException$NotAllowedException: The size of the message which is produced by producer test-0-2 to the topic persistent://my-tenant/my-namespace/test-set-backlog-quota-partition-0 is not allowed

Expected behavior
Message should produce success.

Screenshots
NA

Desktop (please complete the following information):

  • OS: macOS

Additional context
NA

@Jason918 Jason918 added the type/bug The PR fixed a bug or issue reported a bug label Nov 24, 2021
@Jason918
Copy link
Contributor Author

I think we can add new field "payload size" in CommandSend API.
And make topic policy only checks the payload size.
What do you think? @codelipenghui @315157973 @eolivelli

@Jason918
Copy link
Contributor Author

This will be fixed by PIP-132 in #13591
Close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant