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 2022/04/07 12:14:41 UTC

[GitHub] [pulsar] congbobo184 commented on a diff in pull request #15061: [fix][txn]: fix transaction producer stuck problem

congbobo184 commented on code in PR #15061:
URL: https://github.com/apache/pulsar/pull/15061#discussion_r845061819


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/TopicTransactionBufferRecoverTest.java:
##########
@@ -569,4 +570,52 @@ public void testTransactionBufferNoSnapshotCloseReader() throws Exception{
         assertTrue(stats.getSubscriptions().keySet().contains("__compaction"));
     }
 
+    @Test
+    public void transactionBufferRecoverFailRemoveProducerFuture() throws Exception {
+        String topic = NAMESPACE1 + "/transactionBufferRecoverFailRemoveProducerFuture";
+
+        @Cleanup
+        Producer<byte[]> producer = pulsarClient
+                .newProducer()
+                .topic(topic)
+                .sendTimeout(0, TimeUnit.SECONDS)
+                .create();
+
+
+        // txn buffer init success
+        Transaction txn = pulsarClient.newTransaction()
+                .withTransactionTimeout(5, TimeUnit.SECONDS)
+                .build().get();
+        producer.newMessage(txn).value("test".getBytes()).sendAsync();
+        producer.newMessage(txn).value("test".getBytes()).sendAsync();
+        txn.commit().get();
+
+        PersistentTopic originalTopic = (PersistentTopic) getPulsarServiceList().get(0)
+                .getBrokerService().getTopic(TopicName.get(topic).toString(), false).get().get();
+        TopicTransactionBuffer topicTransactionBuffer = (TopicTransactionBuffer) originalTopic.getTransactionBuffer();
+
+        CompletableFuture<Void> bufferFuture = new CompletableFuture<>();
+        bufferFuture.completeExceptionally(new BrokerServiceException.ServiceUnitNotReadyException("test"));
+
+        // set fail future to topic transaction buffer
+        Field field = TopicTransactionBuffer.class.getDeclaredField("transactionBufferFuture");
+        field.setAccessible(true);
+        field.set(topicTransactionBuffer, bufferFuture);

Review Comment:
   cool!



-- 
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