Hitachi

Hitachi Advanced Database Setup and Operation Guide


2.10.1 Lock modes

The following describes the lock modes provided by HADB. The following also describes whether two competing transactions can run concurrently depending on the combination of lock modes.

Organization of this subsection

(1) Lock modes

Several lock modes are available on the HADB server.

(2) Relationship of concurrent execution between lock modes (behavior of transactions competing for locked resources)

When multiple transactions attempt to reserve the same locked resource, they compete against each other for the locked resource. When competition of two transactions occurs, the combination of the lock modes between the transactions that earlier and later attempted to reserve the resource will determine whether the transactions can run concurrently.

The following table shows whether two transactions that compete for the same locked resource can run concurrently depending on the combination of lock modes.

Table 2‒12: Relationship between the lock modes of competing transaction

Lock mode of the earlier transaction (T1)

Lock mode of the later transaction (T2)

SR

SU

PU

EX

Shared retrieval mode (SR)

T1/T2

T1/T2

T1/T2

T1

Shared update mode (SU)

T1/T2

T1/T2

T1

T1

Protected update mode (PU)

T1/T2

T1

T1

T1

Exclusive mode (EX)

T1

T1

T1

T1

Legend:

T1/T2: Both the earlier and later transactions can run concurrently.

T1: Only the earlier transaction can run.

In the preceding table, if the relationship between lock modes is T1, the later transaction cannot reserve the locked resource. Therefore, the later transaction will take either of the following actions:

For details, see 2.10.4 Locked resources that are reserved and their lock modes.

#

While a transaction waits for a locked resource to be freed, if the following phenomenon occurs on a locked resource that the transaction has already reserved, the transaction will result in an error:

  • A transition of the lock mode arose for the reserved locked resource, but the lock mode could not be changed because conflict with another transaction occurred.

Note, however, that in the following cases, an error does not occur as an extension of the processing that archives a chunk by using the adbarchivechunk command. In these cases, the transaction will wait until the transition of the lock mode succeeds.

  • The lock mode is changed from shared retrieval mode (SR) to exclusive mode (EX) when the pre-processing table has been locked.

  • The lock mode is changed from protected update mode (PU) to exclusive mode (EX) when the processing-target table has been locked.

(3) Transition of the lock mode

If a resource is locked twice successively in different lock modes within a transaction, the lock mode will change as shown in the following table.

Table 2‒13: Transition of the lock mode

Lock mode used first

Lock mode used next

SR

SU

PU

EX

Shared retrieval mode (SR)

--

Changes to SU

Changes to PU

Changes to EX#1, #2

Shared update mode (SU)

--

--

Changes to PU

Changes to EX#2

Protected update mode (PU)

--

--

--

Changes to EX#2

Exclusive mode (EX)

Changes to SR#3

--

Changes to PU#4

--

Legend:

--: The mode does not change.

#1

The lock mode changes to exclusive mode (EX) when the following locked resources are reserved as an extension of processing of an ALTER VIEW statement. In other cases, an error occurs when reserving the locked resources.

  • Pre-processing table

#2

The lock mode changes to exclusive mode (EX) when the following locked resources are reserved as an extension of the adbarchivechunk command processing. In other cases, an error occurs when a locked resource is reserved.

  • Pre-processing table

  • DB area (processing that stores the processing-target table and indexes)

  • Processing-target table

#3

The lock mode changes to shared retrieval mode (SR) when the following locked resources are reserved as an extension of the adbarchivechunk command processing. In other cases, the lock mode does not change.

  • Pre-processing table

  • DB area (processing that stores the processing-target table and indexes)

#4

The lock mode changes to protected update mode (PU) when the following locked resource is reserved as an extension of the adbarchivechunk command processing. In other cases, the lock mode does not change.

  • Processing-target table