private void drainNonMarkerEditsAndFailSyncs() {
    if (toWriteAppends.isEmpty()) {
      return;
    }
    boolean hasNonMarkerEdits = false;
    Iterator<FSWALEntry> iter = toWriteAppends.descendingIterator();
    while (iter.hasNext()) {
      FSWALEntry entry = iter.next();
      if (!entry.getEdit().isMetaEdit()) {
        entry.release();
        hasNonMarkerEdits = true;
        break;
      }
    }
    if (hasNonMarkerEdits) {
      for (;;) {
        iter.remove();
        if (!iter.hasNext()) {
          break;
        }
        iter.next().release();
      }
      for (FSWALEntry entry : unackedAppends) {
        entry.release();
      }
      unackedAppends.clear();
      // fail the sync futures which are under the txid of the first remaining edit, if none, fail
      // all the sync futures.
      long txid = toWriteAppends.isEmpty() ? Long.MAX_VALUE : toWriteAppends.peek().getTxid();
      IOException error = new IOException("WAL is closing, only marker edit is allowed");
      for (Iterator<SyncFuture> syncIter = syncFutures.iterator(); syncIter.hasNext();) {
        SyncFuture future = syncIter.next();
        if (future.getTxid() < txid) {
          markFutureDoneAndOffer(future, future.getTxid(), error);
          syncIter.remove();
        } else {
          break;
        }
      }
    }
  }
Append a set of edits to the WAL.
<p/>
The WAL is not flushed/sync'd after this transaction completes BUT on return this edit must
have its region edit/sequence id assigned else it messes up our unification of mvcc and
sequenceid. On return <code>key</code> will have the region edit/sequence id filled in.
<p/>
NOTE: This appends, at a time that is usually after this call returns, starts a mvcc
transaction by calling 'begin' wherein which we assign this update a sequenceid. At assignment
time, we stamp all the passed in Cells inside WALEdit with their sequenceId. You must
'complete' the transaction this mvcc transaction by calling
MultiVersionConcurrencyControl#complete(...) or a variant otherwise mvcc will get stuck. Do it
in the finally of a try/finally block within which this appends lives and any subsequent
operations like sync or update of memstore, etc. Get the WriteEntry to pass mvcc out of the
passed in WALKey <code>walKey</code> parameter. Be warned that the WriteEntry is not
immediately available on return from this method. It WILL be available subsequent to a sync of
this append; otherwise, you will just have to wait on the WriteEntry to get filled in.
@param hri        the regioninfo associated with append
@param key        Modified by this call; we add to it this edits region edit/sequence id.
@param edits      Edits to append. MAY CONTAIN NO EDITS for case where we want to get an edit
                  sequence id that is after all currently appended edits.
@param inMemstore Always true except for case where we are writing a region event meta marker
                  edit, for example, a compaction completion record into the WAL or noting a
                  Region Open event. In these cases the entry is just so we can finish an
                  unfinished compaction after a crash when the new Server reads the WAL on
                  recovery, etc. These transition event 'Markers' do not go via the memstore.
                  When memstore is false, we presume a Marker event edit.
@return Returns a 'transaction id' and <code>key</code> will have the region edit/sequence id
        in it.
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.java