Oracle® Database Administrator's Guide 11g Release 2 (11.2) Part Number E10595-04 |
|
|
View PDF |
As the statements in a distributed transaction are issued, the database defines a session tree of all nodes participating in the transaction. A session tree is a hierarchical model that describes the relationships among sessions and their roles. Figure 33-2 illustrates a session tree:
All nodes participating in the session tree of a distributed transaction assume one or more of the following roles:
Role | Description |
---|---|
Client | A node that references information in a database belonging to a different node. |
Database server | A node that receives a request for information from another node. |
Global coordinator | The node that originates the distributed transaction. |
Local coordinator | A node that is forced to reference data on other nodes to complete its part of the transaction. |
Commit point site | The node that commits or rolls back the transaction as instructed by the global coordinator. |
The role a node plays in a distributed transaction is determined by:
Whether the transaction is local or remote
The commit point strength of the node ("Commit Point Site")
Whether all requested data is available at a node, or whether other nodes need to be referenced to complete the transaction
Whether the node is read-only
A node acts as a client when it references information from a database on another node. The referenced node is a database server. In Figure 33-2, the node sales
is a client of the nodes that host the warehouse
and finance
databases.
A database server is a node that hosts a database from which a client requests data.
In Figure 33-2, an application at the sales
node initiates a distributed transaction that accesses data from the warehouse
and finance
nodes. Therefore, sales.acme.com
has the role of client node, and warehouse
and finance
are both database servers. In this example, sales
is a database server and a client because the application also modifies data in the sales
database.
A node that must reference data on other nodes to complete its part in the distributed transaction is called a local coordinator. In Figure 33-2, sales
is a local coordinator because it coordinates the nodes it directly references: warehouse
and finance.
The node sales
also happens to be the global coordinator because it coordinates all the nodes involved in the transaction.
A local coordinator is responsible for coordinating the transaction among the nodes it communicates directly with by:
Receiving and relaying transaction status information to and from those nodes
Passing queries to those nodes
Receiving queries from those nodes and passing them on to other nodes
Returning the results of queries to the nodes that initiated them
The node where the distributed transaction originates is called the global coordinator. The database application issuing the distributed transaction is directly connected to the node acting as the global coordinator. For example, in Figure 33-2, the transaction issued at the node sales
references information from the database servers warehouse
and finance
. Therefore, sales.acme.com
is the global coordinator of this distributed transaction.
The global coordinator becomes the parent or root of the session tree. The global coordinator performs the following operations during a distributed transaction:
Sends all of the distributed transaction SQL statements, remote procedure calls, and so forth to the directly referenced nodes, thus forming the session tree
Instructs all directly referenced nodes other than the commit point site to prepare the transaction
Instructs the commit point site to initiate the global commit of the transaction if all nodes prepare successfully
Instructs all nodes to initiate a global rollback of the transaction if there is an abort response
The job of the commit point site is to initiate a commit or roll back operation as instructed by the global coordinator. The system administrator always designates one node to be the commit point site in the session tree by assigning all nodes a commit point strength. The node selected as commit point site should be the node that stores the most critical data.
Figure 33-3 illustrates an example of distributed system, with sales
serving as the commit point site:
The commit point site is distinct from all other nodes involved in a distributed transaction in these ways:
The commit point site never enters the prepared state. Consequently, if the commit point site stores the most critical data, this data never remains in-doubt, even if a failure occurs. In failure situations, failed nodes remain in a prepared state, holding necessary locks on data until in-doubt transactions are resolved.
The commit point site commits before the other nodes involved in the transaction. In effect, the outcome of a distributed transaction at the commit point site determines whether the transaction at all nodes is committed or rolled back: the other nodes follow the lead of the commit point site. The global coordinator ensures that all nodes complete the transaction in the same manner as the commit point site.
A distributed transaction is considered committed after all non-commit-point sites are prepared, and the transaction has been actually committed at the commit point site. The redo log at the commit point site is updated as soon as the distributed transaction is committed at this node.
Because the commit point log contains a record of the commit, the transaction is considered committed even though some participating nodes may still be only in the prepared state and the transaction not yet actually committed at these nodes. In the same way, a distributed transaction is considered not committed if the commit has not been logged at the commit point site.
Every database server must be assigned a commit point strength. If a database server is referenced in a distributed transaction, the value of its commit point strength determines which role it plays in the two-phase commit. Specifically, the commit point strength determines whether a given node is the commit point site in the distributed transaction and thus commits before all of the other nodes. This value is specified using the initialization parameter COMMIT_POINT_STRENGTH
. This section explains how the database determines the commit point site.
The commit point site, which is determined at the beginning of the prepare phase, is selected only from the nodes participating in the transaction. The following sequence of events occurs:
Of the nodes directly referenced by the global coordinator, the database selects the node with the highest commit point strength as the commit point site.
The initially-selected node determines if any of the nodes from which it has to obtain information for this transaction has a higher commit point strength.
Either the node with the highest commit point strength directly referenced in the transaction or one of its servers with a higher commit point strength becomes the commit point site.
After the final commit point site has been determined, the global coordinator sends prepare responses to all nodes participating in the transaction.
Figure 33-4 shows in a sample session tree the commit point strengths of each node (in parentheses) and shows the node chosen as the commit point site:
Figure 33-4 Commit Point Strengths and Determination of the Commit Point Site
The following conditions apply when determining the commit point site:
A read-only node cannot be the commit point site.
If multiple nodes directly referenced by the global coordinator have the same commit point strength, then the database designates one of these as the commit point site.
If a distributed transaction ends with a rollback, then the prepare and commit phases are not needed. Consequently, the database never determines a commit point site. Instead, the global coordinator sends a ROLLBACK
statement to all nodes and ends the processing of the distributed transaction.
As Figure 33-4 illustrates, the commit point site and the global coordinator can be different nodes of the session tree. The commit point strength of each node is communicated to the coordinators when the initial connections are made. The coordinators retain the commit point strengths of each node they are in direct communication with so that commit point sites can be efficiently selected during two-phase commits. Therefore, it is not necessary for the commit point strength to be exchanged between a coordinator and a node each time a commit occurs.
See Also:
"Specifying the Commit Point Strength of a Node" to learn how to set the commit point strength of a node
Oracle Database Reference for more information about the initialization parameter COMMIT_POINT_STRENGTH