Updated on 2024-05-07 GMT+08:00

Log Replay

recovery_time_target

Parameter description: Specifies the time for a standby server to write and replay logs.

This is a SIGHUP parameter. Set it based on instructions provided in Table 1.

Value range: an integer ranging from 0 to 3600. The unit is s.

0 indicates that log flow control is disabled. A value from 1 to 3600 indicates that a standby server can write and replay logs within the period specified by the value, so that the standby server can quickly assume the primary role. If this parameter is set to a small value, the performance of the primary server is affected. If it is set to a large value, the log flow is not effectively controlled.

Default value: 60

recovery_max_workers

Parameter description: Specifies the maximum number of concurrent replay threads.

This parameter is a POSTMASTER parameter. Set it based on instructions provided in Table 1.

Value range: an integer ranging from 0 to 20

Default value: 4 (For better performance, the default value in tool installation is 4.)

queue_item_size

Parameter description: Specifies the maximum length of the task queue of each redo replayer thread.

This parameter is a POSTMASTER parameter. Set it based on instructions provided in Table 1.

Value range: a value ranging from 1 to 65535.

Default value: 560

recovery_parse_workers

Parameter description: Specifies the number of ParseRedoRecord threads for the extreme Recovery Time Objective (RTO) feature.

This parameter is a POSTMASTER parameter. Set it based on instructions provided in Table 1.

Value range: an integer ranging from 1 to 16

This parameter can be set to a value greater than 1 only when the ultimate RTO feature is enabled. In addition, it must be used together with recovery_redo_workers. If both recovery_parse_workers and recovery_max_workers are enabled, the ultimate RTO setting of recovery_parse_workers prevails and the concurrent replay function is disabled. Ultimate RTO does not have flow control anymore, and flow control is controlled by the recovery_time_target parameter.

Default value: 1

After ultimate RTO is enabled, the standby node will start more worker threads whose value is equal to the value of recovery_parse_workers x (the value of recovery_redo_workers + 2) + 5, occupying more CPU, memory, and I/O resources. Set parameters based on the actual hardware configuration. If the parameter value is too large, the CPU and memory usage may be too high and the startup may be abnormal.

recovery_redo_workers

Parameter description: Specifies the number of PageRedoWorker threads corresponding to each ParseRedoRecord thread when the ultimate RTO feature is enabled.

This parameter is a POSTMASTER parameter. Set it based on instructions provided in Table 1.

Value range: an integer ranging from 1 to 8

This parameter must be used together with recovery_parse_workers. The setting of recovery_redo_workers takes effect only when recovery_parse_workers is set to a value greater than 1.

Default value: 1

After the database is upgraded from V500R001C00 to V500R001C10 or a later version, you are advised to set parameters based on the number of CPUs in the environment and restart the DN.

Table 1 Parameter settings for different CPUs, memory sizes, and deployment models

No.

CPUs

Memory

Distributed Hybrid Deployment

recovery_parse_workers

recovery_redo_workers

Replayer Threads

Remarks

1

4

-

-

1

1

-

Not recommended

2

8

-

Yes

1

1

-

Not recommended

3

8

64

No

1

1

-

Not recommended

4

16

128

Yes

1

1

-

Not recommended

5

16

128

No

2

3

15

-

6

32

256

Yes

2

2

13

-

7

32

256

No

2

8

25

-

8

64

512

Yes

2

4

17

-

9

64

512

No

2

8

25

Set the parameter to the recommended value for larger specifications.

10

96

768

-

2

8

25

Set the parameter to the recommended value for larger specifications.

recovery_parallelism

Parameter description: Specifies the actual number of replay threads. This parameter is read-only.

This parameter is a POSTMASTER parameter and is affected by recovery_max_workers and recovery_parse_workers. If any value is greater than 0, recover_parallelism will be recalculated.

Value range: an integer ranging from 1 to 2147483647

Default value: 1

enable_page_lsn_check

Parameter description: Specifies whether to enable the data page LSN check. During replay, the current LSN of the data page is checked to see if it is the expected one.

This parameter is a POSTMASTER parameter. Set it based on instructions provided in Table 1.

Value range: Boolean

Default value: on

recovery_min_apply_delay

Parameter description: Specifies the replay delay of the standby node.

This is a SIGHUP parameter. Set it based on instructions provided in Table 1.

  • This parameter does not take effect on the primary node. It must be set on the standby node that requires a delay. You are advised to set this parameter on the asynchronous standby node. If the delay is set on the asynchronous standby node, the RTO will be long after the node is promoted to primary.
  • The delay time is calculated based on the transaction commit timestamp on the primary server and the current time on the standby server. Therefore, ensure that the clocks of the primary and standby servers are synchronized.
  • If the delay time is too long, the disk where the XLOG file is located on the standby node may be full. Therefore, you need to set the delay time based on the disk size.
  • Operations without transactions are not delayed.
  • After the primary/standby switchover, if the original primary node needs to be delayed, you need to manually set this parameter.
  • When synchronous_commit is set to remote_apply, synchronous replication is affected by the delay. Each commit message is returned only after the replay on the standby server is complete.
  • Using this feature also delays hot_standby_feedback, which may cause the primary server to bloat, so be careful when using both.
  • If a DDL operation (such as DROP or TRUNCATE) that holds an AccessExclusive lock is performed on the primary node, the query operation on the operation object on the standby node will be returned only after the lock is released during the delayed replay of the record on the standby node.

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

Default value: 0 (no delay added)

redo_bind_cpu_attr

Parameter description: Specifies the core binding operation of the replayer thread. Only the sysadmin user can access this parameter. This parameter is a POSTMASTER parameter. Set it based on instructions provided in Table 1.

Value range: a string of more than 0 characters. The value is case-insensitive.

  • 'nobind': The thread is not bound to a core.
  • 'nodebind: 1, 2': Use the CPU cores in NUMA groups 1 and 2 to bind threads.
  • 'cpubind: 0-30': Use the CPU cores 0 to 30 to bind threads.
  • 'cpuorderbind: 16-32': One thread is bound to one core starting from core 16. If the number of cores in the range is insufficient, the remaining threads are not bound. You are advised to set the interval to a value greater than or equal to the value of recovery_parallelism plus 1.

Default value: 'nobind'