コード例 #1
0
  /**
   * Returns true if the LN at the given bin/index slot is permanently deleted. Returns false if it
   * is not deleted, or if it is deleted but part of an unclosed, resurrected txn.
   *
   * <p>Enter/leave with bin field latched.
   */
  private boolean isLNDeleted(BIN checkBin, int checkIndex) {

    if (!checkBin.isEntryKnownDeleted(checkIndex) && !checkBin.isEntryPendingDeleted(checkIndex)) {
      /* Not deleted. */
      return false;
    }

    final long lsn = checkBin.getLsn(checkIndex);
    if (lsn == DbLsn.NULL_LSN) {
      /* Can discard a NULL_LSN entry without locking. */
      return true;
    }

    /* Lock LSN to guarantee deletedness. */
    final BasicLocker lockingTxn = BasicLocker.createBasicLocker(envImpl);
    /* Don't allow this short-lived lock to be preempted/stolen. */
    lockingTxn.setPreemptable(false);
    try {
      final LockResult lockRet =
          lockingTxn.nonBlockingLock(
              lsn, LockType.READ, false /*jumpAheadOfWaiters*/, checkBin.getDatabase());
      if (lockRet.getLockGrant() == LockGrantType.DENIED) {
        /* Is locked by a resurrected txn. */
        return false;
      }
      return true;
    } finally {
      lockingTxn.operationEnd();
    }
  }