Skip to content

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

@Jason918

Description

@Jason918

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugThe PR fixed a bug or issue reported a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions