We have added an AFTER LOGON ON DATABASE,AFTER DDL ON DATABASE and AFTER SERVERERROR ON DATABASE trigger.
Standby databases are not writable and so this is not going to work.
As a result every users connecting to the standby database were complaining:
ORA-00604: error occurred at recursive SQL level 1
ORA-16000: database open for read-only access
ORA-06512: at line 2
ORA-02063: preceding 3 lines
00604. 00000 -"error occurred at recursive SQL level %s"
*Cause:An error occurred while processing a recursive SQL statement
(a statement applying to internal dictionary tables).
*Action: If the situation described in the next error on the stack
can be corrected, do so; otherwise contact Oracle Support.
Another issue raises the replication does not work i.e. Data sync is no working.
Realising my mistake I dropped/disable the trigger but this didn’t make the problem go away on the standby database.
A quick look in the alert log on the primary and there was a logon failure related to Data Guard:
Error 1017 received logging on to the standby
------------------------------------------------------------
Check that the primary and standby are using a password file
and remote_login_passwordfile is set to SHARED or EXCLUSIVE,
and that the SYS password is same in the password files.
returning error ORA-16191
------------------------------------------------------------
PING[ARCl]: Heartbeat failed to connect to standby 'adgrpt'. Error is 16191.
I checked the SYS passwords on both nodes in case an underlying problem had suddenly occurred but all was ok.
Looking at the output we have a big clue here,
as it looks like the error the users were getting:
ORA-16000: database open for read-only access
Why are we still getting that when I’ve dropped the trigger on the primary database? It is immediately apparent that
I have broken Data Guard and my drop is in a log file awaiting shipping to the standby. This is a catch 22:
I can’t apply the log because the trigger won’t let Data Guard authenticate and Data Guard can’t authenticate because of the presence of the trigger.
Two questions sprang to my mind:
Can I disable the trigger?
Why is the trigger affecting the SYS user?
I can’t workaround the trigger in any documented way because any attempt to do so on the physical standby is prevented by its read-only status, for example:
SQL> grant ADMINISTER DATABASE TRIGGER to appuser;
grant ADMINISTER DATABASE TRIGGER to appuser
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-16000: database open for read-only access
Here user SYS is connecting with a password not “as sysdba” and so we are hitting the logon trigger.
we can the following system parameter .
alter system set "_system_trig_enabled"=FALSE;
I can then restart the recovery with:
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
And of course not forgetting to re-enable system triggers:
alter system set "_system_trig_enabled"=TRUE;
It should be pointed out that this method is nice because it doesn’t involve restarting the standby and therefore interrupting any running reports
but if you don’t like undocumented parameters or you have other system triggers you depend on you can instead:
Shut down the standby.
Restart the standby in MOUNT mode. This means that any triggers will not fire.
Start the recovery.
If the trigger has been dropped on the primary it should replicate to the secondary.
Open the database.
Source URL: https://oraganism.wordpress.com/2015/08/26/non-working-logon-trigger-on-data-guard-standby-database/
Standby databases are not writable and so this is not going to work.
As a result every users connecting to the standby database were complaining:
ORA-00604: error occurred at recursive SQL level 1
ORA-16000: database open for read-only access
ORA-06512: at line 2
ORA-02063: preceding 3 lines
00604. 00000 -"error occurred at recursive SQL level %s"
*Cause:An error occurred while processing a recursive SQL statement
(a statement applying to internal dictionary tables).
*Action: If the situation described in the next error on the stack
can be corrected, do so; otherwise contact Oracle Support.
Another issue raises the replication does not work i.e. Data sync is no working.
Realising my mistake I dropped/disable the trigger but this didn’t make the problem go away on the standby database.
A quick look in the alert log on the primary and there was a logon failure related to Data Guard:
Error 1017 received logging on to the standby
------------------------------------------------------------
Check that the primary and standby are using a password file
and remote_login_passwordfile is set to SHARED or EXCLUSIVE,
and that the SYS password is same in the password files.
returning error ORA-16191
------------------------------------------------------------
PING[ARCl]: Heartbeat failed to connect to standby 'adgrpt'. Error is 16191.
I checked the SYS passwords on both nodes in case an underlying problem had suddenly occurred but all was ok.
Looking at the output we have a big clue here,
as it looks like the error the users were getting:
ORA-16000: database open for read-only access
Why are we still getting that when I’ve dropped the trigger on the primary database? It is immediately apparent that
I have broken Data Guard and my drop is in a log file awaiting shipping to the standby. This is a catch 22:
I can’t apply the log because the trigger won’t let Data Guard authenticate and Data Guard can’t authenticate because of the presence of the trigger.
Two questions sprang to my mind:
Can I disable the trigger?
Why is the trigger affecting the SYS user?
I can’t workaround the trigger in any documented way because any attempt to do so on the physical standby is prevented by its read-only status, for example:
SQL> grant ADMINISTER DATABASE TRIGGER to appuser;
grant ADMINISTER DATABASE TRIGGER to appuser
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-16000: database open for read-only access
Here user SYS is connecting with a password not “as sysdba” and so we are hitting the logon trigger.
we can the following system parameter .
alter system set "_system_trig_enabled"=FALSE;
I can then restart the recovery with:
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
And of course not forgetting to re-enable system triggers:
alter system set "_system_trig_enabled"=TRUE;
It should be pointed out that this method is nice because it doesn’t involve restarting the standby and therefore interrupting any running reports
but if you don’t like undocumented parameters or you have other system triggers you depend on you can instead:
Shut down the standby.
Restart the standby in MOUNT mode. This means that any triggers will not fire.
Start the recovery.
If the trigger has been dropped on the primary it should replicate to the secondary.
Open the database.
Source URL: https://oraganism.wordpress.com/2015/08/26/non-working-logon-trigger-on-data-guard-standby-database/