Skip to main content

Breaking the Read-Only Barrier: How to Run DML on Oracle Active Data Guard

                                                   ADG_REDIRECT_DML

Introduction

Historically, Active Data Guard (ADG) was strictly read-only. If an application needed to perform even a tiny "Insert into Audit_Log," it had to connect to the Primary.

The DML Redirection feature marks a significant shift in ADG capabilities. 

ADG_REDIRECT_DML allows the standby to accept DML, transparently redirect it to the Primary, and wait for the apply service to bring the change back. This functionality effectively eliminates the 'look-but-don't-touch' limitation, providing a seamless experience for read-mostly applications that require occasional data persistence.

Prerequisites & Environment

  • Oracle Database Version: 19c or higher.

  • License: Active Data Guard option.

  • Mode: Standby must be in READ ONLY WITH APPLY (Active Data Guard).

Primary Database Server : 





















Physical standby Database server: READ ONLY WITH APPLY


































                 How it Works (The "Magic" Behind the Scenes)

  1. DML is issued on the Standby.

  2. The Standby passes the metadata/DML to the Primary.

  3. Primary executes the DML and generates redo.

  4. Redo is shipped back to the Standby and applied.

  5. The Standby session completes the commit.

Step-by-Step Configuration

Setting up the Test Environment on the Primary: To demonstrate DML redirection, we first need to create a test user and a sample table on the Primary database.











 Standby :

If you attempt to perform a DML operation on the standby database without further configuration, Oracle will block the transaction with the following error: ORA-16000: database or pluggable database open for read-only access.


























To resolve this and enable transparent redirection, update the following initialization parameter on the Standby Database:

 ALTER SYSTEM SET ADG_REDIRECT_DML=TRUE SCOPE=BOTH;




































Validating the End-to-End Flow: After enabling ADG_REDIRECT_DML, the standby no longer throws ORA-16000. Instead, the write is transparently proxied to the Primary database. Once the transaction commits, the changes are propagated back to the standby through the standard redo transport services, ensuring data consistency across the environment.

Validate from Primary Database :






















Important Limitation: Administrative User Restrictions

During testing, I observed that DML Redirection does not apply to administrative accounts. If you attempt to perform DML on the standby while connected as SYS or SYSTEM, the database will return ORA-16397: statement redirection from Oracle Active Data Guard standby database to primary database failed. This confirms that the feature is intended for application-level schemas rather than administrative maintenance tasks.




















Update :
















































 Key Limitations 

  • It is not intended for high-volume write workloads (due to network latency).

  • PL/SQL blocks containing DML are handled differently (need ADG_REDIRECT_PLSQL).

  • Parallel DML is not supported for redirection.

Comments

Popular posts from this blog

ORA-65139: Mismatch between XML metadata file and data file

Error: CDB$ROOT@EBTUPRDC> CREATE PLUGGABLE DATABASE EBTUSPRDPDB1 using '/home/oracle/EBTUSPRDC.xml' nocopy tempfile reuse; CREATE PLUGGABLE DATABASE EBTUSPRDPDB1 using '/home/oracle/EBTUSPRDC.xml' nocopy tempfile reuse * ERROR at line 1: ORA-65139: Mismatch between XML metadata file and data file /u05/odb/ORADATA_1/EBTUSPRDC/datafile/system.1531.807800993 for value of fcpsb (2230502002 in the plug XML file, 2230505492 in the data file) Fix: Don't open Non-CDB database until we complete pdb creation other wise we will get above error. Shutdown immediate; startup mount; alter database open read only; create xml file. shutdown immediate; Connect to CDB and Create Pluggable database .

Useful OEM Queries to get Target details from OEM Repository

List Targets with TNS Listener ports configured : SELECT mgmt$target.host_name , mgmt$target.target_name , mgmt$target.target_type , mgmt$target_properties.property_name , mgmt$target_properties.property_value FROM mgmt$target , mgmt$target_properties WHERE ( mgmt$target.target_name = mgmt$target_properties.target_name ) AND ( mgmt$target.target_type = mgmt$target_properties.target_type ) and ( mgmt$target.target_type = 'oracle_listener' ) and ( mgmt$target_properties.property_name = 'Port' ); Devora02       LISTENER_ora02                       oracle_listener Port 1529 Devora01       LISTENER_ora01                       oracle_listener Port 1529 Devora04       LISTENE...

TFA-00002 : Oracle Trace File Analyzer (TFA) is not running

TFA Failed to start listening for commands on one of the Rac Node : As a root user /etc/init.d/init.tfa  start Starting TFA.. start: Job is already running: oracle-tfa Waiting up to 100 seconds for TFA to be started.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Successfully started TFA Process.. . . . . . TFA-00002 : Oracle Trace File Analyzer (TFA) is not running TFA Failed to start listening for commands Solution : run synctfanodes.sh  if you have root password . if no root password copy below files to TFA Failed node and try to restart TFA .. Please check whether these 4 files exist on all nodes are similar. TFA_HOME/server.jks TFA_HOME/client.jks TFA_HOME/internal/ssl.properties   TFA_HOME/internal/ portmapping.txt If not similar just copy these files to TFA Failing node and try TFA Restart ..It Worked for me .   [root@host01]# ./tfactl  -v "debug" start Starting TFA...