Deconstruct Streams LCR

At times while resolving streams replication issues, it might be faster to generate individual queries associated with an failed LCR instead of relying on routines provided by the DBMS_APPLY_ADM package.In addition the script attached to this blog can be used to clear LCR back log in parallel as long as the source commit order is maintained.

The driving query in the anonymous block is as follows and chose an appropriate filter to handle your issue
for currec in (
 select local_transaction_id, message_count
 from dba_apply_error
  where -- local_transaction_id = '70.18.2231436' --# Use this filter to handle one LCR at a time
    -- ERROR_MESSAGE LIKE '%DBOR_USERS%' --# Use this filter to handle LCR which have errors in the same table
    -- error_creation_time >= to_timestamp('18-MAR-2013 08:00:00','dd-MON-RRRR HH24:MI:SS')  --#  Use the following two to filter on a date range.
    --and error_creation_time <  to_timestamp('18-MAR-2013 10:00:00','dd-MON-RRRR HH24:MI:SS')
ORDER BY source_commit_scn)



Note: Prior to executing the SQL generated by the script, you will have to resolve the underlying issue that led to the Apply failure.

Usage

1. Copy the script to the target database
2. Make the necessary updates to the driving query filter to target specific errors
3. Log on to the database as sys or streams_admin user.
4. Start a spool file. e.g. spool somefilename.sql
5. run the script as a anonymous block
6. The generated output can be executed without any changes.

Notes

1. Should you wish to remove trailing spaces in the output file, then use the following series of commands
cat [spooled_file_name] | sed -e "s/ \{1,\}$//" > new_file_name



Download the script from here.


Comments

Popular posts from this blog

Recover Standby database from ORA-00332: archived log is too small

Check Active Dataguard Replication Status

Top CPU consuming oracle sessions