@Override public boolean txnEnter(long txnId) throws IOException { LocalTransaction txn = txn(txnId); if (txn == null) { txn = new LocalTransaction(mDatabase, txnId, LockMode.UPGRADABLE_READ, 0L); mTransactions.insert(txnId).value = txn; } else { txn.enter(); } return true; }
@Override public final void durabilityMode(DurabilityMode mode) { if (mode == null) { throw new IllegalArgumentException("Durability mode is null"); } else { bogusCheck(); mDurabilityMode = mode; } }
private LocalTransaction newTransaction(long txnId) { LocalTransaction txn = new LocalTransaction (mDatabase, txnId, LockMode.UPGRADABLE_READ, INFINITE_TIMEOUT); txn.attach(ATTACHMENT); return txn; }
txn.lockTimeout(-1, null); txn.durabilityMode(mDurabilityMode.alwaysRedo()); txn.check(); commitPos = txn.mContext.redoDeleteIndexCommitFinal (txn.mRedo, txn.txnId(), treeId, txn.durabilityMode()); } finally { shared.release(); txn.commit(); } catch (Throwable e) { DatabaseException.rethrowIfRecoverable(e); throw closeOnFailure(this, e); } finally { txn.reset();
if (redo == null) { cursor.store(this, cursor.leafExclusive(), value); commit(); return; check(); try { if (txnId == 0) { txnId = assignTransactionId(redo); redo.txnCommitSync(this, commitPos); } else { commitPending(commitPos, null); return; redo.txnCommitSync(this, commitPos); } else { commitPending(commitPos, undo); return; try { if ((hasState & HAS_SCOPE) == 0) { setScopeState(redo, parentScope); if (value == null) { redo.txnDelete(RedoOps.OP_TXN_DELETE, txnId, indexId, key); borked(e, true, true);
check(); txnId = assignTransactionId(); ParentScope parentScope = mParentScope; if (parentScope != null) { setScopeState(parentScope); borked(e, false, true); // rollback = false, rethrow = true
/** * @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(); }
txn.lockExclusive(mTree.mId, key, keyHash()); mTxn = txn; doValueModify(mode, op, pos, buf, off, len); txn.commit(); } catch (Throwable e) { db.removeThreadLocalTransaction(); txn.reset(); throw e; } finally { if (txn.lockMode() != LockMode.UNSAFE) { txn.lockExclusive(mTree.mId, key, keyHash()); undoTxn = txn; if (mode <= 1 && txn.durabilityMode() != DurabilityMode.NO_REDO) { txn.redoCursorValueModify(this, op, pos, buf, off, len);
@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); } }
store(LocalTransaction.BOGUS, leafExclusive(), value); } else { if (txn.lockMode() != LockMode.UNSAFE) { txn.lockExclusive(mTree.mId, key, keyHash()); 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); txn.commit();
throw new IllegalStateException("Custom transaction handler is not installed"); check(); if (mRedo != null) { long txnId = mTxnId; final CommitLock.Shared shared = mDatabase.commitLock().acquireShared(); try { txnId = assignTransactionId(); } finally { shared.release(); ParentScope parentScope = mParentScope; if (parentScope != null) { setScopeState(parentScope); LockResult result = lockCheck(indexId, key); if (result != LockResult.OWNED_EXCLUSIVE) { throw new IllegalStateException("Lock isn't owned exclusively: " + result);
return; check(borked); mRedo.txnCommitSync(this, commitPos); } else { commitPending(commitPos, null); return; mRedo.txnCommitSync(this, commitPos); } else { commitPending(commitPos, undo); return; borked(e, true, true); // rollback = true, rethrow = true
@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); } }
LocalTransaction txn = new LocalTransaction (mDatabase, mTxnId, lockMode, timeoutNanos, txn.recoveredScope(scope.mSavepoint, LocalTransaction.HAS_TRASH); if (acquireLocks) { scope.acquireLocks(txn);
/** * To be called during redo recovery. */ final void prepareNoRedo() throws IOException { check(); try { if ((mHasState & HAS_PREPARE) == 0) { pushUndoPrepare(); mHasState |= HAS_PREPARE; } } catch (Throwable e) { borked(e, true, true); // rollback = true, rethrow = true } }
} else if (txn.durabilityMode() == DurabilityMode.NO_REDO) { byte[] key = mKey; ViewUtils.positionCheck(key); store(value); } catch (Throwable e) { txn.reset(e); throw e; txn.commit();
throw new IllegalStateException("Custom transaction handler is not installed"); check(); RedoWriter redo = mRedoWriter; if (redo != null) { final CommitLock.Shared shared = mDatabase.commitLock().acquireShared(); try { txnId = assignTransactionId(redo); } finally { shared.release(); ParentScope parentScope = mParentScope; if (parentScope != null) { setScopeState(redo, parentScope);