Lock Management with Workspace Manager

The script content on this page is for navigation purposes only and does not alter the content in any way.

In addition to locks provided by regular Oracle AI Database transactions, Workspace Manager provides two types of version locks. These locks are primarily intended to eliminate row conflicts between a parent workspace and a child workspace. You can enable locking for the workspace, the session, or specified rows, or some combination:

Workspace or session locks persist for the duration of the workspace or session, respectively, or until the workspace is merged or rolled back.

Like database locks, Workspace Manager locks can be exclusive or shared:

Workspace-exclusive locks and version-exclusive locks are forms of exclusive locking that control which users can and cannot change data values, but (unlike exclusive locking) they do not prevent conflicts from occurring. Workspace-exclusive locks lock rows such that only the user that set the lock can change the values in the current workspace; however, other users in other workspaces can change the values. Version-exclusive locks lock rows such that only the user that set the lock can change the values (and that user can be in any workspace); no other users (in any workspace) can change the values.

The following table indicates, for a row locked by a specific user in a specific workspace, which users in which workspaces can and cannot modify the row. For example, the first two entries in this table mean that when a shared (S) lock is placed on a row, any user in the workspace in which the row was locked can modify the row, but any user in a workspace different from the workspace in which the row was locked cannot modify the row.

Lock Mode User Workspace of User Can Modify?
Shared (S) Any user Workspace in which row was locked Yes
Shared (S) Any user Different from workspace in which row was locked No
Exclusive (E) User that locked the row Workspace in which row was locked Yes
Exclusive (E) User that locked the row Different from workspace in which row was locked No
Exclusive (E) Different user from the one that locked the row Any workspace No
Workspace Exclusive (WE) User that locked the row Any workspace Yes
Workspace Exclusive (WE) Different user from the one that locked the row Different from workspace in which row was locked Yes
Workspace Exclusive (WE) Different user from the one that locked the row Workspace in which row was locked No
Version Exclusive (VE) User that locked the row Any workspace Yes
Version Exclusive (VE) Different user from the one that locked the row Any workspace No

Locking a row does not affect workspace merge, refresh, and rollback operations, but it affects what can be done with the row after these operations. You can control these workspace operations by using workspace privileges, calling the FreezeWorkspace procedure, and checking the workspace xxx_LOCK view or views (described in xxx_LOCK Views) before performing the operations.

The xxx_LOCK static data dictionary views (described in xxx_LOCK Views) contain information about locks in each version-enabled table.

For information about Workspace Manager locking with DML operations on tables with referential integrity constraints, see Locking with DML Operations on Tables with Referential Integrity Constraints.

Exclusive Locking and Row Versions

The timing of an exclusive lock with respect to an update operation in a child workspace can affect which version, if any, of the row can be updated in a parent workspace. For example, when a table is version-enabled in the LIVE workspace, each original row is assigned version 0. Assume that a workspace named W1 is created as a child of the LIVE workspace. When workspace W1 is created, the following things happen:

Using this example, if a user in workspace W1 places an exclusive lock on a row before it updates the row, only that user in workspace W1 can update the row. Specifically:

However, if the row is not locked in the LIVE workspace and if a user in workspace W1 updates the row and then places an exclusive lock on the row, a user in the LIVE workspace can update the row. Specifically:

In other words, an exclusive lock after an update does not lock previous versions of the row in workspaces above the locking workspace in the workspace tree or in other branches of the workspace tree.

Locks Taken for Workspace Manager Operations

Workspace Manager automatically takes locks when performing certain operations related to DBMS_WM subprograms. Workspace Manager checks:

If the required lock cannot be requested or if the workspace is frozen in an incompatible mode, an error is generated.

The following table lists Workspace Manager operations and the incompatible freeze modes for certain types of workspaces (parent workspace, current workspace, intermediate multiparent workspace) to be locked for the operation. In the table:

For CompressWorkspace and CompressWorkspaceTree, when the current version within any affected workspace is contained in a compressible range with at least one other version, an attempt is made to acquire a Shared Sub eXclusive lock on that workspace. If it fails to be acquired, no error is raised, but the current version is not compressed.

When the MergeTable and MergeWorkspace procedures are executed with the create_savepoint parameter set to true, the parent workspace lock taken is an SSX (Shared Sub eXclusive) lock.

Operation Parent Workspace Incompatible Freeze Modes Current Workspace Incompatible Freeze Modes Intermediate Multiparent Workspace Incompatible Freeze Modes
Any DML None N/A Shared

DEFERRED_REMOVAL,

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION,

WM_ONLY

