Collaboration diagram for Distributed Transactions: Two-Phase Commit:
![]() |
For the purpose of this discussion, the portion of a global transaction that involves a single Shore Storage Manager transaction is called a thread of the global transaction.
A Shore transaction participates as a thread of a global transaction as follows:
The storage manager logs the minimal information required to effect a vote of the transaction threads that are storage manager transactions, and to recover such in-doubt transactions after restart. Thus, after a crash/restart, the server may query the storage manager about in-doubt (prepared) transactions with ss_m::query_prepared_xct, which tells the caller the number and global transaction IDs associated with prepared transactions. Using this, the server contacts the coordinator and resumes the voting. The server may find the local transaction IDs and use ss_m::tid_to_xct to attach these transactions and to resolve them.
Commit and abort of read-only transactions are the same, as these transactions have no log entries. Preparing read-only transactions causes them to commit/abort and the vote returned is vote_readonly. Once this vote is communicated to the coordinator and the coordinator records it on stable storage, there is no need to involve this thread in any further processing. For this reason, read-only transactions do not appear as prepared transactions at recovery time.
Functions | |
static rc_t | ss_m::enter_2pc (const gtid_t >id) |
Make the attached transaction a thread of a distributed transaction. | |
static rc_t | ss_m::set_coordinator (const server_handle_t &h) |
Assign a coordinator handle to this distributed transaction. | |
static rc_t | ss_m::prepare_xct (sm_stats_info_t *&stats, vote_t &vote) |
Prepare a thread of a distributed transaction. | |
static rc_t | ss_m::prepare_xct (vote_t &vote) |
Prepare a thread of a distributed transaction. | |
static rc_t | ss_m::force_vote_readonly () |
Force the transaction to vote "read-only" in a two-phase commit. | |
static rc_t | ss_m::recover_2pc (const gtid_t >id, bool mayblock, tid_t &local) |
Given a global transaction id, find the local prepared transaction associated with it. | |
static rc_t | ss_m::query_prepared_xct (int &numtids) |
Return the number of prepared transactions. | |
static rc_t | ss_m::query_prepared_xct (int numtids, gtid_t l[]) |
Return the global transaction IDs of in-doubt transactions. |
Make the attached transaction a thread of a distributed transaction.
[in] | gtid | Global transaction ID to associate with this transaction. This will be logged when the transaction is prepared. |
static rc_t ss_m::set_coordinator | ( | const server_handle_t & | h | ) | [static, inherited] |
Assign a coordinator handle to this distributed transaction.
[in] | h | Handle of the coordinator. Not interpreted by the storage manager. |
static rc_t ss_m::prepare_xct | ( | sm_stats_info_t *& | stats, | |
vote_t & | vote | |||
) | [static, inherited] |
Prepare a thread of a distributed transaction.
[in] | stats | Pointer to an allocated statistics-holding structure. |
[out] | vote | This thread's vote. |
If the transaction is being instrumented, the statistics-holding structure will be returned to the caller, and the caller is responsible for its deallocation.
static rc_t ss_m::prepare_xct | ( | vote_t & | vote | ) | [static, inherited] |
Prepare a thread of a distributed transaction.
[out] | vote | This thread's vote. See w_base_t::vote_t. |
static rc_t ss_m::force_vote_readonly | ( | ) | [static, inherited] |
Force the transaction to vote "read-only" in a two-phase commit.
This will override the storage manager's determination of whether this thread of a distributed transaction is read-only, which is based on whether the local transaction thread logged anything. This method may be useful if the local transaction rolled back to a savepoint. See w_base_t::vote_t.
static rc_t ss_m::recover_2pc | ( | const gtid_t & | gtid, | |
bool | mayblock, | |||
tid_t & | local | |||
) | [static, inherited] |
Given a global transaction id, find the local prepared transaction associated with it.
[in] | gtid | A global transaction ID (an opaque quantity to the storage manager). |
[in] | mayblock | Not used. |
[out] | local | Return the transaction ID of the prepared SM transaction. |
static rc_t ss_m::query_prepared_xct | ( | int & | numtids | ) | [static, inherited] |
Return the number of prepared transactions.
[out] | numtids | The number of in-doubt transactions. |
Return the global transaction IDs of in-doubt transactions.
[in] | numtids | The number of global transaction ids in the list. |
[in] | l | The caller-provided list into which to write the global transaction-ids. |