Github user anew commented on a diff in the pull request:

    https://github.com/apache/incubator-tephra/pull/53#discussion_r138731295
  
    --- Diff: 
tephra-core/src/main/java/org/apache/tephra/persist/AbstractTransactionLog.java 
---
    @@ -85,44 +99,20 @@ public long getTimestamp() {
     
       @Override
       public void append(TransactionEdit edit) throws IOException {
    -    long startTime = System.nanoTime();
    -    synchronized (this) {
    -      ensureAvailable();
    -
    -      Entry entry = new Entry(new 
LongWritable(logSequence.getAndIncrement()), edit);
    -
    -      // add to pending edits
    -      append(entry);
    -    }
    -
    -    // wait for sync to complete
    -    sync();
    -    long durationMillis = (System.nanoTime() - startTime) / 1000000L;
    -    if (durationMillis > SLOW_APPEND_THRESHOLD) {
    -      LOG.info("Slow append to log " + getName() + ", took " + 
durationMillis + " msec.");
    -    }
    +    append(Collections.singletonList(edit));
       }
     
       @Override
       public void append(List<TransactionEdit> edits) throws IOException {
    -    long startTime = System.nanoTime();
    -    synchronized (this) {
    +    // synchronizing here ensures that elements in the queue are ordered 
by seq number
    +    synchronized (logSequence) {
           ensureAvailable();
    --- End diff --
    
    Good point, actually it is only used in one place, so I will just inline it 
outside the synchronize.


---

Reply via email to