Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 


Using SQL*Net in a Distributed Database Environment

Oracle Tips by Burleson Consulting

Updated 2 June 2015


Also see Two Phase Commit 2PC Tips

Managing Two-Phase Commits (2PCs) With SQL*Net

When a distributed update (or delete) has finished processing, SQL*Net will coordinate COMMIT processing, which means that the entire transaction will roll back if any portion of the transaction fails.

The first phase of this process is a prepare phase to each node, followed by the COMMIT, and then terminated by a forget phase.

If a distributed update is in the process of issuing the 2PC and a network connection breaks, Oracle will place an entry in the dba_2pc_pending table. The recovery background process (RECO) will then roll back or commit the good node to match the state of the disconnected node to ensure consistency. You can activate RECO via the ALTER SYSTEM ENABLE DISTRIBUTED RECOVERY command.

The dba_2pc_pending table contains an ADVISE column that directs the database to either commit or roll back the pending item. You can use the ALTER SESSION ADVISE syntax to direct the 2PC mechanism. For example, to force the completion of an INSERT, you could enter the following:

ALTER SESSION ADVISE COMMIT;
INSERT INTO PAYROLL@LONDON . . . ;

When a 2PC transaction fails, you can query the dba_2pc_pending table to check the STATE column. You can enter SQL*DBA and use the Recover In-Doubt Transaction dialog box to force either a roll back or a commit of the pending transaction. If you do this, the row will disappear from dba_2pc_pending after the transaction has been resolved. If you force the transaction the wrong way (for example, roll back when other nodes committed), RECO will detect the problem, set the MIXED column to yes, and the row will remain in the dba_2pc_pending table.

Internally, Oracle examines the init.ora parameters to determine the rank that the commit processing will take. The commit_point_strength init.ora parameter determines which of the distributed databases is to be the commit point site. In a distributed update, the database with the largest value of commit_point_strength will be the commit point site.

Viewing pending two phase commit transactions

The commit point site is the database that must successfully complete before the transaction is updated at the other databases. Conversely, if a transaction fails at the commit point site, the entire transaction will be rolled back at all of the other databases. In general, the commit point site should be the database that contains the most critical data. Below is a script that will identify a two-phase commit transaction that has failed to complete.

Two Phase commit  pending.sql reports on any pending distributed transactions.

set pagesize 999;
set feedback off;
set wrap on;

column local_tran_id  format a22 heading 'Local Txn Id'
column global_tran_id format a50 heading 'Global Txn Id'
column state          format a16 heading 'State'
column mixed          format a5  heading 'Mixed'
column advice         format a5  heading 'Advice'        

select
   local_tran_id,
   global_tran_id,
   state,mixed,advice
from  
   dba_2pc_pending
order 
   by local_tran_id;

Managing two phase commits

When a distributed update (or delete) has finished processing, SQL*Net will coordinate commit processing so that if any portion of the transaction fails, the entire transaction will roll back. The first phase of this process is a "prepare phase" to each node, followed by the commit, and then terminated by a "forget phase."

If a distributed update is in the process of issuing the 2PC and a network connection breaks, Oracle will place an entry in the dba_2pc_pending table, and the recovery background process, reco, will roll back or commit the good node to match the state of the disconnected node, thereby ensuring consistency.

You can activate reco via the alter system enable distributed recovery command. The reco process is applicable only when the distributed option is installed in Oracle, and is only used to manage 2PCs. If your system does not perform cross-database synchronization, you may want to disable reco.

The dba_2pc_pending table contains an "advise" column that directs the database to either commit or rollback the pending item. You can use the alter session advise syntax to direct the 2PC mechanism. For example, to force the completion of an insert, you can enter the following:

ALTER SESSION ADVISE COMMIT;
INSERT INTO PAYROLL@LONDON . . . ;

When a 2PC transaction fails, you can query the dba_2pc_pending table to check the "state" column. You can enter SQL*DBA and use the "recover in-doubt transaction" dialog box to force either a rollback or a commit of the pending transaction. If you do this, the row will disappear from dba_2pc_pending after the transaction has been resolved.

If you force the transaction the wrong way (for example, to roll back when other nodes have already committed), reco will detect the problem, set the mixed column to "yes," and the row will remain in dba_2pc_pending table.

 
Get the Complete
Oracle SQL Tuning Information 

The landmark book "Advanced Oracle SQL Tuning  The Definitive Reference"  is filled with valuable information on Oracle SQL Tuning. This book includes scripts and tools to hypercharge Oracle 11g performance and you can buy it for 30% off directly from the publisher.


 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster