| java.lang.Object org.apache.derby.impl.store.raw.xact.TransactionTable
TransactionTable | public class TransactionTable implements Formatable(Code) | | The transaction table is used by the transaction factory to keep track of
all transactions that are in the system.
The transction table serves the following purposes:
- checkpoint - when a checkpoint log record is written out, it writes
out also all transactions that have updated the database. RESOLVE: this is
actually not used right now - rather, the transaction table is
reconstructed during the redo phase by traversing from the undo LWM. It is
a goal to use this transaction table (and traversing from the redoLWM)
instead of rebuilding it to speed up recovery.
- Quiesce State - when a system enters the quiesce state, it needs to account
for all transactions in the system, even those which are just started and
are in their IDLE state.
- TransactionTable VTI - we need to get a snapshot of all transactions
in the system for diagnostic purposes.
In order to speed up the time it takes to look up a transaction from the
transaction table, each transaction must have a unique transaction Id.
This means newly coined transaction must also have a transaction Id.
During recovery, there is only one real xact object doing all the
recovery work, but there could be many outstanding transactions that are
gleamed from the log. Each of these "recovery transactions" have its on
entry into the transaction table but they all share the same Xact object.
Multithreading considerations:
TransactionTable must be MT-safe it is called upon by many threads
simultaneously (except during recovery)
This class depends on Hashtable synchronization!!
|
TransactionTable | public TransactionTable()(Code) | | MT - not needed for constructor
|
addUpdateTransaction | public void addUpdateTransaction(TransactionId tid, RawTransaction tran, int transactionStatus)(Code) | | Change a transaction to update or add an update transaction to this table.
Parameters: tid - the transaction id Parameters: tran - the transaction to be added Parameters: transactionStatus - the transaction status that is stored in theBeginXact log record |
findAndAssumeTransaction | boolean findAndAssumeTransaction(TransactionId id, RawTransaction tran)(Code) | | Find a transaction using the transaction id, and make the passed in
transaction assume the identity and properties of that transaction.
MT - unsafe, caller is recovery, which is single threaded.
Parameters: id - transaction Id Parameters: tran - the transaction that was made to assume the transactionIDand all other relavent information stored in the transaction table true if transaction can be found, false otherwise |
findTransactionContextByGlobalId | public ContextManager findTransactionContextByGlobalId(GlobalXactId global_id)(Code) | | Find a transaction in the table by Global transaction id.
This routine use to be only called during offline recovery so performance
was not critical. Since that time more calls have been made, including
one in startGlobalTransaction() so a linear search may no longer
be appropriate. See DERBY-828.
The ContextManager of the transaction being searched for. Parameters: global_id - The global transaction we are searching for. |
getFirstLogInstant | public LogInstant getFirstLogInstant()(Code) | | Get the least recently added (oldest) transaction
the RawTransaction's first log instant MT - safe, caller can be recovery or checkpoint |
getMostRecentPreparedRecoveredXact | public boolean getMostRecentPreparedRecoveredXact(RawTransaction tran)(Code) | | Get the most recent recovered prepared transaction.
Get the most recently added transaction that says it is prepared during
recovery the transaction table and make the passed in transaction
assume its identity.
This routine, unlike the redo and rollback getMostRecent*() routines
expects a brand new transaction to be passed in. If a candidate
transaction is found, then upon return the transaction table will
be altered such that the old entry no longer exists, and a new entry
will exist pointing to the transaction passed in. The new entry will
look the same as if the prepared transaction had been created during
runtime rather than recovery.
Should only be used in recovery handle prepare after undo !!
MT - unsafe, caller is recovery, which is single threaded.
true if a candidate transaction has been found. false if noprepared/recovery transactions found in the table. Parameters: tran - Newly allocated transaction to add to link to a entry. |
getMostRecentRollbackFirstTransaction | public boolean getMostRecentRollbackFirstTransaction(RawTransaction tran)(Code) | | Get the most recently added transaction that says it needs to be
rolled back first (an InternalXact) from the transaction table and make
the passed in transaction assume its identity.
Should only be used in recovery undo !!
RESOLVE: (sku)I don't think even these internal transactions need to be
rolled back in the reverse order, because they are physical in nature.
But it won't hurt.
MT - unsafe, caller is recovery, which is single threaded.
|
getMostRecentTransactionForRollback | public boolean getMostRecentTransactionForRollback(RawTransaction tran)(Code) | | Get the most recently non-prepared added transaction from the
transaction table and make the passed in transaction assume its
identity. Prepared transactions will not be undone.
RESOLVE: (sku) I don't think normal user transactions needs to be
rolled back in order, but it won't hurt.
Should only be used in recovery undo !!
MT - unsafe, caller is recovery, which is single threaded.
|
getTableForXA | public Hashtable getTableForXA()(Code) | | Return the hash table to the XA layer.
The XA code will do linear read-only operations on the hash table,
write operations are only done in this module. It is a little ugly
to export the hash table, but I wanted to move the XA specific code
into the XA module, so that we could configure out the XA code if
necessary.
Must be MT -safe, depends on sync hash table, and must get
synchronized(hash_table) for linear searches.
The ContextManager of the transaction being searched for. |
getTransactionInfo | public TransactionInfo[] getTransactionInfo()(Code) | | Get a printable version of the transaction table
|
getTypeFormatId | public int getTypeFormatId()(Code) | | Return my format identifier.
|
hasActiveUpdateTransaction | boolean hasActiveUpdateTransaction()(Code) | | Return true if there is no transaction actively updating the database.
New transaction may be started or old transaction committed
right afterward, the caller of this routine must have other ways to
stop transactions from starting or ending.
MT - safe
|
hasPreparedRecoveredXact | public boolean hasPreparedRecoveredXact()(Code) | | Is there a prepared transaction that are recovered
durring the recovery in the transaction table.
MT - unsafe, caller is recovery, which is single threaded.
|
hasPreparedXact | public boolean hasPreparedXact()(Code) | | Is there a prepared transaction in the transaction table.
MT - unsafe, called during boot, which is single threaded.
|
hasRollbackFirstTransaction | public boolean hasRollbackFirstTransaction()(Code) | | Is there an active internal transaction in the transaction table.
MT - unsafe, caller is recovery, which is single threaded.
|
largestUpdateXactId | public TransactionId largestUpdateXactId()(Code) | | Return the largest update transactionId I have seen so far.
MT - unsafe, caller is recovery, which is single threaded.
|
prepareTransaction | void prepareTransaction(TransactionId id)(Code) | | Change transaction to prepared.
MT - unsafe, caller is recovery, which is single threaded.
Parameters: id - the transaction Id |
removeUpdateTransaction | void removeUpdateTransaction(TransactionId id)(Code) | | Change update transaction to non-update
MT - MT safe, since vector is MT-safe.
Parameters: id - the transaction Id |
|
|