private void sync(W writer) {
    fileLengthAtLastSync = writer.getLength();
    long currentHighestProcessedAppendTxid = highestProcessedAppendTxid;
    boolean shouldUseHsync =
      isHsync(highestProcessedAppendTxidAtLastSync, currentHighestProcessedAppendTxid);
    highestProcessedAppendTxidAtLastSync = currentHighestProcessedAppendTxid;
    final long startTimeNs = System.nanoTime();
    final long epoch = (long) epochAndState >>> 2L;
    addListener(doWriterSync(writer, shouldUseHsync, currentHighestProcessedAppendTxid),
      (result, error) -> {
        if (error != null) {
          syncFailed(epoch, error);
        } else {
          long syncedTxid = getSyncedTxid(currentHighestProcessedAppendTxid, result);
          syncCompleted(epoch, writer, syncedTxid, startTimeNs);
        }
      }, consumeExecutor);
  }
This method is used to be compatible with the original logic of {@link FSHLog}.
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.java