poorbarcode commented on code in PR #16758:
URL: https://github.com/apache/pulsar/pull/16758#discussion_r942601545


##########
pulsar-transaction/coordinator/src/main/java/org/apache/pulsar/transaction/coordinator/impl/TxnLogBufferedWriter.java:
##########
@@ -210,9 +210,15 @@ public void asyncAddData(T data, AddDataCallback callback, 
Object ctx){
             return;
         }
         singleThreadExecutorForWrite.execute(() -> {
+            int recordsCountBeforeAdd = dataArray.size();
             try {
                 internalAsyncAddData(data, callback, ctx);
             } catch (Exception e){
+                // Avoid missing callback, do failed callback when error occur 
before add data to the array.
+                int recordsCountAfter = dataArray.size();
+                if (recordsCountAfter == recordsCountBeforeAdd){
+                    callback.addFailed(new 
ManagedLedgerException.ManagedLedgerFencedException(e), ctx);

Review Comment:
   > import static ManagedLedgerException to shorten expression.
   
   The ManagedLedgerException created here uses the parameter `e`, so it cannot 
be set as a static variable.
   
   > Can you please explain why did you choose the Fenced exception for this 
specific error which you don't know its nature?
   
   No exception is thrown in the block of "try catch". If it does, it will be 
due to coding errors such as `data Serializer` or `metrics`.



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