Few days ago for a difficult reasons to explain i lost a production an Oracle database and i had to restore it for a tape backup.(we lost few hours of data). I had standby database attached to the production database that was in sync and it got corrupted as well meaning that i had to rebuild my standby from scratch. Well so far so good i put the production database back online and duplicated it do a standby as it was before but in my monitoring dashboard(i am using Nagios as an alternative monitoring tool) the Primary database sequence was way ahead of my Standby database sequence even thou in my Standby database alert.log the recovery process was doing correct recovery and the status of it reached the "transit" state. What the hell is going on ? As my database is replicating the data in the correct manner but still i get this error ! Let's start digging to see why this happens and how to fix it !
select max(SEQUENCE#) from v$archived_log;
MAX(SEQUENCE#)
--------------
3909
SELECT max(SEQUENCE#) FROM V$ARCHIVED_LOG where APPLIED='YES';
MAX(SEQUENCE#)
--------------
263
archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 263
Next log sequence to archive 265
Current log sequence 265
select distinct(to_char(RESETLOGS_CHANGE#)),RESETLOGS_TIME from v$archived_log;
(TO_CHAR(RESETLOGS_CHANGE#)) RESETLOGS
---------------------------------------- ---------
48539962706 18-DEC-14
51072706835 26-FEB-15 --my restore date
select max(SEQUENCE#) from v$archived_log;
set heading off trimspool on
select maxSCN AS PRIMARY
from (select max(sequence#) almax
from v\$archived_log
where resetlogs_change#=(select resetlogs_change# from v\$database where THREAD#=1)
) al,
(select max(sequence#) maxSCN
from v\$log_history
where first_time=(select max(first_time) from v\$log_history where THREAD#=1)
) lh;