Lock Management

In GaussDB(DWS), concurrent transactions may cause single-node deadlocks or distributed deadlocks due to resource competition. This section describes parameters used for managing transaction lock mechanisms.

deadlock_timeout

Parameter description: Specifies the time, in milliseconds, to wait on a lock before checking whether there is a deadlock condition. When the applied lock exceeds the preset value, the system will check whether a deadlock occurs.

Type: SUSET

Value range: an integer ranging from 1 to 2147483647. The unit is millisecond (ms).

Default value: 1s

ddl_lock_timeout

Parameter description: Indicates the number of seconds a DDL command should wait for the locks to become available. If the time spent in waiting for a lock exceeds the specified time, an error is reported. This parameter is supported only by clusters of version 8.1.3.200 or later.

Type: SUSET

Value range: an integer ranging from 0 to INT_MAX. The unit is millisecond (ms).

Default value: 0

This parameter has a higher priority than lockwait_timeout and takes effect only for AccessExclusiveLock.

ddl_select_concurrent_mode

Parameter description: Specifies the concurrency mode of DDL and SELECT statements. This parameter is supported only by clusters of version 8.1.3.320, 8.2.1, or later.

Type: SUSET

Value range: a string

Default value: none

  • To reserve time for the SELECT statement to respond to signals, if the value of ddl_lock_timeout is less than 1 second in the current version, 1 second is used.
  • Concurrency is not supported when there are conflicts with locks of higher levels (more than one level). For example, autoanalyze is triggered by SELECT when autoanalyze_mode is set to normal.
  • This parameter allows for SELECT statements in either a single statement or a transaction block. However, in other versions, it only supports SELECT statements in a single statement. For concurrent SELECT operations in a single statement or transaction block, learn more information in the description of parameter enable_cancel_select_in_txnblock.
  • Values other than none can be used together. For example, if this parameter is set to truncate, exchange, the TRUNCATE and EXCHANGE statements are blocked by the SELECT statement. The SELECT statement is interrupted and executed first.

enable_cancel_select_in_txnblock

Parameter description: Specifies whether the SELECT statement in a transaction block can be interrupted. This parameter is supported only by clusters of version 8.2.1, 9.1.0.200, or later.

Type: USERSET

Value range: Boolean

Default value: on

  • This parameter controls whether the SELECT statement in a transaction block can be interrupted by the DDL operation specified in ddl_select_concurrent_mode.
  • The ddl_select_concurrent_mode parameter controls DDL statements such as TRUNCATE and EXCHANGE, and the enable_cancel_select_in_txnblock parameter controls SELECT statements.

lockwait_timeout

Parameter description: Specifies the longest time to wait before a single lock times out. If the time you wait before acquiring a lock exceeds the specified time, an error is reported.

Type: SUSET

Value range: an integer ranging from 0 to INT_MAX. The unit is millisecond (ms).

Default value: 20 min

update_lockwait_timeout

Parameter description: sets the maximum duration that a lock waits for concurrent updates on a row to complete when the concurrent update feature is enabled. If the time you wait before acquiring a lock exceeds the specified time, an error is reported.

Type: SUSET

Value range: an integer ranging from 0 to INT_MAX. The unit is millisecond (ms).

Default value: 2min

partition_lock_upgrade_timeout

Parameter description: Specifies the time to wait before the attempt of a lock upgrade from ExclusiveLock to AccessExclusiveLock times out on partitions.

Type: USERSET

Value range: an integer ranging from –1 to 3000, in seconds

Default value: 1800

enable_release_scan_lock

Parameter description: Specifies whether a SELECT statement releases a level-1 lock after the statement execution is complete. This parameter reduces DDL conflicts with SELECT locks within transaction blocks. This parameter is supported only by clusters of version 8.3.0 or later.

Type: USERSET

Value range: Boolean

Default value: off

vacuum_full_interruptible

Parameter description: Controls the behavior that the VACUUM FULL statement gives a lock to other statements. This is supported only by clusters of version 9.1.0.200 or later.

Type: USERSET

Value range: Boolean

Default value: off