Locks are applied to both compound and simple objects. The classic example of a compound object and its component parts is a table and its rows. A cache buffer is an example of a simple object. Simple objects may only be locked in the following modes:
- Exclusive
If a session needs to modify a simple object, then an exclusive lock is required on the resource to prevent any concurrent access.
- Shared
If a session needs to inspect a simple object, then a shared lock on the resource is sufficient to ensure that the data structure will not be modified by another session, while allowing concurrent shared access.
- Null
If a session has some information cached about an object, then a null mode lock may be held as a placeholder, even when the resource is not actively being used. A null mode lock does not inhibit any concurrent access, but if the resource is invalidated, the null mode lock acts as a trigger for the session to invalidate its private cached information. There is an important difference between holding a null mode lock, and not holding a lock at all.
In addition to the modes above, compound objects may also be locked in the following modes:
- Sub-shared
If a session needs shared access to part of a compound object, then a shared lock on the entire compound resource would be unduly restrictive, because it would prevent exclusive access to other parts of the compound resource. In such cases, a sub-shared lock is used instead.
- Sub-exclusive
If a session needs exclusive access to part of a compound resource, then a sub-exclusive lock is sufficiently restrictive.
- Shared-sub-exclusive
This lock mode is used when a session needs exclusive access to part of a compound resource and shared access to the entire compound resource at the same time.
These lock modes apply both to local locks and to the instance locks that are used between parallel server instances. However, different terminology is used for instance locks. Table 4.1 shows the corresponding lock mode names together with the symbolic and numeric representations used in dumps and wait parameter values.
It is important to understand which lock modes are compatible with one another. Table 4.2 shows the complete lock mode compatibility matrix.
Get Oracle Internals: An Introduction now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.