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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -299,12 +301,15 @@ public PersistentTopic(String topic, ManagedLedger 
ledger, BrokerService brokerS
         TopicName topicName = TopicName.get(topic);
         if 
(brokerService.getPulsar().getConfiguration().isTransactionCoordinatorEnabled()
                 && !isEventSystemTopic(topicName)) {
+            this.transactionEnabled = false;
             this.transactionBuffer = brokerService.getPulsar()
                     .getTransactionBufferProvider().newTransactionBuffer(this);
+            
this.transactionBuffer.syncMaxReadPositionForNormalPublish((PositionImpl) 
ledger.getLastConfirmedEntry());
         } else {
+            this.transactionEnabled = true;
             this.transactionBuffer = new TransactionBufferDisable();

Review Comment:
   why not use TransactionBufferDisable directly? in this way, we don't need 
check the transactionEnabled



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -299,12 +301,15 @@ public PersistentTopic(String topic, ManagedLedger 
ledger, BrokerService brokerS
         TopicName topicName = TopicName.get(topic);
         if 
(brokerService.getPulsar().getConfiguration().isTransactionCoordinatorEnabled()
                 && !isEventSystemTopic(topicName)) {
+            this.transactionEnabled = false;
             this.transactionBuffer = brokerService.getPulsar()
                     .getTransactionBufferProvider().newTransactionBuffer(this);
+            
this.transactionBuffer.syncMaxReadPositionForNormalPublish((PositionImpl) 
ledger.getLastConfirmedEntry());
         } else {
+            this.transactionEnabled = true;

Review Comment:
   why this.transactionEnabled = true ?



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java:
##########
@@ -1357,7 +1358,14 @@ protected void handleProducer(final CommandProducer 
cmdProducer) {
                     });
 
                     schemaVersionFuture.thenAccept(schemaVersion -> {
-                        
topic.checkIfTransactionBufferRecoverCompletely(isTxnEnabled).thenAccept(future 
-> {
+                        CompletableFuture<Void> checkTxnRecoverFuture;
+                        if (isTxnEnabled) {
+                            checkTxnRecoverFuture = 
topic.checkIfTransactionBufferRecoverCompletely();
+                        } else {
+                            checkTxnRecoverFuture = 
TransactionBuffer.TRANSACTION_NOT_ENABLED;
+                        }

Review Comment:
   It's better to check `isTxnEnable` in 
`checkIfTransactionBufferRecoverCompletely `, it will make the logic in 
`ServerCnx` more clear



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