None N/A
BeginResolve None N/A Shared Sub eXclusive DEFERRED_REMOVAL None N/A
ChangeWorkspaceType Shared N/A Shared Sub eXclusive

DEFERRED_REMOVAL,

NO_ACCESS,

ONEWRITER,

ONEWRITER_SESSION,

READ_ONLY

Exclusive

NO_ACCESS,

ONEWRITER,

ONEWRITER_SESSION,

READ_ONLY

CommitResolve None N/A Shared Sub eXclusive DEFERRED_REMOVAL None N/A
CompressWorkspace None N/A Shared

DEFERRED_REMOVAL,

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

None N/A
CompressWorkspaceTree None N/A Shared

DEFERRED_REMOVAL,

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

None N/A
CopyWorkspace None N/A Shared

DEFERRED_REMOVAL,

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

None N/A
CreateSavepoint None N/A Shared (Shared Sub eXclusive when new version must be created)

DEFERRED_REMOVAL,

NO_ACCESS

None N/A
CreateWorkspace None N/A Shared (Shared Sub eXclusive when new version must be created)

DEFERRED_REMOVAL,

NO_ACCESS

None N/A
DeleteSavepoint None N/A Exclusive +

DEFERRED_REMOVAL,

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

None N/A
Export None N/A Shared

DEFERRED_REMOVAL,

NO_ACCESS

None N/A
FreezeWorkspace None N/A Shared Sub eXclusive DEFERRED_REMOVAL None N/A
GotoWorkspace None N/A Sub Shared

DEFERRED_REMOVAL,

NO_ACCESSFoot 1

None N/A
Import None N/A Shared Sub eXclusive

DEFERRED_REMOVAL,

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

None N/A
LockRows None N/A Shared

DEFERRED_REMOVAL,

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

None N/A
MergeTable (remove_data=>false) Shared

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

Sub eXclusive

DEFERRED_REMOVAL,

NO_ACCESS

Sub eXclusive NO_ACCESS
MergeTable (remove_data=>true) Shared

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

Sub eXclusive

DEFERRED_REMOVAL,

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

Sub eXclusive

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

MergeWorkspace (remove_workspace=>false) Shared(1)

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

Shared Sub eXclusive

DEFERRED_REMOVAL,

NO_ACCESS

Exclusive NO_ACCESS
MergeWorkspace (remove_workspace=>true) Shared(1)

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

Exclusive +

DEFERRED_REMOVAL,

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

Exclusive +

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

PurgeTable None N/A None; table locked in Exclusive mode None None N/A
RefreshTable Shared(1) NO_ACCESS Shared

DEFERRED_REMOVAL,

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

Shared

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

RefreshWorkspace Shared(1) NO_ACCESS Shared

DEFERRED_REMOVAL,

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

Exclusive

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

RemoveDeferredWorkspaces None N/A Exclusive + N/A None N/A
RemoveWorkspace Shared(1) N/A Exclusive +

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

Shared N/A
RenameSavepoint None N/A Exclusive +

DEFERRED_REMOVAL

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

None N/A
RenameWorkspace None N/A Exclusive +

DEFERRED_REMOVAL

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

None N/A
RollbackResolve None N/A Shared Sub eXclusive DEFERRED_REMOVAL None N/A
RollbackTable None N/A Shared Sub eXclusive

DEFERRED_REMOVAL,

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

None N/A
RollbackWorkspace None N/A Shared Sub eXclusive

DEFERRED_REMOVAL,

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

None N/A
SetConflictWorkspace None NO_ACCESS Sub Shared

DEFERRED_REMOVAL,

NO_ACCESS

None N/A
SetDiffVersions None N/A Sub Shared

DEFERRED_REMOVAL,

NO_ACCESS

None N/A
SetMultiWorkspaces None N/A Sub Shared

DEFERRED_REMOVAL,

NO_ACCESS

None N/A
SetWorkspaceLockModeOFF None N/A Shared Sub eXclusive

DEFERRED_REMOVAL,

NO_ACCESS

None N/A
SetWorkspaceLockModeON None N/A Shared Sub eXclusive

DEFERRED_REMOVAL,

NO_ACCESS

None N/A
UnfreezeWorkspace None N/A Shared Sub eXclusive DEFERRED_REMOVAL None N/A
UnlockRows None N/A Shared

DEFERRED_REMOVAL,

NO_ACCESS,

READ_ONLY,

ONEWRITER,

ONEWRITER_SESSION

None N/A

Footnote 1

The LIVE workspace cannot be frozen in NO_ACCESS mode.