In Part 6, we configured Redo Transport Services. Now we move to the other side of the pipeline:
How does the standby actually apply the redo it receives?
This is where we distinguish between redo transport, redo reception, and redo application.
A standby that is receiving redo is not necessarily applying it. That’s an important distinction when troubleshooting Data Guard.
1. The Complete Data Guard Pipeline
Our architecture is now:
PRIMARY RAC
|
LGWR / ARCH
|
v
Redo Transport
|
Oracle Net
|
v
+---------------+
| Standby RAC |
| |
| RFS |
| | |
| v |
| SRL |
| | |
| v |
| MRP |
| | |
| v |
| Datafiles |
+---------------+
There are three important stages:
1. Transport 2. Receive 3. Apply
If something is wrong, we need to know which stage is responsible.
2. What Is Redo Apply?
Redo Apply is the process of applying redo generated on the primary to the standby database.
The primary generates:
INSERT UPDATE DELETE DDL COMMIT
These changes generate redo.
The standby receives that redo and uses it to reproduce the same database changes.
Conceptually:
PRIMARY
Transaction
|
v
Redo
|
v
Transport
|
v
STANDBY
Redo
|
v
Redo Apply
|
v
Datafiles
The standby doesn’t execute the original SQL statements again.
It applies the redo information.
3. MRP — Managed Recovery Process
The central process for physical standby redo apply is:
MRP0
Managed Recovery Process.
You can check it with:
SELECT process,
status,
thread#,
sequence#
FROM v$managed_standby
ORDER BY process;
Typical output:
PROCESS STATUS THREAD# SEQUENCE# --------- -------------- -------- ---------- MRP0 APPLYING_LOG 1 1250 RFS RECEIVING 1 1251 RFS RECEIVING 2 984
The important line is:
MRP0 APPLYING_LOG
That tells you redo apply is active.
4. RFS vs MRP
This distinction is fundamental.
RFS
Remote File Server.
Its job is to receive redo from the primary.
Primary | v Network | v RFS
MRP
Managed Recovery Process.
Its job is to apply redo to the standby database.
SRL / archived redo
|
v
MRP
|
v
Datafiles
Therefore:
RFS = Receive MRP = Apply
If RFS is active but MRP is stopped:
Redo is arriving
+
Redo is NOT being applied
This produces growing apply lag.
5. Redo Apply Modes
For a physical standby, you will commonly encounter:
Archived Log Apply
and:
Real-Time Apply
The difference is when MRP starts applying redo.
6. Traditional Archived Log Apply
Without Real-Time Apply:
Primary | v Redo | v Archive Log | v Standby | v MRP
The standby waits for the redo to become available as an archived log.
Conceptually:
Generate redo
|
v
Archive log
|
v
Transport
|
v
Apply
There is naturally more latency.
7. Real-Time Apply
With Real-Time Apply:
Primary | v Redo | v Standby Redo Log | v MRP | v Datafiles
MRP can apply redo from the standby redo log before the corresponding primary redo log is archived.
That’s the key idea.
8. Why Real-Time Apply Matters
Suppose the primary generates:
Sequence 100
Traditional apply might wait for:
Sequence 100
↓
Archive
↓
Transport
↓
Standby
↓
Apply
Real-Time Apply can work more like:
Sequence 100
↓
Transport
↓
SRL
↓
MRP
This can significantly reduce apply latency.
For a serious Data Guard implementation, Real-Time Apply should normally be part of the design.
9. Prerequisite: Standby Redo Logs
This connects directly to Part 5.
Real-Time Apply requires standby redo logs.
We already created:
Thread 1 ├── SRL ├── SRL ├── SRL └── SRL Thread 2 ├── SRL ├── SRL ├── SRL └── SRL
Now those SRLs become the immediate source of redo for MRP.
10. Start Redo Apply
On the physical standby:
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
This starts managed recovery.
Check:
SELECT process,
status,
thread#,
sequence#
FROM v$managed_standby;
You should see something similar to:
MRP0 APPLYING_LOG
11. Start Real-Time Apply
For Oracle 19c, the preferred operational approach is to use managed recovery with standby redo logs and verify that the standby is applying from the current redo stream.
A commonly seen command is:
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
The important point for a modern 19c implementation is not simply memorizing this syntax.
Verify that real-time apply is actually active.
12. Check Recovery Mode
Run:
SELECT recovery_mode FROM v$archive_dest_status WHERE status = 'VALID';
You may see:
MANAGED REAL TIME APPLY
That is a strong indication that the standby is applying redo in real time.
You can also inspect:
SELECT dest_id,
status,
recovery_mode,
synchronization_status,
gap_status
FROM v$archive_dest_status
WHERE target = 'STANDBY';
13. Oracle 19c Process View
For Oracle 19c, don’t rely exclusively on old monitoring scripts.
Also use:
SELECT name,
role,
action,
client_role,
thread#,
sequence#
FROM v$dataguard_process
ORDER BY name;
This gives you a broader picture of Data Guard processes.
14. Verify MRP
Run:
SELECT process,
status,
thread#,
sequence#
FROM v$managed_standby
WHERE process LIKE 'MRP%';
Expected:
PROCESS STATUS THREAD# SEQUENCE# ------- -------------- ------- --------- MRP0 APPLYING_LOG 1 1250
If instead you get:
MRP0 WAIT_FOR_LOG
that doesn’t automatically mean something is broken.
It may simply mean:
MRP has caught up and is waiting for more redo.
This distinction is very important.
15. WAIT_FOR_LOG Is Not Necessarily an Error
Suppose:
Primary latest sequence = 1250 Standby applied = 1250
MRP may show:
WAIT_FOR_LOG
because there is nothing else to apply.
That’s healthy.
But if:
Primary = 1500 Standby = 1250
and MRP says:
WAIT_FOR_LOG
then you have a problem to investigate.
Always correlate the process status with the primary and standby sequence numbers.
16. Generate Test Redo
On the primary:
ALTER SYSTEM SWITCH LOGFILE;
Wait briefly, then check the standby:
SELECT process,
status,
thread#,
sequence#
FROM v$managed_standby;
You should see MRP moving through the new sequence.
For RAC, generate redo on both threads.
17. RAC: Don’t Forget Threads
Our primary has:
Thread 1 → PROD1 Thread 2 → PROD2
Therefore the standby must apply:
Thread 1 Thread 2
Check:
SELECT thread#,
MAX(sequence#) AS last_applied
FROM v$archived_log
WHERE applied = 'YES'
GROUP BY thread#
ORDER BY thread#;
Example:
THREAD# LAST_APPLIED ------- ------------ 1 1250 2 984
This is much more useful than looking only at the highest sequence number.
18. Check Received vs Applied
On the standby:
SELECT thread#,
MAX(sequence#) AS last_received
FROM v$archived_log
GROUP BY thread#
ORDER BY thread#;
Then:
SELECT thread#,
MAX(sequence#) AS last_applied
FROM v$archived_log
WHERE applied = 'YES'
GROUP BY thread#
ORDER BY thread#;
Conceptually:
Received: Thread 1 → 1255 Thread 2 → 990 Applied: Thread 1 → 1254 Thread 2 → 990
Thread 1 has some unapplied redo.
19. A Better Apply-Lag Check
Use:
SELECT name,
value,
unit,
time_computed
FROM v$dataguard_stats
WHERE name IN
(
'transport lag',
'apply lag',
'apply finish time'
);
Example:
NAME VALUE -------------------- ---------------- transport lag +00 00:00:01 apply lag +00 00:00:02
That’s excellent.
20. Transport Lag vs Apply Lag
Remember:
Transport Lag
means:
Redo hasn’t reached the standby yet.
Whereas:
Apply Lag
means:
Redo has reached the standby, but apply hasn’t caught up.
Example:
Primary | | 10 minutes behind v Standby
If the redo hasn’t arrived:
Transport problem
If it has arrived but MRP is behind:
Apply problem
This distinction will save you a lot of troubleshooting time.
21. Real-Time Apply Architecture
The architecture we’re building is:
PRIMARY
|
LGWR
|
ASYNC / SYNC
|
v
Oracle Net
|
v
RFS
|
v
Standby Redo Log
|
v
MRP0
|
v
Datafiles
Notice that MRP doesn’t have to wait for:
Primary Archive
before starting to apply the incoming redo.
22. Real-Time Apply and RPO
Real-Time Apply reduces the apply window.
For example:
Without RTA:
Redo generated
↓
Archive
↓
Transport
↓
Apply
versus:
With RTA:
Redo generated
↓
Transport
↓
SRL
↓
Apply
Therefore:
RTA ↓ lower apply latency ↓ lower potential recovery exposure
It doesn’t magically eliminate data loss; transport mode and protection mode still matter.
23. Real-Time Apply Does Not Mean Zero Data Loss
This is a very important point.
You might have:
Real-Time Apply = ON
and still use:
LGWR ASYNC
There can still be redo that hasn’t reached the standby.
So:
Real-Time Apply ≠ Zero Data Loss
Zero or near-zero data loss depends on the complete Data Guard architecture.
24. Apply Rate
You should monitor not only lag but also how quickly the standby can apply redo.
A useful operational metric is:
Redo generation rate vs Redo apply rate
If the primary generates:
500 MB/s
while standby can apply:
300 MB/s
then eventually:
Apply lag ↑
Even if transport is perfect.
25. The Real Bottleneck
Consider:
Primary | 500 MB/s | v Network | 500 MB/s | v SRL | 500 MB/s | v MRP | 300 MB/s | v Datafiles
The bottleneck is:
MRP / standby apply
Adding more network bandwidth won’t solve it.
You need to investigate:
CPU Storage I/O latency Database workload Parallel recovery/apply behavior
26. Monitoring Apply Progress
Use:
SELECT
thread#,
sequence#,
applied,
first_time,
next_time
FROM v$archived_log
ORDER BY thread#, sequence# DESC;
For a specific thread:
SELECT
thread#,
sequence#,
applied,
first_time
FROM v$archived_log
WHERE thread# = 1
ORDER BY sequence# DESC;
27. Identify the Last Applied Sequence
For RAC:
SELECT
thread#,
MAX(sequence#) last_applied
FROM v$archived_log
WHERE applied = 'YES'
GROUP BY thread#
ORDER BY thread#;
This gives:
Thread 1 → last applied Thread 2 → last applied
That’s the correct way to think about RAC Data Guard apply.
28. Check the Standby Database Role
Always verify:
SELECT database_role,
open_mode,
protection_mode,
protection_level
FROM v$database;
For a normal physical standby:
DATABASE_ROLE ------------- PHYSICAL STANDBY OPEN_MODE --------- MOUNTED
or, if using Active Data Guard:
DATABASE_ROLE ------------- PHYSICAL STANDBY OPEN_MODE --------- READ ONLY WITH APPLY
29. Active Data Guard
Active Data Guard allows the standby to be open read-only while redo apply continues.
Architecture:
PRIMARY
|
v
REDO
|
v
STANDBY RAC
/ \
/ \
MRP Apply Queries
| |
v v
Datafiles Read Only
This is particularly useful for:
- reporting
- read-only workloads
- analytics
- backups
- DR validation
It requires the appropriate Oracle licensing.
30. Open Read Only With Apply
In an Active Data Guard environment, you can use:
ALTER DATABASE OPEN READ ONLY;
with the appropriate managed recovery configuration.
In practice, the exact startup/open sequence depends on the state of the standby and whether you are using Data Guard Broker.
Afterward verify:
SELECT open_mode FROM v$database;
Expected:
READ ONLY WITH APPLY
31. Apply Process During Active Data Guard
You may see:
RFS MRP0
while users are querying the standby.
The database is simultaneously:
Receiving redo + Applying redo + Serving read-only queries
This creates additional resource requirements.
32. Apply and Storage
Standby redo and datafile I/O must be designed carefully.
For example:
+DATA ├── Datafiles ├── SRLs └── Control files +RECO ├── Archived logs ├── Flashback logs └── FRA
Heavy redo workloads can expose storage bottlenecks.
Monitor ASM:
SELECT name,
total_mb,
free_mb,
usable_file_mb
FROM v$asm_diskgroup;
33. Apply and CPU
If apply lag increases while:
Transport lag ≈ 0
look at CPU.
Linux:
top
or:
vmstat 1
Oracle:
SELECT inst_id,
stat_name,
value
FROM gv$osstat
WHERE stat_name IN
(
'NUM_CPUS',
'BUSY_TIME',
'IDLE_TIME'
);
The objective is to determine whether the standby is CPU constrained.
34. Apply and I/O
Check:
SELECT
event,
total_waits,
time_waited
FROM v$system_event
WHERE wait_class = 'User I/O'
ORDER BY time_waited DESC;
Also examine:
SELECT
filetype_name,
asynch_io,
access_method
FROM v$iostat_file;
You want to determine whether the standby’s storage can sustain the redo apply workload.
35. A Practical Test
Let’s create a simple test.
Step 1 — Check current apply
Standby:
SELECT name,
value
FROM v$dataguard_stats
WHERE name = 'apply lag';
Step 2 — Generate redo
Primary:
ALTER SYSTEM SWITCH LOGFILE;
Step 3 — Check MRP
Standby:
SELECT process,
status,
thread#,
sequence#
FROM v$managed_standby;
Step 4 — Check apply
SELECT name,
value
FROM v$dataguard_stats
WHERE name IN
(
'transport lag',
'apply lag'
);
36. Simulate Stopped Apply
This is an important DBA exercise.
On the standby:
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Now MRP stops.
Verify:
SELECT process,
status
FROM v$managed_standby;
Generate redo on the primary:
ALTER SYSTEM SWITCH LOGFILE;
Now the standby may continue receiving redo:
RFS → SRL
but:
MRP → stopped
This is a very useful demonstration of the difference between transport and apply.
37. Restart Apply
Start it again:
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Then monitor:
SELECT process,
status,
thread#,
sequence#
FROM v$managed_standby;
You should see MRP process the backlog.
38. Real-Time Apply Test
With SRLs configured:
Primary | v LGWR | v RFS | v SRL | v MRP
Generate a controlled amount of redo and observe:
SELECT thread#,
sequence#,
status,
archived
FROM v$standby_log
ORDER BY thread#, group#;
The active SRL should reflect incoming redo.
39. Important Operational Difference
A common mistake is:
“The archive log exists on the standby, so Data Guard is healthy.”
Not necessarily.
You need to check:
Transport ↓ Received ↓ Applied
For example:
Received sequence = 500 Applied sequence = 450
Data Guard is receiving redo, but apply is 50 sequences behind.
40. Apply Gap Detection
Check:
SELECT * FROM v$archive_gap;
If no rows are returned:
No known archive gap
If rows are returned:
A gap exists
We’ll dedicate a later part to FAL and gap resolution.
41. Apply Status With Broker
When we introduce Data Guard Broker later, the equivalent monitoring becomes:
DGMGRL
For example:
dgmgrl /
Then:
DGMGRL> SHOW DATABASE VERBOSE PRODDB_DR;
Broker exposes:
Transport Lag Apply Lag Apply Rate Transport Status Database Status
This will become our preferred management layer later in the Masterclass.
42. What an Expert Checks First
When someone says:
“The standby is behind.”
Don’t immediately restart MRP.
Ask:
1. Is redo being transported?
SELECT status,
error
FROM v$archive_dest
WHERE target='STANDBY';
2. Is RFS receiving?
SELECT process,
status
FROM v$managed_standby;
3. Is MRP running?
SELECT process,
status
FROM v$managed_standby
WHERE process LIKE 'MRP%';
4. Is there a gap?
SELECT * FROM v$archive_gap;
5. Is the standby simply overloaded?
Check:
CPU I/O redo apply rate storage latency
This is the difference between DBA troubleshooting and simply restarting processes.
43. Recommended Monitoring Script
Here’s a compact script worth keeping:
SET LINESIZE 220
PROMPT === DATABASE ROLE ===
SELECT database_role,
open_mode,
protection_mode,
protection_level
FROM v$database;
PROMPT === DATA GUARD STATUS ===
SELECT dest_id,
status,
target,
db_unique_name,
error
FROM v$archive_dest
WHERE target = 'STANDBY';
PROMPT === RECOVERY PROCESS ===
SELECT process,
status,
thread#,
sequence#
FROM v$managed_standby
ORDER BY process;
PROMPT === DATA GUARD LAG ===
SELECT name,
value,
unit,
time_computed
FROM v$dataguard_stats
WHERE name IN
(
'transport lag',
'apply lag',
'apply finish time'
);
PROMPT === ARCHIVE GAP ===
SELECT *
FROM v$archive_gap;
This is a good first-level health check.
44. A More Advanced Apply Check
For RAC:
SELECT
thread#,
MAX(sequence#) AS last_received
FROM v$archived_log
GROUP BY thread#
ORDER BY thread#;
And:
SELECT
thread#,
MAX(sequence#) AS last_applied
FROM v$archived_log
WHERE applied = 'YES'
GROUP BY thread#
ORDER BY thread#;
Then compare:
Thread 1: Received = 1255 Applied = 1255 Thread 2: Received = 1002 Applied = 1001
Thread 2 is behind by one sequence.
45. Real-Time Apply Best Practice
For our Oracle 19c production architecture:
Standby Redo Logs
+
LGWR transport
+
Real-Time Apply
is the recommended foundation for a low-latency Data Guard implementation.
Then select:
ASYNC
or:
SYNC
based on the required protection level and network architecture.
46. The Complete Architecture After Part 7
We now have:
PRIMARY RAC
┌────────────────────┐
│ │
PROD1 PROD2
THREAD 1 THREAD 2
│ │
└────────┬───────────┘
│
LGWR Transport
│
ASYNC / SYNC
│
Oracle Net
│
▼
┌──────────────┐
│ STANDBY RAC │
│ │
│ RFS │
│ ↓ │
│ SRL │
│ ↓ │
│ MRP0 │
│ ↓ │
│ Datafiles │
└──────────────┘
And the important metrics are:
Transport Lag Apply Lag Apply Rate Archive Gap
47. Part 7 — Final Checklist
Before moving on, you should be able to demonstrate all of these:
✓ Start managed recovery ✓ Stop managed recovery ✓ Identify MRP0 ✓ Identify RFS ✓ Explain transport vs apply ✓ Explain archived-log apply ✓ Explain Real-Time Apply ✓ Verify Real-Time Apply ✓ Verify transport lag ✓ Verify apply lag ✓ Check archive gaps ✓ Monitor RAC threads ✓ Check last received sequence ✓ Check last applied sequence ✓ Diagnose WAIT_FOR_LOG ✓ Test stopped MRP ✓ Restart MRP ✓ Understand Active Data Guard


