void acquireLocks(LocalTransaction txn) throws LockFailureException { Lock lock = mTopLock; if (lock != null) while (true) { // Copy next before the field is overwritten. Lock next = lock.mLockManagerNext; txn.lockExclusive(lock); if (next == null) { break; } mTopLock = lock = next; } } }
void acquireLocks(LocalTransaction txn) throws LockFailureException { Lock lock = mTopLock; if (lock != null) while (true) { // Copy next before the field is overwritten. Lock next = lock.mLockManagerNext; txn.lockExclusive(lock); if (next == null) { break; } mTopLock = lock = next; } } }
void acquireLocks(LocalTransaction txn) throws LockFailureException { Lock lock = mTopLock; if (lock != null) while (true) { // Copy next before the field is overwritten. Lock next = lock.mLockManagerNext; txn.lockExclusive(lock); if (next == null) { break; } mTopLock = lock = next; } } }
@Override public final LockResult lockExclusive(Transaction txn, byte[] key) throws LockFailureException { return check(txn).lockExclusive(mId, key); }
@Override public final LockResult lockExclusive(Transaction txn, byte[] key) throws LockFailureException { return check(txn).lockExclusive(mId, key); }
@Override public final LockResult lockExclusive(Transaction txn, byte[] key) throws LockFailureException { return check(txn).lockExclusive(mId, key); }
/** * @param txn non-null */ final void doCommit(LocalTransaction txn, byte[] key, byte[] value) throws IOException { if (txn.lockMode() != LockMode.UNSAFE) { txn.lockExclusive(mTree.mId, key, keyHash()); if (txn.mDurabilityMode != DurabilityMode.NO_REDO) { txn.storeCommit(this, value); return; } } store(txn, leafExclusive(), value); txn.commit(); }
/** * @param requireUndo true if undo logging is required (when key has been locked) * @param txn non-null */ final void doCommit(boolean requireUndo, LocalTransaction txn, byte[] key, byte[] value) throws IOException { if (txn.lockMode() != LockMode.UNSAFE) { txn.lockExclusive(mTree.mId, key, keyHash()); if (txn.mDurabilityMode != DurabilityMode.NO_REDO) { txn.storeCommit(requireUndo, this, value); return; } } store(txn, leafExclusive(), value); txn.commit(); }
if (mode <= 1) storeRedo: { if (txn.lockMode() != LockMode.UNSAFE) { txn.lockExclusive(mTree.mId, key, keyHash()); if (txn.mDurabilityMode == DurabilityMode.NO_REDO) { break storeRedo; } else { if (txn.lockMode() != LockMode.UNSAFE) { txn.lockExclusive(mTree.mId, key, keyHash());
@Override public final void store(byte[] value) throws IOException { byte[] key = mKey; ViewUtils.positionCheck(key); try { LocalTransaction txn = mTxn; if (txn == null) { txn = mTree.mDatabase.newAlwaysRedoTransaction(); try { if (txn.lockMode() != LockMode.UNSAFE) { txn.lockExclusive(mTree.mId, key, keyHash()); } store(txn, leafExclusive(), value); txn.commit(); } catch (Throwable e) { txn.reset(); throw e; } } else { if (txn.lockMode() != LockMode.UNSAFE) { txn.lockExclusive(mTree.mId, key, keyHash()); } store(txn, leafExclusive(), value); } } catch (Throwable e) { throw handleException(e, false); } }
@Override public final void store(byte[] value) throws IOException { final LocalTransaction txn = mTxn; if (txn == null) { storeAutoCommit(value); } else { byte[] key = mKey; ViewUtils.positionCheck(key); try { if (txn.lockMode() != LockMode.UNSAFE) { txn.lockExclusive(mTree.mId, key, keyHash()); } if (storeMode() <= 1) { storeAndRedo(txn, value); } else { storeNoRedo(txn, value); } } catch (Throwable e) { throw handleException(e, false); } } }
@Override public final void store(byte[] value) throws IOException { byte[] key = mKey; ViewUtils.positionCheck(key); try { LocalTransaction txn = mTxn; if (txn == null) { txn = mTree.mDatabase.newAlwaysRedoTransaction(); try { doCommit(true, txn, key, value); } catch (Throwable e) { txn.reset(); throw e; } } else { if (txn.lockMode() != LockMode.UNSAFE) { txn.lockExclusive(mTree.mId, key, keyHash()); } store(txn, leafExclusive(), value); } } catch (Throwable e) { throw handleException(e, false); } }
final int hash = LockManager.hash(mTree.mId, key); mKeyHash = hash; txn.lockExclusive(mTree.mId, key, hash);
@Override public boolean txnCustomLock(long txnId, byte[] message, long indexId, byte[] key) throws IOException { TransactionHandler handler = mDatabase.mCustomTxnHandler; if (handler == null) { throw new DatabaseException("Custom transaction handler is not installed"); } TxnEntry te = getTxnEntry(txnId); // Allow side-effect free operations to be performed before acquiring latch. mOpLatch.acquireShared(); Latch latch = te.latch(); try { LocalTransaction txn = te.mTxn; // Locks must be acquired in their original order to avoid // deadlock, so don't allow another task thread to run yet. txn.lockUpgradable(indexId, key, INFINITE_TIMEOUT); // Allow another task thread to run while operation completes. nextTask(); // Wait to acquire exclusive now that another thread is running. txn.lockExclusive(indexId, key, INFINITE_TIMEOUT); handler.redo(mDatabase, txn, message, indexId, key); } finally { latch.releaseExclusive(); } // Only release if no exception. mOpLatch.releaseShared(); // Return false to prevent RedoDecoder from looping back. return false; }
@Override public void store(byte[] value) throws IOException { byte[] key = mKey; ViewUtils.positionCheck(key); try { final LocalTransaction txn = mTxn; if (txn == null) { final Locker locker = mTree.lockExclusiveLocal(key, keyHash()); try { store(txn, leafExclusive(), value); } finally { locker.unlock(); } } else { if (txn.lockMode() != LockMode.UNSAFE) { txn.lockExclusive(mTree.mId, key, keyHash()); } store(txn, leafExclusive(), value); } } catch (Throwable e) { throw handleException(e, false); } }
@Override public void store(byte[] value) throws IOException { byte[] key = mKey; ViewUtils.positionCheck(key); try { final LocalTransaction txn = mTxn; if (txn == null) { final Locker locker = mTree.lockExclusiveLocal(key, keyHash()); try { store(txn, leafExclusive(), value); } finally { locker.unlock(); } } else { if (txn.lockMode() != LockMode.UNSAFE) { txn.lockExclusive(mTree.mId, key, keyHash()); } store(txn, leafExclusive(), value); } } catch (Throwable e) { throw handleException(e, false); } }
@Override public final void store(byte[] value) throws IOException { byte[] key = mKey; ViewUtils.positionCheck(key); try { final LocalTransaction txn = mTxn; if (txn == null) { store(LocalTransaction.BOGUS, leafExclusive(), value); } else { if (txn.lockMode() != LockMode.UNSAFE) { txn.lockExclusive(mTree.mId, key, keyHash()); } CursorFrame leaf = leafExclusive(); final DurabilityMode dmode = txn.durabilityMode(); if (dmode == DurabilityMode.NO_REDO) { store(txn, leaf, value); } else { txn.durabilityMode(DurabilityMode.NO_REDO); try { store(txn, leaf, value); } finally { txn.durabilityMode(dmode); } } } } catch (Throwable e) { throw handleException(e, false); } }
@Override public final void store(byte[] value) throws IOException { byte[] key = mKey; ViewUtils.positionCheck(key); try { final LocalTransaction txn = mTxn; if (txn == null) { store(LocalTransaction.BOGUS, leafExclusive(), value); } else { if (txn.lockMode() != LockMode.UNSAFE) { txn.lockExclusive(mTree.mId, key, keyHash()); } CursorFrame leaf = leafExclusive(); final DurabilityMode dmode = txn.durabilityMode(); if (dmode == DurabilityMode.NO_REDO) { store(txn, leaf, value); } else { txn.durabilityMode(DurabilityMode.NO_REDO); try { store(txn, leaf, value); } finally { txn.durabilityMode(dmode); } } } } catch (Throwable e) { throw handleException(e, false); } }
} else { if (txn.lockMode() != LockMode.UNSAFE) { txn.lockExclusive(mTree.mId, key, keyHash());
} else { if (txn.lockMode() != LockMode.UNSAFE) { txn.lockExclusive(mTree.mId, key, keyHash());