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.
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)
Methods that are only called during recovery don't need to take MT considerations, and can safely use iterators with no additional synchronization.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static interface | TransactionTable.
Interface for visiting entries in the transaction table. |
| Modifier and Type | Field and Description |
|---|---|
| private TransactionId | |
| private final ConcurrentHashMap |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| public void | addUpdateTransaction(TransactionId
the transaction id tid, RawTransaction the transaction to be added tran, int the transaction status that is stored in the
BeginXact log record transactionStatus)Change a transaction to update or add an update transaction to this table. |
| pack-priv boolean | Returns: true if transaction can be found, false otherwisetransaction Id id, RawTransaction the transaction that was made to assume the transactionID
and all other relevant information stored in the transaction table tran)Find a transaction using the transaction id, and make the passed in transaction assume the identity and properties of that transaction. |
| public ContextManager | Returns: The ContextManager of the transaction being searched for.The global transaction we are searching for. global_id)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. |
| private TransactionTableEntry | findTransactionEntry(TransactionId id)
generic methods called by all clients of transaction table Must be MT -safe |
| public LogInstant | Returns: the RawTransaction's first log instantMT - safe, caller can be recovery or checkpoint Get the least recently added (oldest) transaction |
| public boolean | Returns: true if a candidate transaction has been found. false if no prepared/recovery transactions found in the table.Newly allocated transaction to add to link to a entry. tran)Get the most recent recovered prepared transaction. |
| public boolean | getMostRecentRollbackFirstTransaction(RawTransaction tran)
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. |
| public boolean | getMostRecentTransactionForRollback(RawTransaction tran)
Get the most recently non-prepared added transaction from the transaction table and make the passed in transaction assume its identity. |
| public TransactionInfo[] | |
| public int | getTypeFormatId()
Implements org. Return my format identifier. |
| pack-priv boolean | |
| public boolean | hasPreparedRecoveredXact()
Is there a prepared transaction that are recovered durring the recovery in the transaction table. |
| public boolean | |
| private boolean | Returns: true if there is a prepared transaction and
recovered when true to search for transaction
that are in prepared during recovery.
recovered tranaction.
false > to search for just prepared
transactons.Is there a prepared transaction in the transaction table. |
| public boolean | |
| public TransactionId | |
| pack-priv void | |
| public void | readExternal(ObjectInput
the stream to read data from in order to restore the object in)Implements java. The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. |
| pack-priv boolean | remove(TransactionId id)
remove the transaction Id an return false iff the transaction is found in the table and it doesn't need exclusion during quiesce state |
| pack-priv void | removeUpdateTransaction(TransactionId
the transaction Id id)Change update transaction to non-update MT - MT safe, since vector is MT-safe. |
| public String | |
| pack-priv void | visitEntries(TransactionTable.
the visitor to apply on each transaction table entry visitorVisit all the entries in the transaction table. |
| public void | writeExternal(final ObjectOutput
the stream to write the object to out)Implements java. The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays. |
| largestUpdateXactId | back to summary |
|---|---|
| private TransactionId largestUpdateXactId | |
| trans | back to summary |
|---|---|
| private final ConcurrentHashMap<TransactionId, TransactionTableEntry> trans | |
| TransactionTable | back to summary |
|---|---|
| public TransactionTable() MT - not needed for constructor | |
| add | back to summary |
|---|---|
| pack-priv void add(Xact xact, boolean exclude) | |
| addUpdateTransaction | back to summary |
|---|---|
| public void addUpdateTransaction(TransactionId tid, RawTransaction tran, int transactionStatus) Change a transaction to update or add an update transaction to this table.
| |
| findAndAssumeTransaction | back to summary |
|---|---|
| pack-priv boolean findAndAssumeTransaction(TransactionId id, RawTransaction tran) 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.
| |
| findTransactionContextByGlobalId | back to summary |
|---|---|
| public ContextManager findTransactionContextByGlobalId(final GlobalXactId global_id) 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.
| |
| findTransactionEntry | back to summary |
|---|---|
| private TransactionTableEntry findTransactionEntry(TransactionId id) generic methods called by all clients of transaction table Must be MT -safe | |
| getFirstLogInstant | back to summary |
|---|---|
| public LogInstant getFirstLogInstant() Get the least recently added (oldest) transaction
| |
| getMostRecentPreparedRecoveredXact | back to summary |
|---|---|
| public boolean getMostRecentPreparedRecoveredXact(RawTransaction tran) 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.
| |
| getMostRecentRollbackFirstTransaction | back to summary |
|---|---|
| public boolean getMostRecentRollbackFirstTransaction(RawTransaction tran) 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 | back to summary |
|---|---|
| public boolean getMostRecentTransactionForRollback(RawTransaction tran) 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. | |
| getTransactionInfo | back to summary |
|---|---|
| public TransactionInfo[] getTransactionInfo() Get a printable version of the transaction table | |
| getTypeFormatId | back to summary |
|---|---|
| public int getTypeFormatId() Implements org. Return my format identifier.
| |
| hasActiveUpdateTransaction | back to summary |
|---|---|
| pack-priv boolean hasActiveUpdateTransaction() 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 | back to summary |
|---|---|
| public boolean hasPreparedRecoveredXact() 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 | back to summary |
|---|---|
| public boolean hasPreparedXact() Is there a prepared transaction in the transaction table. MT - unsafe, called during boot, which is single threaded. | |
| hasPreparedXact | back to summary |
|---|---|
| private boolean hasPreparedXact(boolean recovered) Is there a prepared transaction in the transaction table. MT - unsafe, caller is recovery/at boot, which is single threaded.
| |
| hasRollbackFirstTransaction | back to summary |
|---|---|
| public boolean hasRollbackFirstTransaction() Is there an active internal transaction in the transaction table. MT - unsafe, caller is recovery, which is single threaded. | |
| largestUpdateXactId | back to summary |
|---|---|
| public TransactionId largestUpdateXactId() Return the largest update transactionId I have seen so far. MT - unsafe, caller is recovery, which is single threaded. | |
| prepareTransaction | back to summary |
|---|---|
| pack-priv void prepareTransaction(TransactionId id) Change transaction to prepared. MT - unsafe, caller is recovery, which is single threaded.
| |
| readExternal | back to summary |
|---|---|
| public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException Implements java. Doc from java. The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.
| |
| remove | back to summary |
|---|---|
| pack-priv boolean remove(TransactionId id) remove the transaction Id an return false iff the transaction is found in the table and it doesn't need exclusion during quiesce state | |
| removeUpdateTransaction | back to summary |
|---|---|
| pack-priv void removeUpdateTransaction(TransactionId id) Change update transaction to non-update MT - MT safe, since vector is MT-safe.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |
| visitEntries | back to summary |
|---|---|
| pack-priv void visitEntries(TransactionTable. Visit all the entries in the transaction table. MT - MT safe
Entries that are added to or removed from the transaction table while
it's being traversed, may or may not be visited. All the entries that
are present in the map when this method is called, and have not been
removed when the method returns, will have been visited exactly once
(except if the
Note however that this method does not guarantee that a single
| |
| writeExternal | back to summary |
|---|---|
| public void writeExternal(final ObjectOutput out) throws IOException Implements java. Doc from java. The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
| |
visitEntries(EntryVisitor)
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the scan of the transaction table should
continue, or false if the visitor has completed its work
and no more entries need to be visitedthe entry)TransactionTableEntry being visitedVisit an entry. |
| visit | back to summary |
|---|---|
| public boolean visit(TransactionTableEntry entry) Visit an entry.
| |