code: private void checkForGaps(Collection<EditLogInputStream> streams, long fromTxId,
        long toAtLeastTxId, boolean inProgressOk) throws IOException {
      Iterator<EditLogInputStream> iter = streams.iterator();
      long txId = fromTxId;
      while (true) {
        if (txId > toAtLeastTxId)
          return;
        if (!iter.hasNext())
          break;
        EditLogInputStream elis = iter.next();
        if (elis.getFirstTxId() > txId) {
          break;
        }
        long next = elis.getLastTxId();
        if (next == HdfsConstants.INVALID_TXID) {
          if (!inProgressOk) {
            throw new RuntimeException("inProgressOk = false, but "
                + "selectInputStreams returned an in-progress edit "
                + "log input stream (" + elis + ")");
          }
          // We don't know where the in-progress stream ends.
          // It could certainly go all the way up to toAtLeastTxId.
          return;
        }
        txId = next + 1;
      }
      throw new IOException(String.format("Gap in transactions. Expected to "
          + "be able to read up until at least txid %d but unable to find any "
          + "edit logs containing txid %d", toAtLeastTxId, txId));
    }
docs: Check for gaps in the edit log input stream list.
  Note: we're assuming that the list is sorted and that txid ranges don't
  overlap.  This could be done better and with more generality with an
  interval tree.