distributed transactions and database links to rdb...

14
1 John Howard Oracle Rdb Engineering ©2004-2005, Oracle Corporation Distributed Transactions and Database Links to Rdb

Upload: lydung

Post on 17-Apr-2018

248 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Distributed Transactions and Database Links to Rdb …download.oracle.com/otndocs/products/rdb/pdf/rdbtf05_disttrans.pdfDistributed Transactions and Database Links to Rdb. 2 ... –

1

John Howard

Oracle RdbEngineering

©2004-2005, Oracle Corporation

Distributed Transactions andDatabase Links to Rdb

Page 2: Distributed Transactions and Database Links to Rdb …download.oracle.com/otndocs/products/rdb/pdf/rdbtf05_disttrans.pdfDistributed Transactions and Database Links to Rdb. 2 ... –

2

Agenda

• Transactions in DBLINK environment

• Why distributed transactions were hard

• Use of the DECdtm XA Gateway

• Demo

• What’s Next

Page 3: Distributed Transactions and Database Links to Rdb …download.oracle.com/otndocs/products/rdb/pdf/rdbtf05_disttrans.pdfDistributed Transactions and Database Links to Rdb. 2 ... –

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

Page 4: Distributed Transactions and Database Links to Rdb …download.oracle.com/otndocs/products/rdb/pdf/rdbtf05_disttrans.pdfDistributed Transactions and Database Links to Rdb. 2 ... –

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

Page 5: Distributed Transactions and Database Links to Rdb …download.oracle.com/otndocs/products/rdb/pdf/rdbtf05_disttrans.pdfDistributed Transactions and Database Links to Rdb. 2 ... –

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

Page 6: Distributed Transactions and Database Links to Rdb …download.oracle.com/otndocs/products/rdb/pdf/rdbtf05_disttrans.pdfDistributed Transactions and Database Links to Rdb. 2 ... –

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

Page 7: Distributed Transactions and Database Links to Rdb …download.oracle.com/otndocs/products/rdb/pdf/rdbtf05_disttrans.pdfDistributed Transactions and Database Links to Rdb. 2 ... –

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

Page 8: Distributed Transactions and Database Links to Rdb …download.oracle.com/otndocs/products/rdb/pdf/rdbtf05_disttrans.pdfDistributed Transactions and Database Links to Rdb. 2 ... –

8

Gory Details Illustrated

OracleRDBMSServer

SQS Executor Process

RdbDispatch

OCINATCON

OCINATCON

I/F

DynamicSQL

XACalls

DECdtmServices

XA GatewayServer

DECdtmCalls

DECdtmCalls

Page 9: Distributed Transactions and Database Links to Rdb …download.oracle.com/otndocs/products/rdb/pdf/rdbtf05_disttrans.pdfDistributed Transactions and Database Links to Rdb. 2 ... –

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

Page 10: Distributed Transactions and Database Links to Rdb …download.oracle.com/otndocs/products/rdb/pdf/rdbtf05_disttrans.pdfDistributed Transactions and Database Links to Rdb. 2 ... –

10

D E M O N S T R A T I O N

Transactions using MultipleDBLINKs to Rdb

Page 11: Distributed Transactions and Database Links to Rdb …download.oracle.com/otndocs/products/rdb/pdf/rdbtf05_disttrans.pdfDistributed Transactions and Database Links to Rdb. 2 ... –

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

Page 12: Distributed Transactions and Database Links to Rdb …download.oracle.com/otndocs/products/rdb/pdf/rdbtf05_disttrans.pdfDistributed Transactions and Database Links to Rdb. 2 ... –

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

[email protected]

Page 13: Distributed Transactions and Database Links to Rdb …download.oracle.com/otndocs/products/rdb/pdf/rdbtf05_disttrans.pdfDistributed Transactions and Database Links to Rdb. 2 ... –

13

Q U E S T I O N S

A N S W E R S

Page 14: Distributed Transactions and Database Links to Rdb …download.oracle.com/otndocs/products/rdb/pdf/rdbtf05_disttrans.pdfDistributed Transactions and Database Links to Rdb. 2 ... –

14