WebSpeed
Developer’s Guide
Multi-database Applications
In a multi-database application, you generally do not have to code any additional database transaction handling. Multi-database transactions are handled in much the same way that single-database transactions are handled. The WebSpeed two-phase commit mechanism ensures that any database transaction is either committed to all affected databases or to none. You should check to see that all necessary databases are connected before you start a database transaction.
Two-phase Commit
During a database transaction, WebSpeed writes data to one or more databases as program control passes through database update statements in the transaction block. At the end of a transaction block, WebSpeed tries to commit the changes to the databases. WebSpeed uses a two-phase commit protocol to commit the changes to the databases. In the two-phase commit protocol, WebSpeed polls all the databases affected by the transaction to see if they are reachable.
In the first phase of the two-phase commit, WebSpeed checks whether it can reach each database and makes the appropriate validation checks for each database. If any one of the databases is unreachable or the validation checks fail for a database, WebSpeed backs out the transaction and returns the databases to their pretransaction states using the before-image files. If all of the databases are reachable and their validation checks succeeded, WebSpeed commits the changes to the databases.
For more information on two-phase commit, see the Progress Database Administration Guide and Reference.
Checking Database Connections
If you want to test database connections prior to entering a database transaction, use the CONNECTED function:
NOTE: Thetxnblk.p
procedure exists only for illustration.You should connect to all databases affected by a database transaction prior to entering a transaction block. As a general rule, do not execute a database connection in a transaction block. The database connection overhead could lock records in other databases affected by the transaction for a considerable length of time. A database connection failure also causes a database transaction error. WebSpeed defers DISCONNECT statements in a database transaction until the transaction completes or is undone.
For more information about connecting and disconnecting databases, see the CONNECT and DISCONNECT statements in the Progress Language Reference.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |