Finding and Fixing RAC Global Cache Waits on an Exadata VM Cluster in the Cloud
An application that ran on a single instance is moved to a two-node RAC database on an Exadata VM cluster, for example in Oracle Database@Azure. CPU is lower, storage is faster, and yet some transactions are slower than before. The top wait events now start with "gc": gc buffer busy acquire, gc current block busy, gc cr block 2-way. These are global cache waits, the time sessions spend waiting for a block that the other instance holds.
Global cache traffic is not a fault; it is how RAC keeps both instances consistent. On Exadata the interconnect is very fast, so a long gc wait almost always points to contention in the application's design rather than to the network. This post measures the problem, finds the objects and statements behind it, and fixes the common causes.
The Use Case
An order-entry application moved from a single-instance database to a two-node RAC database on an Exadata VM cluster in Oracle Database@Azure. Users report that order submission takes twice as long at peak. AWR shows "gc buffer busy acquire" and "gc current block busy" among the top five events.
Environment used in this runbook
Database: Oracle Database 19c (19.24), RAC container database SALESCDB with PDB SALESPDB
Platform: Exadata Database Service on Oracle Database@Azure, two-node VM cluster
Instances: SALESCDB1 and SALESCDB2
Application service: sales_app, currently running on both instances
Licence: RAC is included with Exadata Database Service; the AWR and ASH queries need the Diagnostics Pack
How Global Cache Waits Arise
Every block has a master. When a session needs a block that is in the other instance's buffer cache, it asks the holder, and the block is shipped over the interconnect. A 2-way wait means two instances were involved, a 3-way wait three.
Current versus consistent read. "gc current" waits are for the latest version of a block, needed for changes. "gc cr" waits are for a consistent-read version, needed for queries.
Busy waits mean contention. "gc buffer busy" and "gc current block busy" mean the block was in use or being changed on the other side, so the request had to wait. These are the waits that application design causes and changes can fix.
Hot spots are the usual cause. Sequences without enough caching, right-growing indexes on sequence values, small hot tables updated from both instances, and the same batch running on both nodes at once.
Step 1: Check the Cluster and the Interconnect
Confirm both instances are open and that the interconnect is the private network you expect. On Exadata Database Service the interconnect is the Exadata RDMA network, managed by the service.
SQL |
COLUMN name FORMAT A10 COLUMN ip_address FORMAT A16
SELECT inst_id, instance_name, host_name, status FROM gv$instance ORDER BY inst_id;
SELECT inst_id, name, ip_address, is_public FROM gv$cluster_interconnects ORDER BY inst_id; |
Expected output |
INST_ID INSTANCE_NAME HOST_NAME STATUS
---------- ---------------- ------------------------------ ------------
1 SALESCDB1 salesaz-node1 OPEN
2 SALESCDB2 salesaz-node2 OPEN
INST_ID NAME IP_ADDRESS IS_
---------- ---------- ---------------- ---
1 clib0 192.168.132.2 NO
2 clib0 192.168.132.4 NOWhat to expect: Both instances open, and each using a private interface (IS_PUBLIC NO) for the interconnect. If the interconnect ever shows a public address, global cache traffic is on the wrong network and that alone explains slow gc waits; on Exadata this should never be the case.
Step 2: Measure How Much Time Goes to the Global Cache
Before chasing individual events, find out how much of the database's time is spent in gc waits. If it is a few percent, look elsewhere; if it is a quarter of DB time, this is the problem.
SQL |
COLUMN event FORMAT A30
SELECT event, SUM(total_waits) AS waits, ROUND(SUM(time_waited_micro) / 1e6) AS seconds, ROUND(SUM(time_waited_micro) / NULLIF(SUM(total_waits), 0) / 1000, 2) AS avg_ms FROM gv$system_event WHERE event LIKE 'gc%' AND wait_class <> 'Idle' GROUP BY event ORDER BY seconds DESC FETCH FIRST 5 ROWS ONLY; |
Expected output |
EVENT WAITS SECONDS AVG_MS
------------------------------ ---------- ---------- ----------
gc buffer busy acquire 4120441 38210 9.27
gc current block busy 1883027 21477 11.41
gc cr block 2-way 24830115 6455 .26
gc current block 2-way 19077432 5150 .27
gc cr grant 2-way 8812004 1146 .13How to read it: The plain 2-way transfers average about a quarter of a millisecond, which is what Exadata's interconnect should deliver: the network is fine. The two busy events average 9 to 11 ms and account for most of the gc time. That pattern means contention on specific blocks, not a slow network, so the next step is to find which blocks.
Step 3: Check Block Transfer Times per Instance
The receive-time statistics give the average time to receive a block over the interconnect. They confirm, per instance, that the transfer itself is fast.
SQL |
SELECT inst_id, ROUND(10 * SUM(CASE name WHEN 'gc cr block receive time' THEN value END) / NULLIF(SUM(CASE name WHEN 'gc cr blocks received' THEN value END), 0), 2) AS cr_ms, ROUND(10 * SUM(CASE name WHEN 'gc current block receive time' THEN value END) / NULLIF(SUM(CASE name WHEN 'gc current blocks received' THEN value END), 0), 2) AS current_ms FROM gv$sysstat WHERE name IN ('gc cr block receive time', 'gc cr blocks received', 'gc current block receive time', 'gc current blocks received') GROUP BY inst_id ORDER BY inst_id; |
Expected output |
INST_ID CR_MS CURRENT_MS
---------- ---------- ----------
1 .21 .24
2 .22 .25What to expect: The receive times are kept in centiseconds, so multiplying by 10 gives milliseconds. Both instances receive blocks in about 0.2 ms, which rules out the interconnect and the remote instance's CPU as the cause. If these values were several milliseconds, check CPU saturation on the sending instance first, because the LMS processes that ship blocks need CPU to respond.
Step 4: Find the Objects Behind the Busy Waits
ASH records, for each sampled session, the event and the object it was waiting on. Group the gc busy waits by object to find the hot spots.
SQL |
COLUMN owner FORMAT A8 COLUMN object_name FORMAT A24 COLUMN object_type FORMAT A12 COLUMN event FORMAT A26
SELECT o.owner, o.object_name, o.object_type, a.event, COUNT(*) AS samples FROM gv$active_session_history a JOIN dba_objects o ON o.object_id = a.current_obj# WHERE a.event IN ('gc buffer busy acquire', 'gc buffer busy release', 'gc current block busy') AND a.sample_time > SYSDATE - 1/24 GROUP BY o.owner, o.object_name, o.object_type, a.event ORDER BY samples DESC FETCH FIRST 5 ROWS ONLY; |
Expected output |
OWNER OBJECT_NAME OBJECT_TYPE EVENT SAMPLES
-------- ------------------------ ------------ -------------------------- ----------
SALES ORDERS_PK INDEX gc buffer busy acquire 3912
SALES ORDER_LINES_PK INDEX gc buffer busy acquire 2477
SALES ORDERS TABLE gc current block busy 911
SYS SEQ$ TABLE gc current block busy 604
SALES ORDER_STATUS_LOG TABLE gc buffer busy acquire 388How to read it: The top two are the primary key indexes of ORDERS and ORDER_LINES, both filled from sequences: every new order inserts into the same rightmost index block from both instances. SYS.SEQ$ appearing means sequences are being updated in the dictionary too often, which points to a small sequence cache. ORDER_STATUS_LOG is a small, heavily updated table.
Step 5: Find the Statements and Sequences Involved
Now link the hot objects to SQL and check the sequences that feed those primary keys.
SQL |
COLUMN sequence_name FORMAT A18
SELECT a.sql_id, COUNT(*) AS samples, SUBSTR(s.sql_text, 1, 50) AS sql_text FROM gv$active_session_history a JOIN gv$sqlarea s ON s.sql_id = a.sql_id AND s.inst_id = a.inst_id WHERE a.event LIKE 'gc%busy%' AND a.sample_time > SYSDATE - 1/24 GROUP BY a.sql_id, SUBSTR(s.sql_text, 1, 50) ORDER BY samples DESC FETCH FIRST 3 ROWS ONLY;
SELECT sequence_name, cache_size, order_flag, scale_flag FROM dba_sequences WHERE sequence_owner = 'SALES'; |
Expected output |
SQL_ID SAMPLES SQL_TEXT
------------- ---------- --------------------------------------------------
7f2k9qd1x8m4c 4102 INSERT INTO SALES.ORDERS (ORDER_ID, CUSTOMER_ID, O
b31nq0v6a2tzh 2618 INSERT INTO SALES.ORDER_LINES (ORDER_ID, LINE_NO,
0d9w4xh3pq7ru 602 UPDATE SALES.ORDER_STATUS_LOG SET LAST_STATUS = :B
SEQUENCE_NAME CACHE_SIZE O S
------------------ ---------- - -
ORDER_SEQ 20 Y N
ORDER_LINE_SEQ 20 Y NWhat to expect: The order inserts dominate, and both sequences have the default cache of 20 with ORDER set. ORDER forces the two instances to coordinate on every NEXTVAL, and a cache of 20 sends them to SEQ$ constantly. Together with a primary key index on the sequence value, this is the classic RAC hot spot.
Step 6: Fix the Sequences
Unless the application really needs numbers in strict order across instances (it rarely does: gaps and out-of-order values are normal with caching), remove ORDER and raise the cache. Since 18c, scalable sequences go further: they prefix each value with the instance and session, so concurrent inserts land in different index blocks.
SQL |
ALTER SEQUENCE sales.order_seq CACHE 1000 NOORDER; ALTER SEQUENCE sales.order_line_seq CACHE 1000 NOORDER;
-- Optional: make the sequence scalable so inserts spread across the index ALTER SEQUENCE sales.order_seq SCALE EXTEND;
SELECT sequence_name, cache_size, order_flag, scale_flag FROM dba_sequences WHERE sequence_owner = 'SALES'; |
Expected output |
Sequence altered.
Sequence altered.
Sequence altered.
SEQUENCE_NAME CACHE_SIZE O S
------------------ ---------- - -
ORDER_SEQ 1000 N Y
ORDER_LINE_SEQ 1000 N NWhat this does: Each instance now takes a block of 1,000 numbers at a time without coordinating, which removes the SEQ$ contention. The scalable ORDER_SEQ adds an instance and session prefix to every value, so inserts from different sessions go to different leaf blocks of ORDERS_PK. Check first that the key column is large enough: scalable values are longer, and SCALE EXTEND adds digits to the generated numbers.
Tip: If changing the sequence is not possible, a reverse key index or a hash-partitioned index on the key also spreads the inserts. A reverse key index stops range scans on the key, and a hash-partitioned index needs the Partitioning option, so weigh both before choosing.
Step 7: Give the Batch Its Own Instance
The status-log updates come from a batch job that runs on both instances at once, so the same few blocks of ORDER_STATUS_LOG move back and forth. Run the batch through its own service that is preferred on one instance only, so those blocks stay in one buffer cache.
Shell |
srvctl add service -db SALESCDB_AZ -pdb SALESPDB \ -service sales_batch.example.internal \ -preferred SALESCDB2 -available SALESCDB1
srvctl start service -db SALESCDB_AZ -service sales_batch.example.internal srvctl status service -db SALESCDB_AZ -service sales_batch.example.internal |
Expected output |
Service sales_batch.example.internal is running on instance(s) SALESCDB2What this does: The batch connects through sales_batch, which runs only on SALESCDB2 and moves to SALESCDB1 only if SALESCDB2 fails. All batch updates to ORDER_STATUS_LOG now happen in one instance, and the online application keeps using both instances through sales_app. Point the batch scheduler's connect string at the new service.
Step 8: Prove the Improvement
Compare the gc waits for the same peak hour before and after the changes. AWR keeps the per-snapshot totals, so the comparison is exact.
SQL |
COLUMN event_name FORMAT A26
SELECT TO_CHAR(s.begin_interval_time, 'MM-DD HH24:MI') AS snap_start, e.event_name, ROUND((e.time_waited_micro - LAG(e.time_waited_micro) OVER (PARTITION BY e.instance_number, e.event_name ORDER BY e.snap_id)) / 1e6) AS seconds FROM dba_hist_system_event e JOIN dba_hist_snapshot s ON s.snap_id = e.snap_id AND s.instance_number = e.instance_number WHERE e.event_name IN ('gc buffer busy acquire', 'gc current block busy') AND e.instance_number = 1 AND s.begin_interval_time > SYSDATE - 2 ORDER BY e.snap_id, e.event_name FETCH FIRST 4 ROWS ONLY; |
Expected output |
SNAP_START EVENT_NAME SECONDS
----------- -------------------------- ----------
11-04 10:00 gc buffer busy acquire 7922
11-04 10:00 gc current block busy 4311
11-05 10:00 gc buffer busy acquire 408
11-05 10:00 gc current block busy 277What to expect: For the same 10:00 peak, gc buffer busy acquire drops from about 7,900 seconds to about 400, and gc current block busy from about 4,300 to under 300. Confirm with the application team that order submission times are back to normal, and keep the AWR report pair as evidence for the change record.
Summary
Global cache waits on an Exadata VM cluster are rarely a network problem: the interconnect delivers blocks in a fraction of a millisecond. Check the interconnect and measure how much time goes to gc events, then separate the plain transfers from the busy waits. Use ASH to find the hot objects and statements, which are usually sequence-filled primary key indexes, sequences with a small cache or ORDER, and small tables updated from both instances. Raise the sequence cache and drop ORDER, consider scalable sequences, give batch work its own single-instance service, and prove the result with AWR.
Comments