liangyepianzhou commented on a change in pull request #12219:
URL: https://github.com/apache/pulsar/pull/12219#discussion_r728020863



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TopicTransactionBuffer.java
##########
@@ -163,6 +174,34 @@ public void recoverExceptionally(Exception e) {
     @Override
     public CompletableFuture<Position> appendBufferToTxn(TxnID txnId, long 
sequenceId, ByteBuf buffer) {
         CompletableFuture<Position> completableFuture = new 
CompletableFuture<>();
+        if (checkIfReady()){
+            addTxnEntry(completableFuture, txnId, buffer);
+        } else {
+            if (checkIfUnused() && changeToInitializingStateFromUnused()){
+                //`PulsarDecoder` will release this buffer  in `finally` and 
`takeSnapshot` is asynchronous
+                buffer.retain();
+                takeSnapshot().thenAccept(ignore -> {
+                    changeToReadyState();

Review comment:
       In order to ensure the orderliness of the messages and no ambiguity, we 
hope that the first transaction will directly fail, and then the client will 
resend the requests.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to