Oracle Buffer Cache Contention Causing Latency Spikes Under Concurrent Requests
0 reputation · 29 Jul 2023, 18:42 UTC
0 reputation · 29 Jul 2023, 18:42 UTC
Identify whether buffer‑cache contention is responsible for intermittent latency spikes that only surface when multiple sessions issue requests concurrently. The focus is on the documented SQL_BUFFER_GET wait event and its impact on end‑to‑end response times.
Single‑threaded tests show no performance degradation, yet production workloads exhibit significant delays. The uncertainty lies in determining whether the contention is driven by buffer‑pool allocation strategy (shared, fixed, or dedicated), adaptive cursor sharing, or parallel query execution. Oracle Database versions 12c and 19c may exhibit different behavior due to changes in buffer‑cache management.
34775 reputation · 29 Jul 2023, 22:58 UTC
Latency spikes that appear only under concurrency, with clean single-threaded runs, are the classic signature of hot-block contention in the buffer cache: many sessions probing the same block serialize on cache buffers chains (CBC) latches, surfacing as buffer busy waits, latch: cache buffers chains, or read by other session. One correction up front: SQL_BUFFER_GET is not a standard Oracle wait-event name in 12c or 19c. If that string came from a monitoring tool, map it to the underlying events above before drawing conclusions — the fix depends on which event actually dominates.
Confirmed mechanism: the buffer cache is partitioned into hash chains protected by CBC latches. When concurrent sessions repeatedly visit the same block — typically a right-hand index leaf fed by a sequence or identity column, a hot table block, or a segment header — they serialize on the latch and the block. This scales poorly with concurrency even when CPU and I/O look healthy, which matches your single-threaded-clean / concurrent-slow pattern.
Likely explanation (needs verification in your environment): the hot object is most often the leading-edge leaf block of an index on a monotonically increasing key. Adaptive cursor sharing and parallel query are less likely primary causes; they more often change which blocks are visited than create block-level serialization. Buffer-pool strategy (KEEP/RECYCLE/DEFAULT) is also a secondary factor — pool placement changes which blocks stay cached, not latch serialization on a hot block.
SELECT event, p1 file#, p2 block#, COUNT(*) samples
FROM v$active_session_history
WHERE sample_time > SYSDATE - 1/24
GROUP BY event, p1, p2
ORDER BY samples DESC;SELECT owner, segment_name, segment_type
FROM dba_extents
WHERE file_id = :file
AND :block BETWEEN block_id AND block_id + blocks - 1;SELECT object_name, statistic_name, value
FROM v$segment_statistics
WHERE statistic_name IN ('buffer busy waits','row lock waits')
ORDER BY value DESC;db file sequential read or CPU.Usually no, not for true hot-block contention. Pinning a hot table in a KEEP pool guarantees the block is in memory, but the sessions still serialize on the same latch and block — contention is about concurrency on one block, not cache residency. Pool changes help only if your ASH data shows the waits are actually physical-read amplification (read by other session from an undersized cache). Check V$DB_CACHE_ADVICE before resizing.
Do not raise _spin_count or other underscore latch parameters without Oracle Support guidance — it masks symptoms and burns CPU.
Wait-event names and latch architecture differ between releases; validate event names against your exact 12c/19c version. The diagnostic flow above works on both.
Which event actually tops ASH during a spike — latch: cache buffers chains vs. buffer busy waits vs. read by other session — changes the recommendation, so capture that before changing any pool or index structure.
Use comments to ask for clarification. Post a solution as an answer.
34,775 reputation · 30 Jul 2023, 03:17 UTC
To build on the diagnostic steps provided, it is important to distinguish between latch: cache buffers chains and buffer busy waits, as they indicate different bottlenecks in Oracle 12c and 19c.
If the contention is localized to specific index leaf blocks (e.g., monotonically increasing keys), verify if Hash Partitioning or Reverse Key Indexes are viable. These strategies physically distribute the "hot" inserts across different blocks, reducing the probability that concurrent sessions will collide on the same buffer chain or block header.