You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/12/23 09:43:25 UTC
[GitHub] [pulsar] codelipenghui commented on a change in pull request #13454: Fix semaphore and memory leak when chunks failed to enqueue
codelipenghui commented on a change in pull request #13454:
URL: https://github.com/apache/pulsar/pull/13454#discussion_r774445669
##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/client/impl/MessageChunkingTest.java
##########
@@ -369,6 +374,43 @@ public void testExpireIncompleteChunkMessage() throws Exception{
producer = null; // clean reference of mocked producer
}
+ @Test
+ public void testChunksEnqueueFailed() throws Exception {
+ final String topicName = "persistent://my-property/my-ns/test-chunks-enqueue-failed";
+ log.info("-- Starting {} test --", methodName);
+ this.conf.setMaxMessageSize(5);
+
+ final MemoryLimitController controller = ((PulsarClientImpl) pulsarClient).getMemoryLimitController();
+ assertEquals(controller.currentUsage(), 0);
+
+ final int maxPendingMessages = 10;
+
+ @Cleanup
+ Producer<byte[]> producer = pulsarClient.newProducer()
+ .topic(topicName)
+ .maxPendingMessages(maxPendingMessages)
+ .enableChunking(true)
+ .enableBatching(false)
+ .create();
+ assertTrue(producer instanceof ProducerImpl);
+ Semaphore semaphore = ((ProducerImpl<byte[]>) producer).getSemaphore().orElse(null);
+ assertNotNull(semaphore);
+ assertEquals(semaphore.availablePermits(), maxPendingMessages);
+ producer.send(createMessagePayload(1).getBytes());
+ try {
+ producer.send(createMessagePayload(100).getBytes(StandardCharsets.UTF_8));
Review comment:
The producer will not hit the pending message limitation and the memory limitation, if the messages published successfully, will not reach the catch branch.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org