When Oracle reads a data block into the cache,
it opens a GCS resource to coordinate concurrent
access by multiple instances. Oracle coordinates
and converts the resource into different modes
and roles, depending on the following:
Thus, a resource is a concurrency control
mechanism on the data blocks. It is also called
a GCS resource.
In a stand-alone Oracle instance, various locks
are used to control data integrity and
concurrency. Similarly, the multi-instance RAC
architecture deals with cached data block mode
roles and the controlling access levels. The
cached data blocks acquire a global nature.
GCS resources comprise the concurrency control
mechanism on data blocks. They include enqueues
involving the transaction locks, table locks,
library cache locks, and the dictionary cache
locks. Global enqueue resources are normally
held for a very short time and then quickly
released. For example, the TX locks are acquired
whenever a transaction starts. They are released
immediately after the transaction commits or
rolls back. Figure 2.9 shows the main groups of
resources involved in the synchronization
process.
Figure 2.9:
Resources for Coordination
Now, the three main components - the global
cache service, global enqueue service, and the
global resource directory
- will be examined more closely.
Global Cache Service
The main function of the Global Cache Service (GCS)
is to track the status and location of the data
blocks. Status is the resource role and the
resource mode. The GCS is the main mechanism by
which cache coherency among the multiple caches
is maintained.
GCS maintains the modes for blocks in the global
role and is responsible for block transfers
between the instances. The LMS processes handle
the GCS messages and carry out the bulk of the
GCS processing. GCS resource coordination is
explained in detail in later sections.
Global Enqueue Service
The Global Enqueue Service (GES) tracks the status
of all Oracle enqueuing mechanisms. This
involves all non-cache fusion intra-instance
operations. The GES performs concurrency control
on dictionary cache locks, library cache locks,
and transactions. It performs this operation for
resources that are accessed by more than one
instance.
Enqueues
What exactly is an enqueue? Enqueues
are shared memory structures that serialize access
to the database resources. For example, when a
user updates a row and gets a row-level lock, a
TX enqueue is created for that user. If another
user subsequently attempts to update that same
row, that user's session will block or wait on
the enqueue that the initial user created. They
are sometimes referred to as positive waits.
In a single instance environment, enqueues are
local to the instance.
With RAC, the enqueues can be global to
the database. Enqueues
are comprised of transaction locks, DML locks, SCN
locks, and such.
Enqueues
are associated with a session or a transaction.
They are held longer than the latches, have finer granularity, more modes than the
latches, and protect more database resources.
For example, when a table lock is requested, the
request is assigned to an enqueue. Oracle can
use enqueues in any of three modes: null (N)
mode, shared (S) mode, or exclusive (X) mode.
The GES controls access to data files and
control files but not for the data blocks. GES
processing includes the coordination for
enqueues other than the data blocks. The
resources managed by the GES include the
following:
Transaction locks
– It is acquired in the exclusive mode when a
transaction initiates its first row level
change. The lock
is held until the transaction is committed or
rolled back.
Library Cache locks
- When a database object (such as a table, view,
procedure, function, package, package body,
trigger, index, cluster, or synonym) is
referenced during parsing or compiling of a SQL, DML
or DDL, PL/SQL, or Java statement, the process
parsing or compiling the statement acquires the
library cache lock in the correct mode.
Dictionary Cache Locks
- Global enqueues are used
in the cluster database mode. The data
dictionary structure is the same for all Oracle
instances in a cluster database as it is for
instances in a single-instance database.
However, in real application clusters, Oracle
synchronizes all the dictionary caches
throughout the cluster. Real application
clusters use latches
to do this, just as in the case of a
single-instance Oracle database.
Table locks
– These
are the GES locks that protect the entire
table(s). A transaction acquires a table
lock when a table is modified. A table lock can
be held in any of several modes: null
(N), row share
(RS), row exclusive
(RX), share lock
(S), share row exclusive (SRX), or exclusive
(X).