private class BufferManager.DBTxWrapper extends java.lang.Object implements Finalizable, Commitable
TransactionManager
to receive commit/rollback and
finished/iterate/retry notifications.
Note that our architecture differs somewhat from Progress here in that if we have an error at commit time, it is too late to undo in the current block scope. All attempts are made before commit is executed to vet and prevent any errors, but it is still possible to have an error at this level if say, two transactions in different contexts attempt to commit conflicting data. In this case, the error would be handled in the next block scope up from the current one.
Auto-commit buffers require special handling during a database-level rollback. Changes to such buffers made during a database transaction must be preserved, but a database-level transaction rollback will not discriminate these changes from those made to other buffers. Therefor, we must reverse the rollback (re-roll forward?) for any auto-commit buffers whose changes are rolled back with the transaction. This is done by beginning a new transaction just for these changes, immediately after a database-level rollback. Within that transaction, changes made to an auto-commit buffer are rolled forward once again and the transaction is then committed.
Modifier and Type | Class and Description |
---|---|
private class |
BufferManager.DBTxWrapper.ReversibleIterator
Class used to iterate through all the reversible data, by buffer.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
autoRollback
Do we need to rollback database transaction in finished()?
|
private DirtyShareContext |
dirtyContext
Dirty share context
|
private Persistence |
persistence
Persistence service object
|
Constructor and Description |
---|
DBTxWrapper(Persistence persistence,
DirtyShareContext dirtyContext)
Constructor which accepts a
Persistence instance and the set
of currently open buffers for that database, registers with the
TransactionManager as a Finalizable and a
Commitable , and begins a new database-level
transaction. |
Modifier and Type | Method and Description |
---|---|
private void |
begin()
Begin a new database-level transaction.
|
void |
commit(boolean transaction)
Called by the
TransactionManager when the full
transaction must be committed. |
void |
deleted()
This implementation does nothing.
|
private void |
end()
Perform transaction post-processing to release or downgrade record
locks which may have been acquired during the transaction, to clean
up dirty index update sharing information contributed to the dirty
share manager by the current context for the transaction which is now
ending, and to clean up any other resources associated with the
transaction.
|
private void |
executeReversibleRollbacks()
Reverse temp table changes which were rolled back at the database, in
order to support the Progress temp-table NO-UNDO semantic.
|
void |
finished()
Called by the
TransactionManager after commit or
rollback to clean up. |
void |
iterate()
Called by the
TransactionManager from the top of the
block (just after the loop test) on the second and subsequent
iterations of an iterating loop. |
private void |
prepareReversibleRollbacks()
Prepare temp table reversible rollbacks for execution.
|
void |
retry()
Processes the retry notification provided by the
TransactionManager . |
void |
rollback(boolean transaction)
Called by the
TransactionManager when the full
transaction must be rolled back. |
void |
rollbackPending()
No-op
|
void |
validate(boolean transaction)
No-op
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initFailure
private final Persistence persistence
private final DirtyShareContext dirtyContext
private boolean autoRollback
DBTxWrapper(Persistence persistence, DirtyShareContext dirtyContext)
Persistence
instance and the set
of currently open buffers for that database, registers with the
TransactionManager
as a Finalizable
and a
Commitable
, and begins a new database-level
transaction.persistence
- Persistence object which will be used for transaction
support.dirtyContext
- Dirty share context which must be cleaned up at the end of
this transaction.java.lang.IllegalStateException
- if a transaction is already active in the current session;
this represents a programming error.public void finished()
TransactionManager
after commit or
rollback to clean up. This closes the current Hibernate session
and removes this database name from the buffer manager's set of
databases currently involved in transactions.
In the event the transaction manager did not explicitly commit or
rollback (e.g., blockSetup()
was never called, perhaps
due to conditional processing which evaluated to false), we
automatically rollback at this point.
finished
in interface Finalizable
public void deleted()
deleted
in interface Finalizable
public void iterate()
TransactionManager
from the top of the
block (just after the loop test) on the second and subsequent
iterations of an iterating loop.
We create a new, database-level transaction here, after the loop test has been passed.
iterate
in interface Finalizable
java.lang.IllegalStateException
- if a transaction is already active in the current session;
this represents a programming error.public void retry()
TransactionManager
. This occurs just after we've
rolled back and we are about to jump to the top of the loop. We
will not get a call to iterate()
, because this is not a
normal iteration; instead, we are retrying the same pass through
the block and need to set up a transaction as if we were coming in
fresh.retry
in interface Finalizable
java.lang.IllegalStateException
- if a transaction is already active in the current session;
this represents a programming error.public void commit(boolean transaction)
TransactionManager
when the full
transaction must be committed. This is our hook to commit the
database-level transaction.commit
in interface Commitable
transaction
- true
if this is a full transaction. Not used,
since we only register for full transaction commits.public void rollbackPending()
rollbackPending
in interface Commitable
public void validate(boolean transaction)
validate
in interface Commitable
transaction
- Not used.public void rollback(boolean transaction)
TransactionManager
when the full
transaction must be rolled back. This is our hook to roll back the
database-level transaction.rollback
in interface Commitable
transaction
- true
if this is a full transaction. Not used,
since we only register for full transaction commits.private void begin()
java.lang.IllegalStateException
- if a transaction is already active in the current session;
this represents a programming error.private void end()
private void prepareReversibleRollbacks()
private void executeReversibleRollbacks()