*            Control whether to copy the existing value for the first key
     *            into _spareValue before deleting the record.
     * @return <code>true</code> if any records were removed.
     * @throws PersistitException
     */
    private boolean removeKeyRangeInternal(Key key1, Key key2, boolean fetchFirst) throws PersistitException {
        Debug.$assert0.t(key1.getEncodedSize() > 0);
        Debug.$assert0.t(key2.getEncodedSize() > 0);
        Debug.$assert0.t(key1.compareTo(key2) < 0);

        assertCorrectThread(true);
        _persistit.checkClosed();

        if (_ignoreTransactions || !_transaction.isActive()) {
            return raw_removeKeyRangeInternal(key1, key2, fetchFirst, false);
        }

        // Record the delete operation on the journal

        _transaction.remove(this, key1, key2);

        checkLevelCache();

        _value.clear().putAntiValueMVV();
        final int storeOptions = StoreOptions.MVCC | StoreOptions.WAIT | StoreOptions.ONLY_IF_VISIBLE
                | StoreOptions.DONT_JOURNAL | (fetchFirst ? StoreOptions.FETCH : 0);

        boolean anyRemoved = false;
        boolean keyIsLessThan = true;
        Key nextKey = new Key(key1);

        while (keyIsLessThan && !key1.isRightEdge()) {
            Buffer buffer = null;
            try {
                int foundAt = search(key1, true);
                buffer = _levelCache[0]._buffer;

                while (!buffer.isAfterRightEdge(foundAt)) {
                    keyIsLessThan = key1.compareTo(key2) < 0;
                    if (!keyIsLessThan) {
                        break;
                    }
                    foundAt = buffer.nextKey(nextKey, foundAt);
                    buffer.releaseTouched();
                    buffer = null;
                    anyRemoved |= storeInternal(key1, _value, 0, storeOptions);
                    nextKey.copyTo(key1);
                    break;
                }
            } finally {
                if (buffer != null) {
                    buffer.releaseTouched();
                    buffer = null;
                }
            }
        }

        _value.clear();
        return anyRemoved;
    }