A portion of the disclosure of this patent document contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure, as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever.
The present invention is generally related to computer systems and software such as middleware, and is particularly related to transactional middleware.
A transactional middleware system, or transaction oriented middleware, includes enterprise application servers that can process various transactions within an organization. With the developments in new technologies such as high performance network and multiprocessor computers, there is a need to further improve the performance of transactional middleware. These are generally areas that embodiments of the invention are intended to address.
Systems and methods are provided for supporting processing a transaction with a plurality of transaction branches. A transaction manager operates to send, to a resource manager, a prepare request for each said transaction branch in the plurality of transaction branches with the exception of at least one transaction branch. Furthermore, after receiving an indication from the resource manager that the received preparation requests are handled successfully (i.e. the transaction branch is read-only and has been committed), the transaction manager operates to send a commit request to commit said at least one transaction branch to the resource manager.
Other objects and advantages of the present invention will become apparent to those skilled in the art from the following detailed description of the various embodiments, when read in light of the accompanying drawings.
The invention is illustrated, by way of example and not by way of limitation, in the figures of the accompanying drawings in which like references indicate similar elements. It should be noted that references to “an” or “one” or “some” embodiment(s) in this disclosure are not necessarily to the same embodiment, and such references mean at least one.
The description of the invention as following uses the OracleTuxedo® environment as an example for a transactional middleware machine environment. It will be apparent to those skilled in the art that other types of transactional middleware machine environments can be used without limitation.
Described herein are systems and methods that can support read-only optimization in a transactional middleware environment.
In accordance with various embodiments of the invention, a transactional system can support a global transaction, which can be executed on more than one server, and is capable of accessing data from more than one resource manager.
A global transaction can be treated as a specific sequence of operations that are characterized by the four properties of atomicity, consistency, isolation, and durability (ACID). The global transaction can be a logical unit of work that has the following features:
Furthermore, a global transaction may include several local transactions, each accessing a single resource manager. A local transaction can access a single database or file and can be controlled by the resource manager responsible for performing concurrency control and atomicity of updates at that distinct database. A given local transaction may be either successful or unsuccessful in completing its access.
Furthermore, the transactional environment 100 can support one or more transactions. Using the Open Group Distributed Transaction Processing (DTP) Model, the transaction manager (TM) 101 can construct transaction trees for various transactions with either tightly-coupled or loosely-coupled relationships with a resource manager (RM) 102. The coupling of the relationships can be determined in the way that the local services are defined, e.g. in the DMCONFIG file for the Oracle Tuxedo system.
As shown in
The tightly-coupled transaction 111 can include a plurality of transaction branches, e.g. branches 111a-111c, each of which can have the same transaction identifier (XID) 121. The common XID 121 can be used by all processes participating in the same global transaction 111 and accessing the same resource manager (RM) 102.
This tightly-coupled relationship can maximize data sharing between processes. For example, XA-compliant RMs can share locks for resources used by processes having the same XID. Additionally, the Tuxedo system can achieve the tightly-coupled relationship through the group concept. In Tuxedo, the work done by a group on behalf of a given global transaction belongs to the same transaction branch, and all the processes can be given with the same XID.
On the other hand, the loosely-coupled transaction 110 can include a plurality of transaction branches, e.g. branches 112-114, each of which can have a different transaction identifier (XID). As shown in
The TM 101 can generate a transaction branch for each part of the work in support of the global transaction. For example, a loosely-coupled relationship can be created in the Tuxedo system when each group participating in the same global transaction defines a transaction branch.
The resource manager (RM) 102 can handle each transaction branch in the loosely-coupled transaction 110 separately, and there is no sharing of data or of locks between the transaction branches. Furthermore, deadlocks, which may result in the rollback of the global transaction, can occur between the transaction branches in the loosely-coupled transaction 110.
A two-phase-commit (2PC) protocol can be used to execute a transaction, such as a loosely-coupled global transaction. The two-phase-commit protocol (2PC) can include a prepare phase and a commit phase. In the prepare phase, a coordinating transaction manager (TM) instructs the participating resource managers (RMs) to take the necessary steps for either committing or aborting the transaction. In the commit phase, the transaction manager (TM) decides whether to commit or abort the transaction, based on the results of the prepare phase.
For example, the transaction manager 201 can execute a transaction that involves transaction branch A 211, transaction branch B 212, and transaction branch C 213, each of which can be executed against a resource manager 202-204 respectively. If any branch fails in the transaction, the transaction manager 201 can help the resource manager 202-204 decide whether to commit, or roll back, the transaction.
As shown in
The transaction log (TLOG) may be written either to files, or to a database, so that the transaction manager 201 can have enough information to recover the transaction if any branch fails during the commit phase.
Then, the transaction manager 201 can instruct the resource manager 202-204 to commit all three branches (steps 8, 9 and 10). The resource manager 202-204 can inform the transaction manager 201 after successfully completing the commit phase (steps 11, 12 and 13).
In accordance with an embodiment of the invention, a read-only optimization can be used to improve the performance of a transactional system without sacrificing the ACID properties of the transaction. The read-only optimization can reduce the phases involved in executing a transaction and can eliminate the transaction log (TLOG).
The transaction manager 301 can execute a transaction that involves transaction branch A 311, transaction branch B 312, and transaction branch C 313, each of which can be executed against a resource manager 302 that manage one or more data source, e.g. a database 303.
In accordance with an embodiment of the invention, using the read-only optimization, the transaction manager 301 can withhold one branch during the prepare phase. As shown in
The transaction manager 301 can randomly pick a branch form the branches A-C 311-313 to hold. Alternatively, the transaction manager 301 can decide to hold a branch that can perform the fastest execution.
Furthermore, when each of these transaction branches A-B 311-312 returns a “Read-Only” vote (steps 3-4), the transaction manager 301 can invoke a commit operation on the branch C 313 directly (step 5), without invoking a prepare operation and/or writing a TLOG.
The “Read-Only” vote returned by the resource manager 302 indicates that no data on the branches has been modified. The transaction manager 301 can safely assume that the branches A-B 311-312 are completed and that no commit operations on the branches are necessary for this transaction.
Additionally, the transaction manager 301 can save a state of the branch C 313 to the database 303 while committing the branch C 313 (step 5). Thus, if the commit fails, the transaction manager 301 can recover the transaction by rolling back the branch C 313.
Using the read-only optimization, the system can improve the performance of a transaction by eliminating the TLOG. Furthermore, as shown in
Many Tuxedo applications uses on-line transaction process (OLTP), which runs on the same RM (one instance or more) and can taking advantage of the read-only optimization in a database, such as an Oracle Database. For a global transaction involving more than one Tuxedo group, Tuxedo can automatically hold one transaction branch which can be performed the fastest and do prepare stage on the other branches. If, and only if, all the other branches return a Read-only vote, Tuxedo can perform a commit operation directly on the branch on hold, without writing a TLOG and performing a prepare operation.
The transaction manager 501 can execute a global transaction that involves transaction branch A 511, transaction branch B 512, and transaction branch C 513, each of which can be executed against a resource manager 502 that manage one or more data source, e.g. a database 503.
In accordance with an embodiment of the invention, the transaction manager 501 can automatically find out whether the resource manager 502 supports the read-only optimization. The transaction manager 501 can take advantage of the read-only optimization when the resource manager 502 supports the read-only optimization. Otherwise, the transaction manager 501 can revert to the two-phase commit protocol.
For example, the transaction manager 501 can invoke a prepare operation on the branches A-B 511-512 of the transaction with the branch C 513 on hold (steps 1-2). When the resource manager (RM) 502 does not support the read-only optimization, or the transaction is loosely coupled, the resource manager (RM) 502 can return an “OK” vote instead of the “Read-Only” vote.
As shown in
Furthermore, following the two-phase-commit (2PC) protocol, the transaction manager 501 can invoke a commit operation on each of the branches A-C 511-513 (steps 8-10). Then, the resource manager (RM) 502 can inform the transaction manager 501 for each of the branches A-C 511-513 that is successfully committed (steps 11-13).
In accordance with an embodiment of the invention, the coordinator of transaction may not send commit request to a branch which indicates read-only at the prepare stage. Thus, the system can forgo the step 8 and step 11.
The transaction manager 602 can initiate a transaction that may involve multiple transaction domains 621-622. The global transaction can include multiple transaction branches A-C 611-613 that are tightly-coupled. The transaction branches A-C 611-613 can use the same transaction identifier (XID) 605 and can access the same resource manager 603.
As shown in
Then, after receiving the “Read-Only” vote from the resource manager 603 for both the branches A-B 611-612 (Step 2 and step 4), the transaction manager 602 can send a commit instruction to the resource manager 603 on branch C 613 directly (Step 5). Accordingly, the resource manager 603 can return a success vote after committing the transaction (Step 6).
In the example of Tuxedo, if a local TDomain is involved in an XA transaction coming from a remote TDomain, the global transaction identifier (GTRID), which may be referred to as the common grid, can be reused in the local domain to access RMs for this global transaction. Thus, the branches on these TDomains can be tightly coupled, if they are performed in same database and read-only optimization can be used.
The transaction manager 701 can execute a global transaction that involves transaction branch A 711, transaction branch B 712, and transaction branch C 713, each of which can be executed against a resource manager 702 that manage one or more data sources, e.g. a database 703.
In accordance with an embodiment of the invention, the resource manager 702 may not support the one-phase commit optimization. In such a case, the transaction manager 701 can treat the resource manager 702 as not supporting the read-only optimization, thus reverting to the two-phase commit protocol.
For example, the transaction manager 701 can invoke a prepare operation on the branches A-B 711-712 of the transaction with the branch C 713 on hold (steps 1-2), and receives a read-only vote on each of the branches A-B 711-712 (steps 3-4). The transaction manager 701 subsequently (step 5) can try to commit branch C 713, and receives an “XAER_PROTO” vote from the resource manager 702 (step 6), which indicates that the resource manager 702 can not commit the global transaction on branch C 713. Accordingly, the transaction manager 701 can revert to the two-phase commit protocol, which include the steps of preparing branch C 713 (steps 7-8), writing a TLOG (step 9), and committing the branch C 713 (steps 10-11).
The present invention may be conveniently implemented using one or more conventional general purpose or specialized digital computer, computing device, machine, or microprocessor, including one or more processors, memory and/or computer readable storage media programmed according to the teachings of the present disclosure. Appropriate software coding can readily be prepared by skilled programmers based on the teachings of the present disclosure, as will be apparent to those skilled in the software art.
In some embodiments, the present invention includes a computer program product which is a storage medium or computer readable medium (media) having instructions stored thereon/in which can be used to program a computer to perform any of the processes of the present invention. The storage medium can include, but is not limited to, any type of disk including floppy disks, optical discs, DVD, CD-ROMs, microdrive, and magneto-optical disks, ROMs, RAMs, EPROMs, EEPROMs, DRAMs, VRAMs, flash memory devices, magnetic or optical cards, nanosystems (including molecular memory ICs), or any type of media or device suitable for storing instructions and/or data
The foregoing description of the present invention has been provided for the purposes of illustration and description. It is not intended to be exhaustive or to limit the invention to the precise forms disclosed. Many modifications and variations will be apparent to the practitioner skilled in the art. The embodiments were chosen and described in order to best explain the principles of the invention and its practical application, thereby enabling others skilled in the art to understand the invention for various embodiments and with various modifications that are suited to the particular use contemplated. It is intended that the scope of the invention be defined by the following claims and their equivalence.
This application claims priority on U.S. Provisional Patent Application No. 61/612,144, entitled “SYSTEM AND METHOD FOR PROVIDING DISTRIBUTED TRANSACTION PROCESSOR DATABASE AFFINITY AND DISTRIBUTED TRANSACTION PROCESS OPTIMIZATION,” by inventors Todd Little, Edward A. Heeren, Paul Parkinson, Carol L. Colrain, Nancy Ikeda, Peizhi Shi, Right Lv, Jim Jin and Xugang Shen, filed Mar. 16, 2012, which application is herein incorporated by reference (Attorney Docket No. ORACL-05314U50). This application is related to the following patent applications, each of which is hereby incorporated by reference in its entirety: U.S. Patent Application titled “SYSTEM AND METHOD FOR SHARING GLOBAL TRANSACTION IDENTIFIER (GTRID) IN A TRANSACTIONAL MIDDLEWARE ENVIRONMENT”, application Ser. No. ______, filed ______, 2013 (Attorney Docket No. ORACL-05423US1); and U.S. patent application Ser. No. titled “SYSTEM AND METHOD FOR SUPPORTING APPLICATION INTEROPERATION IN A TRANSACTIONAL MIDDLEWARE ENVIRONMENT”, application Ser. No. ______, filed ______, 2013 (Attorney Docket No. ORACL-05423US2).
Number | Date | Country | |
---|---|---|---|
61612144 | Mar 2012 | US |