distributed transactions and database links to rdb...
TRANSCRIPT
1
John Howard
Oracle RdbEngineering
©2004-2005, Oracle Corporation
Distributed Transactions andDatabase Links to Rdb
2
Agenda
• Transactions in DBLINK environment
• Why distributed transactions were hard
• Use of the DECdtm XA Gateway
• Demo
• What’s Next
3
What is a DBLINK?• A DBLINK is a Oracle RDBMS database server-
to-server connection– Set up in the Oracle RDBMS database with SQLPLUS:
SQL> CREATE DATABASE LINK dblink_name 2 CONNECT TO "username" IDENTIFIED BY 3 "password" USING "service_name";
– Uses a server-to-server subset of the OCI protocolOCI Native Connection (NATCON)
NATCON is a remote call interface
• Implementation in Rdb uses SQL Services– SQL Services Dispatcher resolves connection
– SQL Services Executor implements OCI NATCON Interface
– SQS Executor translates Oracle SQL into Rdb SQL
4
Transactions on a DBLINK
• OCI NATCON Transaction interface– Not SQL sentences like SET TRANSACTION– RCI calls to transaction functions in NATCON I/F:gtabegn(), gtaprtn(), gtacomm(),gtaroll(), gtafrgt(), gtareco()
– Implemented inside the SQL Executor
• Uses Oracle RDBMS internal transactionprotocol– Distributed transaction capable
2 Phase Commit (i.e. prepare and commit/rollback)Allows partner to decline 2PC
– “XA-like” protocol … but not XA
5
What’s the Problem withDBLINK 2PC and Rdb?
• Rdb supports distributed transactions but …– It uses DECdtm as the transaction manager– It requires DECdtm AST calls to manage transaction
SQS Executor would need a DECdtm TIDWould pass TID to Dispatch layer in context structureDispatch layer would join the DECdtm transaction
– Rdb recovery asks DECdtm for transaction status
• Oracle RDBMS Server doesn’t do DECdtm– SQS Executor has to decline 2PC– Oracle RDBMS server copes by calling DBLINK to
commit after other participants successfully prepare– Limits transaction to one Rdb DBLINK participant
6
HP to the Rescue
• DECdtm XA Gateway provided by HP– Interfaces an XA Transaction Manager (TM) to DECdtm
– Allows DECdtm Resource Manager (RM) – like Rdb –to participate in an XA transaction
– Released as part of OpenVMS 7.3-1
• Can be exploited for DBLINK 2PC– Oracle RDBMS protocol is similar and compatible
– Interface written for OCI NATCON to XA GatewaySQS Executor translates between protocols
Can now participate in distributed transactions
– One DBLINK limit removed
7
Gory Details ofImplementation
• SQS Executor is a SQL$PRE/CC application– Now compiled specifying implicit 2PC
– Executor’s Rdb Dispatch layer joins the default DECdtm transaction
• SQS Executor now sends NATCON transactioncalls to XA Gateway
– OCI transaction ID is used as an XA transaction ID
– XA Gateway calls DECdtm
Sets SQS Executor process default transaction
Passes transaction calls for that transaction
– DECdtm calls Dispatch layer of SQS Executor via ASTs
• SQL statements submitted dynamically as before
8
Gory Details Illustrated
OracleRDBMSServer
SQS Executor Process
RdbDispatch
OCINATCON
OCINATCON
I/F
DynamicSQL
XACalls
DECdtmServices
XA GatewayServer
DECdtmCalls
DECdtmCalls
9
How Do I Use It?
• Set up the DECdtm XA Gateway– Make sure Gateway server is installed:
DDTM$XG_SS.EXE– Use Gateway Control Program (XGCP.EXE) to:
Create a log for your XA domainStart up the Gateway server
• Define Rdb logical for XA Gateway domain– Logical name: RDB$DDTM_XG_INFO– For example:
$DEFINE/SYSTEM RDB$DDTM_XG_INFO SYSTEM$node_namewhere node_name is the OpenVMS node name
– Now SQL Services will automatically do 2PC
10
D E M O N S T R A T I O N
Transactions using MultipleDBLINKs to Rdb
11
What’s Next
• Enhanced Rdb Dispatch rule enforcement– Rdb only allows one concurrent transaction– Rdb Dispatch doesn’t detect 2nd transaction start
XA Gateway resets the default transactionRdb Dispatch doesn’t have an AST to detect that
– SQS Server has to guard against it– Rdb Dispatch needs to detect and reject setting new
default transaction before old one is finished
• Improved error reporting– DECdtm and XA Gateway “genericize” errors– Need to enhance Rdb Dispatch error reporting
12
For More Information
• www.oracle.com/rdb• metalink.oracle.com• www.hp.com/products/openvms• DECdtm XA Gateway info:
– Gateway control program: OpenVMS System ManagementUtilities Reference
– Managing transactions: OpenVMS System Manager’sManual
13
Q U E S T I O N S
A N S W E R S
14