Concurrency and Consistency
Database systems provide data concurrency by
enabling multiple users to access the same data
without compromising data consistency. Data
consistency means that each user sees a
consistent view of the data, including the
visible changes made by the users’ own
transactions, as well as the transactions of
other users. Oracle automatically supplies a
query with read-consistent data so that all data
that the query sees comes from a single point in
time (statement-level read consistency).
Optionally, Oracle can provide read consistency
to all queries in a transaction
(transaction-level read consistency). Oracle
maintains undo records to manage such consistent
views. The undo segments contain the old data
values that have been changed by uncommitted or
recently committed transactions.
In a RAC system, users can connect with multiple
instances to run database queries. Typically,
users will be connected to different nodes but
access the same set of data or data blocks. This
situation demands that the data consistency,
formerly confined to a single instance, be
effectively extended to multiple instances.
Therefore, buffer cache coherence from multiple
instances must be maintained. Instances require
three main types of concurrency:
-
Concurrent reads on multiple instances –
When users on two different instances need
to read the same set of blocks
-
Concurrent reads and writes on different
instances - A user intends to read a data
block that was recently modified, and the
read can be for the current version of the
block or for a read-consistent previous
version
-
Concurrent writes on different instances –
When the same set of data blocks are
modified by different users on different
instances
Cache Coherency
Whether the database is a single-instance
stand-alone system or a multi-instance RAC
system, maintaining data consistency is a
fundamental requirement. If data blocks are
already available in the local buffer cache,
then they are immediately available for user
processes. Also, if they are available in
another instance within the cluster, they will
be transferred into the local buffer cache.
Maintaining the consistency of data blocks in
the buffer caches of multiple instances is
called cache coherency.
The Global Cache Service (GCS), implemented by a
set of Oracle processes, requires an instance to
acquire cluster-wide data before a block can be
modified or read. In this way, cache coherency
is ensured and maintained. This resource can be
explained in terms of enqueue and/or lock.
GCS synchronizes global cache access, allowing
only one instance at a time to modify the block.
Thus, cache coherency is maintained in the RAC
system by coordinating buffer caches located on
separate instances. GCS ensures that the data
blocks cached in different cache buffers are
maintained globally. That is why some people
prefer to call cache fusion a diskless cache
coherency mechanism. This is true in a sense,
because the previous Oracle parallel server
version (OPS) utilized forced disk writes to
maintain cache coherency.
Global Cache Service
GCS is the main controlling process for cache
fusion. It tracks the location and status, i.e.
mode and role, of the data blocks as well as the
access privileges of the various instances. GCS
guarantees data integrity by employing global
access levels. It maintains block modes for data
blocks in the global role. It is also
responsible for block transfers between
instances. As shown in Figure 2.8, upon a
request from an instance, GCS organizes the
block shipping and the appropriate lock mode
conversions. Various background processes, such
as global cache service processes (LMSn)
and the global enqueues service daemon (LMD),
implement the global cache service.
Figure 2.8:
Message/Resource Exchange Controlled by GCS
Before going further into a detailed examination
of the cache fusion mechanism and how GCS
operations are performed in different scenarios,
the next section will take a look at basic SGA
structures and locking concepts.