zhangshuyan0 commented on PR #5499:
URL: https://github.com/apache/hadoop/pull/5499#issuecomment-1478896102

   It is a great idea to avoid unnecessary `FSEditLog#logSync()`  costs. We may 
be able to make this feature more general.
   When `FSEditLogAsync` is used, `FSEditLog#logSync()` does nothing because 
`THREAD_EDIT.get()` is null.
   
https://github.com/apache/hadoop/blob/67e02a92e0b9c4da3dcdd01f231a98f243f12d06/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogAsync.java#L139-L149
   So we only need to pay attention to the scenarios where `FSEditLog` is used. 
   
https://github.com/apache/hadoop/blob/67e02a92e0b9c4da3dcdd01f231a98f243f12d06/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java#L661-L664
   I think we can solve this problem in a similar way, modify `FSEditLog` as 
follows:
   ```
   public void logSync() {
       // Fetch the transactionId of this thread.
       if (myTransactionId.get().txid != -1) {
         long id = myTransactionId.get().txid;
         logSync(id);
         myTransactionId.get().txid = -1;
       }
     }
   ```
   In this way, we don't have to consider whether there is EditLog written 
every time we call logSync().
   Please feel free to disagree.


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to