Recreate plog

When a plog is corrupted and it is required to recreate the corrupted plog we have to reset mine to start parsing again from old redo/archivelog and generate plog. This will re-create all the plogs from the corrupted plog.

Example : Plog 1056

1. First of all shutdown mine and apply.

2. Get REDO LOG sequence with which plog 1056 was created. Run following command on MINE server.

SQL> select REDO_THREAD,REDO_SEQUENCE,PLOG_SEQUENCE from DBRSMINE_RLOG_PLOG_MAP where PLOG_SEQUENCE=1056;

REDO_THREAD REDO_SEQUENCE PLOG_SEQUENCE
 ----------- ------------- -------------
 1 1056 1056

3. Delete records from DBRSAPPLY_PLOG_HISTORY on APPLY server. Copy the table to some temp table as backup.

SQL> create table DBRSAPPLY_PLOG_HISTORY_TEMP as select * from DBRSAPPLY_PLOG_HISTORY;
Table created.
SQL>
SQL> delete from DBRSAPPLY_PLOG_HISTORY where SEQUENCE>=1056;
2 rows deleted.
SQL> commit;
Commit complete

.

4. Delete records from DBRSAPPLY_REDO_LOG_HISTORY on APPLY server. Copy the table to some temp table as backup.
Here SEQUENCE column denotes redo sequence. In RAC source, a plog is created from multiple redo's of different threads, therefore we have to delete records for all threads. ( 2 threads for 2 RAC source).

SQL> create table APP_REDO_HISTORY_TEMP as select * from DBRSAPPLY_REDO_LOG_HISTORY
Table created
SQL>
SQL> delete from DBRSAPPLY_REDO_LOG_HISTORY where SEQUENCE>=1056 and THREAD=1;
2 rows deleted.
SQL> commit;
Commit complete.
 
------ FOR THREAD 2: (IN RAC SOURCE) ------
SQL> delete from DBRSAPPLY_REDO_LOG_HISTORY where SEQUENCE>=XXXX and THREAD=2;

5. Reset MINE using following command. Execute this command in console when mine and apply are NOT running. 

dbvrep> ENGINE MINE RESET TO PLOG 1056

6. Delete plog files from mine and apply server as mine will generate new plogs for same sequneces.

oracle@dbvlin203[/home/oracle/reptest1/mine]: ls
1053.plog 1054.plog 1055.plog 1056.plog 1057.plog 1058.plog 1059.plog
oracle@dbvlin203[/home/oracle/reptest1/mine]: rm -r 1056.plog 1057.plog 1058.plog 1059.plog
oracle@dbvlin203[/home/oracle/reptest1/mine]:
-- Repeat on APPLY --

7. Now you can start mine and apply. Mine will start parsing from redo 1056 again.

When fetcher is used, you don't have to bring down the fetcher and you need not  delete archives from mine_stage. The mine would automatically pick up the first archivelog from the mine_stage directory to generate the required PLOG and then move forward.

You can set plog sequence (in this example 1056) to the most recent uncorrupted plog. Usually this sequence should be equal to the plog sequence APPLY was processing before shutdown. But if you are not sure you can always set it 2-3 sequences behind the actual APPLY plog. There is no issue with this. Replicate is aware of the changes that have already been applied to the target and will not try to re-apply them. However, it will have to read through any previously applied plogs to determine this, and that may take some time, depending on the size of the plogs and the data contained within. Generally speaking there is usually no reason to set the sequence too far in the past. Whatever plog sequence you choose you need to ensure that the corresponding archlogs exist.

MINE will re-mine all plogs from and including sequence you specified and APPLY will process all plogs from and including this sequence.