Data Damage Detection and Repair Functions
File Type |
File/Page |
Primary/Standby |
Detection and Repair |
Ordinary row-store tables (including Astore and Ustore) and segment-page tables (excluding indexes and compressed tables) |
File and page |
Primary |
Manual detection and repair. |
Undo files (excluding undo meta) |
Page |
Primary |
Manual detection and repair (excluding analyse verify). |
init fork file for unlogged tables |
File |
Primary |
Manual detection and repair. |
Ordinary row-store tables (Astore and Ustore), ILM compressed tables, segment-page tables, hash bucket tables, indexes (B-tree and UB-tree), and undo files (excluding undo meta. Undo files support only CRC errors verification.) |
Page |
Standby |
Automatic detection and repair during replay. |

The main standby node and cascaded standby node of the standby cluster can be repaired.
A critical section is used in the database to ensure the consistency of access to key resources. Errors cannot be thrown in the critical section. If a damaged page is accessed in the critical area, PANIC is triggered. Repair detection and automatic repair are not supported. Typical operations that access the critical area during execution include database write operations such as INSERT, DELETE, UPDATE, and DROP.
gs_verify_data_file(verify_segment bool)
Description: Checks whether files in the current database of the current instance are lost. The verification only checks whether intermediate segments are lost in the main file of the data table. The default value is false, indicating that the segment-page table data file is not verified. If this parameter is set to true, only segment-page table files are verified. By default, only the initial user, users with the SYSADMIN attribute, and users with the OPRADMIN attribute in the O&M mode can view the information. Other users can view the information only after being granted permissions.
The returned result is as follows:
- Non-segment-page table: rel_oid and rel_name indicate the table OID and table name of the corresponding file, and miss_file_path indicates the relative path of the lost file.
- Segment-page table: All tables are stored in the same file. Therefore, rel_oid and rel_name cannot display information about a specific table. For a segment-page table, if the first file is damaged, the subsequent files such as .1 and .2 are not checked. For example, if 3, 3.1, and 3.2 are damaged, only 3 damage can be detected. When the number of segment-page files is less than 5, the files that are not generated are also detected during function detection. For example, if there are only files 1 and 2, files 3, 4, and 5 are detected during segment-page file detection. In the following examples, the first is an example of checking a non-segment-page table, and the second is an example of checking a segment-page table.
Parameter description:
- verify_segment
Specifies the range of files to be checked. false indicates that non-segment-page tables are checked. true indicates that segment-page tables are checked.
The value can be true or false (default value).
Return type: record
Example (The abnormal line is displayed only when an exception is detected. Otherwise, no line is displayed.):
Verify a non-segment-page table.
gaussdb=# SELECT * FROM gs_verify_data_file();
node_name | rel_oid | rel_name | miss_file_path
------------------+---------+--------------+------------------
dn_6001_6002_6003 | 16554 | test | base/16552/24745
Verify a segment-page table.
gaussdb=# SELECT * FROM gs_verify_data_file(true);
node_name | rel_oid | rel_name | miss_file_path
-------------------+---------+----------+----------------
dn_6001_6002_6003 | 0 | none | base/16573/2
gs_repair_file(tableoid Oid, path text, timeout int)
Description: Repairs the file based on the input parameters. Only the primary DN with normal primary/standby connection is supported. Only the main file of the data table can be repaired. The parameters are set based on the OID and path returned by the gs_verify_data_file function. The value of table OID for a segment-page table ranges from 0 to 4294967295. (The internal verification determines whether a file is a segment-page table file based on the file path. The table OID is not used for a segment-page table file.) If the repair is successful, true is returned. If the repair fails, the failure cause is displayed. By default, only the initial user, users with the SYSADMIN permission, and users with the OPRADMIN permission in the O&M mode on the primary DN can view the information. Other users can view the information only after being granted permissions.

- If a file on a DN is damaged, a verification error at the PANIC level is reported when the DN is promoted to primary. The DN cannot be promoted to primary, which is normal.
- If a file exists but its size is 0, the file will not be repaired. To repair the file, you need to delete the file whose size is 0 and then repair it.
- You can delete a file only after the file descriptor is automatically closed. You can manually restart the process or perform a primary/standby switchover.
Parameter description:
- tableoid
OID of the table corresponding to the file to be repaired. Set this parameter based on the rel_oid column in the list returned by the gs_verify_data_file function.
Value range: OID ranging from 0 to 4294967295. Note: A negative value will be forcibly converted to a non-negative integer.
- path
Path of the file to be repaired. Set this parameter based on the miss_file_path column in the list returned by the gs_verify_data_file function.
Value range: a string.
- timeout
Specifies the duration for waiting for the standby DN to replay. The repair file needs to wait for the standby DN to be put back to the corresponding location on the current primary DN. Set this parameter based on the replay duration of the standby DN.
Value range: 60s to 3600s.
Return type: Boolean
Example (Set tableoid and path based on the output of gs_verify_data_file):
Page-based storage:
gaussdb=# SELECT * FROM gs_repair_file(16554,'base/16552/24745',360);
gs_repair_file
----------------
t
Segment-page storage:
gaussdb=# SELECT * FROM gs_repair_file(16554,'base/16573/2',360);
gs_repair_file
----------------
t
local_bad_block_info()
Description: Displays the page damage of the instance. You can read the page from the disk and record the page CRC failure. By default, only the initial user, users with the SYSADMIN attribute, users with the MONADMIN attribute, users with the OPRADMIN attribute in the O&M mode, and monitoring users can view the information. Other users can view the information only after being granted permissions. In the multi-tenancy scenario, the global information is returned if this function is called in a non-PDB, and only the information about a local PDB is returned if this function is called in a PDB.
In the preceding information, file_path indicates the relative path of the damaged file. Segment-page mode is supported. block_num indicates the number of the page where the file is damaged. The page number starts from 0. check_time indicates the time when the page damage is detected. repair_time indicates the time when the page is repaired.
Return type: record
Example (Related entries are displayed only when there are damaged records. Otherwise, no log is displayed.):
gaussdb=# SELECT * FROM local_bad_block_info();
node_name | spc_node | db_node | rel_node| bucket_node | fork_num | block_num | file_path | check_time | repair_time
-----------------+-------+--------+--------+--------------+----------+-----------+-----------------+--------------------------+-------------------------------
dn_6001_6002_6003| 1663 | 16552 | 24745 | -1 | 0 | 0 | base/16552/24745 | 2022-01-13 20:19:08.385004+08 | 2022-01-13 20:19:08.407314+08
local_clear_bad_block_info()
Description: Deletes data of repaired pages from local_bad_block_info, that is, information whose repair_time is not empty. By default, only the initial user, users with the SYSADMIN attribute, users with the OPRADMIN attribute in the O&M mode, and monitoring users can view the information. Other users can view the information only after being granted permissions. In the multi-tenancy scenario, this function runs properly if it is called in a non-PDB, and an error is reported if it is called in a PDB.
Return type: Boolean
Example:
gaussdb=# SELECT * FROM local_clear_bad_block_info();
result
--------
t
gs_inconsistency_info(reset bool)
Description: Displays or resets data inconsistency information in the database. If the input parameter reset is set to true, data inconsistency information is reset. If the input parameter reset is set to false, data inconsistency information is displayed. By default, only the initial user, users with the SYSADMIN attribute, users with the MONADMIN attribute, users with the OPRADMIN attribute in the O&M mode, and monitor users can view the information. Other users can view the information only after being granted permissions. inconsistency_type indicates the inconsistency type, node_name indicates the node name, spc_node indicates the tablespace ID, db_node indicates the database node ID, rel_node indicates the table ID, bucket_node indicates the hash bucket ID, backend indicates the temporary table ID, index_oid indicates the index OID, tuple_blkno indicates the page number of the heap table where the tuple is located, tuple_offset indicates the offset of the heap table page where the tuple is located, count indicates the number of times the inconsistency information occurs, and last_update_time indicates the last time when the inconsistent information is updated.
Return type: record
When the input parameter reset is set to false and inconsistency information is detected, related items are displayed. In other cases, no line is displayed. Example:
gaussdb=# SELECT * FROM gs_inconsistency_info(false);
inconsistency_type | node_name | spc_node | db_node | rel_node | bucket_node | backend | index_oid | tuple_blkno | tuple_offset | count | last_update_time
---------------------+-----------+----------+---------+----------+-------------+---------+-----------+-------------+--------------+-------+------------------------------
INCONSISTENCY_INDEX | sgnode | 1663 | 12902 | 16722 | -1 | -1 | 16728 | 0 | 1 | 1 | 2024-11-20 16:18:56.85289-05
gs_verify_and_tryrepair_page (path text, blocknum oid, verify_mem bool, is_segment bool)
Description: Verifies the page specified by the instance. By default, only the initial user, users with the SYSADMIN attribute, and users with the OPRADMIN attribute in O&M mode on the primary DN can view the table. Other users can view the table only after being granted permissions.
In the command output, disk_page_res indicates the verification result of the page on the disk, mem_page_res indicates the verification result of the page in the memory, and is_repair specifies whether the repair function is triggered during the verification. t indicates that the page is repaired, and f indicates that the page is not repaired. In the multi-tenancy scenario, this function runs properly if it is called in a non-PDB, and an error is reported if it is called in a PDB.

- If a page on a DN is damaged, a verification error at the PANIC level is reported when the DN is promoted to primary. The DN cannot be promoted to primary, which is normal. Damaged pages of hash bucket tables cannot be repaired.
- The repair triggered by this function can only repair pages in the memory. The repair takes effect only after the memory pages are flushed to disks and the physical pages are repaired.
Parameter description:
- path
Path of the damaged file. Set this parameter based on the file_path column in the local_bad_block_info file. To verify the undo pages of the Ustore table, enter the path of the undo pages to be verified.
Value range: a string.
- blocknum
Page number of the damaged file. Set this parameter based on the block_num column in the local_bad_block_info file. If you want to verify the undo pages of the Ustore table, enter the block number of the undo pages to be verified.
Value range: OID ranging from 0 to 4294967295. Note: A negative value will be forcibly converted to a non-negative integer.
- verify_mem
Specifies whether to verify a specified page in the memory. If this parameter is set to false, only pages on the disk are verified. If this parameter is set to true, pages in the memory and on the disk are verified. If a page on the disk is damaged, the system verifies the basic information of the page in the memory and flushes the page to the disk to restore the page. If a page is not found in the memory during memory page verification, the page on the disk is read through the memory API. During this process, if the disk page is faulty, the remote read automatic repair function is triggered.
Value range: The value is of the Boolean type and can be true or false.
- is_segment
Determines whether the table is a segment-page table. Set this parameter based on the value of bucket_node in the local_bad_block_info file. If the value of bucket_node is –1, the table is not a segment-page table. In this case, set is_segment to false. If the value of bucket_node is not –1, set is_segment to true. Segment-page storage is supported.
Value range: The value is of the Boolean type and can be true or false.
Return type: record
Examples (Transfer parameters based on the output of local_bad_block_info. Otherwise, an error is reported.):
Page-based storage:
gaussdb=# SELECT * FROM gs_verify_and_tryrepair_page('base/16552/24745',0,false,false);
node_name | path | blocknum | disk_page_res | mem_page_res | is_repair
------------------+------------------+------------+-----------------------------+---------------+----------
dn_6001_6002_6003 | base/16552/24745 | 0 | page verification succeeded.| | f
Segment-page storage:
gaussdb=# SELECT * FROM gs_verify_and_tryrepair_page('base/14365/1',4494,false,true);
node_name | path | blocknum | disk_page_res | mem_page_res | is_repair
------------------+--------------+----------+------------------------------+--------------+-----------
dn_6001_6002_6003 | base/14365/1 | 4494 | page verification succeeded. | | f
gs_repair_page(path text, blocknum oid, is_segment bool, timeout int)
Description: Restores the specified page of the instance. This function can be used only by the primary DN that is properly connected to the primary and standby DNs. If the page is successfully restored, true is returned. If an error occurs during the restoration, an error message is displayed. By default, only the initial user, users with the SYSADMIN attribute, and users with the OPRADMIN attribute in O&M mode on the primary DN can view the table. Other users can view the table only after being granted permissions.
Note: If a page on a DN is damaged, a verification error at the PANIC level is reported when the DN is promoted to primary. The DN cannot be promoted to primary, which is normal. Damaged pages of hash bucket tables or compressed tables cannot be repaired.
Parameter description:
- path
Path of the damaged page. Set this parameter based on the file_path column in local_bad_block_info or the path column in the gs_verify_and_tryrepair_page function.
Value range: a string.
- blocknum
Number of the damaged page. Set this parameter based on the block_num column in local_bad_block_info or the blocknum column in the gs_verify_and_tryrepair_page function.
Value range: OID ranging from 0 to 4294967295. Note: A negative value will be forcibly converted to a non-negative integer.
- is_segment
Determines whether the table is a segment-page table. The value of this parameter is determined by the value of bucket_node in local_bad_block_info. If the value of bucket_node is –1, the table is not a segment-page table and is_segment is set to false. If the value of bucket_node is not –1, is_segment is set to true. Segment-page storage is supported.
Value range: The value is of the Boolean type and can be true or false.
- timeout
Duration of waiting for standby DN replay. The page to be repaired needs to wait for the standby DN to be played back to the location of the current primary DN. Set this parameter based on the replay duration of the standby DN.
Value range: 60s to 3600s.
Return type: Boolean
Examples (Transfer parameters based on the output of local_bad_block_info. Otherwise, an error is reported.):
Page-based storage:
gaussdb=# SELECT * FROM gs_repair_page('base/16552/24745',0,false,60);
result
--------
t
Segment-page storage:
gaussdb=# SELECT * FROM gs_repair_page('base/16552/1',4494,true,60);
result
--------
t
gs_seg_verify_datafile(IN tablespace_name name, IN database_name name, IN file_id integer, IN bucketnode integer, IN start_block_id bigint default 0, IN end_block_id bigint default UINT32MAX)
- Description
Description: Verifies segment-page files 1 to 5, checks whether the main fork has page damage, and records the verification result in the local_bad_block_info() function.
Permission: Only users with the SYSADMIN attribute and users with the OPRADMIN attribute in O&M mode can execute this function.
- Parameter description:
Name
Type
Description
tablespace_name
name
Tablespace name.
database_name
name
Database name.
file_id
integer
File name. Value range: an int4 value in the range [1,5].
bucketnode
integer
Bucket node of the table.
- 0 to 1023 indicate the bucket nodes of a hash bucket table.
- 1024 indicates the bucket node of a segment-page ordinary table.
Currently, only hash bucket tables and segment-page ordinary tables are supported.
start_block_id
bigint
Start value of the verification page range. The default value is 0.
end_block_id
bigint
End value of the verification page range. The default value is 4294967295.
- Return value: None
Example:
gaussdb=# SELECT * FROM gs_seg_verify_datafile('seg_tblspc', 'postgres', 2, 1024);
WARNING: page verification failed, calculated checksum 60994 but expected 11565, the block num is 4157
gs_seg_verify_datafile
------------------------
(1 row)
gs_edit_page_bypath(path text, blocknum int64, offset int, data text, data_size int, read_backup bool, storage_type text)
Description: Transfers the path, block number, offset, target data to be changed, and length of the target table file, changes the target data to the corresponding fields on the page, and returns the path of the modified file to be flushed to the disk. The read_backup column determines the file reading mode, and the storage_type column indicates the file storage mode (for example, segment-page storage). To prevent incorrect modification, this function does not directly change the original page but changes the copied page and flushes the changed page to the specified path. Only the SYSADMIN or OPRADMIN in O&M mode can execute this function.
Return type: text
Category |
Parameter |
Type |
Description |
---|---|---|---|
Input parameter |
path |
text |
Physical file path of the file to be modified, which is related to the read_backup field. The value can be the relative path of the file in the database directory or the absolute path of files such as the backup file. If the target file does not exist or fails to be read, an error message is displayed.
In page-based mode, only U-page and UB-tree data pages can be edited and modified. In segment-page mode, Astore data pages can be edited and modified. Tables with tablespaces are not supported. Other information about the input file cannot be obtained. Therefore, you need to ensure that the input data type is correct. |
Input parameter |
blocknum |
bigint |
Block number of the page to be repaired. Value range: 0 to MaxBlockNumber. Reads the page corresponding to the specified physical or logical block number based on the read_backup field. If the specified block number is out of range, an error message is returned. |
Input parameter |
offset |
int |
In-page offset of the field to be modified. Value range: 0 ≤ offset < BLCKSZ. If the specified value is less than 0 or greater than or equal to that of BLCKSZ, the system view is used to return the corresponding error information. |
Input parameter |
data |
text |
Type of the target value to be modified. Type:
Others: If the value of the data parameter is not one of the preceding types, the value can only be a decimal numeric string. |
Input parameter |
data_size |
int |
Length of the written data, in bytes. Value range: 1 to 8. If the specified write length is less than 1 byte or greater than 8 bytes, or the sum of offset and data_size is greater than the value of BLCKSZ, the system view is used to return the corresponding error information. |
Input parameter |
read_backup |
bool |
Specifies whether to read pages from the backup directory. If this parameter is set to false, the target page is read based on the logical block number. Otherwise, the page is read based on the physical block number. |
Input parameter |
storage_type |
text |
Specifies the file storage mode. This parameter is optional.
|
Output parameter |
output_msg |
text |
If the modification is successful, the absolute path of the modified file is returned. The modified file is stored in the gs_log/dump directory. If the modification fails, a failure message is returned. |
In the example, transfer parameters based on the parameter description and use the actual physical path.
Example 1: Overwrite the data whose value is 0X1FFF at the offset of 16 bytes on page 0 in the base/15808/25075 table.
gaussdb=# SELECT gs_edit_page_bypath('base/15808/25075',0,16,'0x1FFF', 2, false, 'page');
gs_edit_page_bypath
----------------------------------------------------------------------
/gs_log_dir/dump/1663_15808_25075_0.editpage
(1 rows)
Example 2: If the input parameter does not comply with the specifications, an error message is returned.
gaussdb=# SELECT gs_edit_page_bypath('base/15808/25075', 0,16,'@1231!', 8, false, 'page');
gs_edit_page_bypath
-------------------------------------------
Error: the parameter 'data' decode failed.
(1 row)
Example 3: When the data to be written is the same as the original value, an alarm is returned.
gaussdb=# SELECT gs_edit_page_bypath('/gs_log_dir/dump/1663_15808_25075_0.editpage', 0,16,'0x1FFF', 2, true, 'page');
gs_edit_page_bypath
----------------------------------------------------------
Warning: source buffer is consistent with target buffer.
(1 row)
gs_repair_page_bypath(src_path text, src_blkno int64, dest_path text, dest_blkno int64, storage_type text)
Description: Transfers the path and page number of the source file, and writes the page to the specified page number of the target file. You can repair pages of the standby node through the primary node or repair the pages of the primary node through the standby node. In addition, you can initialize bad blocks in this view.
- Target pages are overwritten and synchronized to the standby node. In page storage mode, U-heap and UB-tree pages can be modified. The Undo Record page, Undo Slot page, compressed table, and Astore page will be supported later. In segment-page storage mode, Astore pages and hash bucket tables can be modified. System catalog files and data sections cannot be modified.
- With this function, you can overwrite target pages during the write operation. Before overwriting, the target page is backed up and flushed to a specified directory. The backup page can be rewritten back to the target page. If an ordinary table is modified on the primary node, a new WAL is generated and synchronized to the standby node. If an ordinary table is modified on the standby node, no WAL is recorded.
- The repair view applies to the primary node or the standby node when the read on standby function is enabled. Only the SYSADMIN or OPRADMIN in O&M mode can use this function. All modifications will be recorded in database logs. In addition, you are advised to enable the audit logging function of system functions before using this function to record audit information.
- When the repair view is called on the standby node, the standby node can be repaired only by reading pages from the primary node.
- The LSNs of the source and target pages must be the same. Otherwise, the repair fails.
- The target page is verified. If the target page is correct, it cannot be overwritten. Currently, the U-heap and UB-tree pages can be verified.
Return type: text

Calling this system function is a high-risk operation. Exercise caution when performing this operation.
Category |
Parameter |
Type |
Description |
---|---|---|---|
Input parameter |
src_path |
text |
Path of the source file. The following types of paths are supported:
|
Input parameter |
src_blkno |
bigint |
Physical block number of the source page. Value range: 0 to MaxBlockNumber. |
Input parameter |
dest_path |
text |
Relative path of the target file. For example, base/15808/25075. |
Input parameter |
dest_blkno |
bigint |
Logical block number of the target page. Value range: 0 to MaxBlockNumber. |
Input parameter |
storage_type |
text |
Specifies the target file storage mode. This parameter is optional.
|
Output parameter |
output_msg |
text |
If the overwrite operation is successful, the backup path of the target page is returned. If the overwrite operation fails, an error message is returned. The format of the flushed file name is relfilepath_blocknum_timestamp.repairpage. |
Transfer parameters based on the preceding table and ensure that the physical file exists. If the input parameter is abnormal or the restoration fails, an error is reported.
Example 1: Enter a file in a specified path to overwrite the target file.
gaussdb=# SELECT * FROM gs_repair_page_bypath('gs_log/dump/1663_15991_16767_0.editpage', 0, 'base/15991/16767', 0, 'page');
output_msg
------------------------------------------------------------------------------------------------
/gs_log_dir/dump/1663_15991_16767_0_738039702421788.repairpage
(1 row)
Example 2: Read pages from the standby node to repair the primary node.
gaussdb=# SELECT * FROM gs_repair_page_bypath('standby', 0, 'base/15990/16768', 0, 'page');
output_msg
-------------------------------------------------------------------------------------------------
/gs_log_dir/dump/1663_15990_16768_0_738040397197907.repairpage
(1 row)
Example 3: Read pages from the primary node to repair the standby node.
gaussdb=# SELECT * FROM gs_repair_page_bypath('primary', 0, 'base/15990/16768', 0, 'page');
output_msg
-------------------------------------------------------------------------------------------------
/gs_log_dir/dump/1663_15990_16768_0_738040506157799.repairpage
(1 row)
Example 4: Initialize the target page and skip bad blocks.
gaussdb=# SELECT * FROM gs_repair_page_bypath('init_block', 0, 'base/15990/16768', 0, 'page');
output_msg
-------------------------------------------------------------------------------------------------
/gs_log/dump/1663_15990_16768_0_738040768010281.repairpage
(1 row)
gs_repair_undo_byzone(zone_id int)
Description: Transfers the ID of the undo zone to be repaired, repairs the metadata of the target undo zone, and returns the repair result details. If the undo zone is not repaired, no information is output.
Return type: record
Note: Currently, the function can be called only on the primary node. After the repair is successful, the repair will be synchronized to the standby node by recording Xlogs. The caller must be a SYSADMIN or an OPRADMIN in O&M mode. You are advised to enable the audit logging function before using the function to record audit information.

Calling this system function is a high-risk operation. Exercise caution when performing this operation.
Category |
Parameter |
Type |
Description |
---|---|---|---|
Input parameter |
zone_id |
int |
Undo zone ID.
|
Output parameter |
zone_id |
int |
Undo zone ID. |
Output parameter |
repair_detail |
text |
Repair result of the undo zone metadata corresponding to the zone ID. If the repair is successful, "rebuild undo meta succeed." is displayed. If the repair fails, "rebuild undo meta failed." as well as the failure cause is displayed. |
Example 1: If the undo zone meta information corresponding to the entered zone_id is not damaged, no output is expected.
gaussdb=# SELECT * FROM gs_repair_undo_byzone(4);
zone_id | repair_detail
---------+---------------
(0 rows)
Example 2: If the undo zone metadata corresponding to the entered zone_id is successfully restored, the system displays a message indicating that the restoration is successful.
gaussdb=# SELECT * FROM gs_repair_undo_byzone(78);
zone_id | repair_detail
---------+---------------
78 | rebuild undo meta succeed.
(1 row)
Example 3: If the undo zone metadata corresponding to the entered zone ID fails to be repaired, the detailed information about the repair failure is displayed.
gaussdb=# SELECT * FROM gs_repair_undo_byzone(0);
zone_id | repair_detail
---------+---------------
0 | rebuild undo meta failed. try lock undo zone_id failed.
(1 row)

If the undo zone to be repaired is damaged and the zone ID is occupied by another active thread, the active thread that occupies the zone ID automatically ends when the repair function is called to forcibly repair the damaged undo zone metadata.
gs_verify_urq(index_oid oid, partindex_oid oid, blocknum bigint, queue_type text)
Description: Verifies the correctness of the index recycling queue (potential queue/available queue/single page).
Parameters: For details, see Table 3.
Return type: record
Category |
Parameter |
Type |
Description |
---|---|---|---|
Input parameter |
index_oid |
oid |
UB-tree index OID.
|
Input parameter |
partindex_oid |
oid |
UB-tree partitioned index OID.
|
Input parameter |
blocknum |
bigint |
Specifies the page number:
|
Input parameter |
queue_type |
text |
Specifies the queue type:
|
Output parameter |
error_code |
text |
Error code |
Output parameter |
detail |
text |
Detailed error information and other key information. |
When using the example, transfer parameters based on the parameter description and use the actual OID and blocknum. Otherwise, an error is reported.
Example 1:
gaussdb=# SELECT * FROM gs_verify_urq(16387, 0, 1, 'free queue');
error_code | detail
------------+--------
(0 rows)
Example 2:
gaussdb=# SELECT * FROM gs_verify_urq(16387, 0, 1, 'empty queue');
error_code | detail
-----------------------+---------------------------------------------------------------------------------------------------------------
VERIFY_URQ_PAGE_ERROR | invalid urq meta: oid 16387, blkno 1, head_blkno = 1, tail_blkno = 3, nblocks_upper = 4294967295, nblocks_lower = 1; urq_blocks = 6, index_blocks = 12
(1 row)

Currently, this API supports only Ustore index tables. If the verification of the index recycling queue is normal, the view does not display the error code and error details. Otherwise, the view displays the error code and error details. The error codes include "VERIFY_URQ_PAGE_ERROR", "VERIFY_URQ_LINK_ERROR", "VERIFY_URQ_HEAD_MISSED_ERROR", and "VERIFY_URQ_TAIL_MISSED_ERROR". Contact Huawei technical support if any of the preceding error codes is displayed.
gs_urq_dump_stat(index_oid oid, partindex_oid oid)
Description: Queries information about a specified index recycling queue.
In the return result, recentGlobalDataXmin and globalFrozenXid are two oldestxmins used by the recycling queue to determine whether the index page can be recycled, next_xid is the XID of the next latest transaction, urq_blocks indicates the total number of pages in the recycling queue and information about valid pages in the free queue (available queue) and empty queue (potential queue). For PCR indexes, the output recentGlobalDataXmin is replaced by globalRecycleXid that affects the recycling of the PCR index pages.
Parameters: For details, see Table 4.
Category |
Parameter |
Type |
Description |
---|---|---|---|
Input parameter |
index_oid |
oid |
UB-tree index OID.
|
Input parameter |
partindex_oid |
oid |
UB-tree partitioned index OID.
|
Output parameter |
result |
text |
Detailed statistics about the index recycling queue. |
When using the example, transfer parameters based on the parameter description and use the actual OID. Otherwise, an error is reported.
Example (RCR):
gaussdb=# SELECT * FROM gs_urq_dump_stat(16387, 0);
result
---------------------------------------------------------------------------------------------------------------------------------
urq stat info: recentGlobalDataXmin = 213156, globalFrozenXid = 213156, next_xid = 214157, urq_blocks = 6, +
free queue: head page blkno = 0 min_xid = 211187 max_xid = 214157, tail page blkno = 0 min_xid = 211187 max_xid = 214157,+
middle page min_xid = 1152921504606846975 max_xid = 0, valid_pages = 1, valid_items = 6, can_use_item = 3 +
empty queue: head page blkno = 1 min_xid = 212160 max_xid = 213160, tail page blkno = 3 min_xid = 213162 max_xid = 214156,+
middle page min_xid = 1152921504606846975 max_xid = 0, valid_pages = 2, valid_items = 999, can_use_item = 498 +
(1 row)
Example (PCR):
gaussdb=# SELECT gs_urq_dump_stat(17260,0);
gs_urq_dump_stat
-------------------------------------------------------------------------------------------------------------------------------------------------
urq stat info: globalRecycleXid = 22113, globalFrozenXid = 22107, next_xid = 22116, urq_blocks = 6, +
free queue: head page blkno = 0 min_xid = 1152921504606846975 max_xid = 0, tail page blkno = 0 min_xid = 1152921504606846975 max_xid = 0,+
middle page min_xid = 1152921504606846975 max_xid = 0, valid_pages = 1, valid_items = 0, can_use_item = 0 +
empty queue: head page blkno = 1 min_xid = 1152921504606846975 max_xid = 0, tail page blkno = 1 min_xid = 1152921504606846975 max_xid = 0,+
middle page min_xid = 1152921504606846975 max_xid = 0, valid_pages = 1, valid_items = 0, can_use_item = 0 +
(1 row)

Currently, this API supports only Ustore index tables.
gs_repair_urq(index_oid oid, partindex_oid oid)
Description: Repairs (with loss) index recycling queues (potential and available queues). The recycling queue file of the current index is deleted and an empty recycling queue file is created. If the repair is successful, "reinitial the recycle queue of index relation successfully" is displayed.
Parameter: For details, see Table 5.
Note: The current function can be called only on the primary node.
Category |
Parameter |
Type |
Description |
---|---|---|---|
Input parameter |
index_oid |
oid |
UB-tree index OID.
|
Input parameter |
partindex_oid |
oid |
UB-tree partitioned index OID.
|
Output parameter |
result |
text |
If the repair is successful, "reinitial the recycle queue of index relation successfully" is displayed. Otherwise, the repair fails. |
When using the example, transfer parameters based on the parameter description and use the actual OID. Otherwise, an error is reported.
Example:
gaussdb=# SELECT * FROM gs_repair_urq(16387, 0);
result
------------------------------------------------------------
reinitial the recycle queue of index relation successfully.
(1 row)

Currently, this API supports only Ustore index tables.
gs_check_table(table_oid oid, partition_oid oid, index_oid oid, partindex_oid oid, start_blk bigint, end_blk bigint, duration text, need_repair bool, mode text)
Description: Verifies reverse data consistency between heap tables and indexes.
Constraints: The Astore and Ustore are supported. MOT storage engines are not supported. The verification of standby nodes is supported, but the verification of the logger node is not supported. The verification of common row-store tables, ILM compressed tables, and hash bucket tables is supported by heap tables. The verification of temporary tables, global temporary tables, and unlogged tables is not supported by heap tables. Indexes support B-tree and UB-tree index verification and are compatible with segment-page storage.
Parameters: For details, see Table gs_check_table parameters.
Return type: record
Category |
Parameter |
Type |
Description |
---|---|---|---|
Input parameter |
table_oid |
oid |
Heap table OID.
|
Input parameter |
partition_oid |
oid |
Partition OID.
|
Input parameter |
index_oid |
oid |
Index OID.
|
Input parameter |
partindex_oid |
oid |
Partitioned index OID.
|
Input parameter |
start_blk |
bigint |
Number of the verification start page. If it and end_blk are set to –1, the verification starts from the beginning by default. When all partitions in a partitioned table are scanned, only the verification from the beginning is supported. The values of start_blk and end_blk must be –1. |
Input parameter |
end_blk |
bigint |
Number of the verification end page. |
Input parameter |
duration |
text |
Verification duration. The value can be in millisecond, second, minute, hour, or day, for example, 500ms, 60s, 10min, 2h, or 1d. The maximum value is 24h. There may be a millisecond-level, seconds-level, or minute-level error. If this parameter is set to 0, the verification is complete by default. The verification duration is the minimum value of the actual execution time and the configured time. If the execution time exceeds the configured time, the verification stops and the current verification position is recorded. The next scanning can be resumed from the recorded position. |
Input parameter |
need_repair |
bool |
Specifies whether to automatically repair inconsistency. That is, add or delete index tuples based on heap tables. Currently, this parameter can only be set to false. This parameter is a pre-embedded parameter. This version does not support automatic repair. |
Input parameter |
mode |
text |
Pre-embedded parameter of the validation mode. The value can be increment or full. Resumable verification, increment verification, and full verification are supported. |
Output parameter |
error_code |
int |
Error code. |
Output parameter |
output_filepath |
text |
Relative path for flushing parsed data to disks. The path is the gs_log/dump dictionary. The flushed file name is dbverify_error code_heap table OID_timestamp.log. Example: /$GAUSSLOG/gs_log/dump/dbverify_0_16384_123456.log |
When using the example, transfer parameters based on the parameter description and use the actual and matching OID and blocknum. Otherwise, an error is reported.
Example 1:
gaussdb=# select * from gs_check_table((select oid from pg_class where relname='t2'),0,0,0,-1,-1, '1h', false, 'full');
verify_code | output_filepath
-------------+---------------------------------------------------------------------------------------
0 | /$GAUSSLOG/gs_log/dump/dbverify_0_17279_766073191583799.log
(1 row)
Example 2:
gaussdb=# select * from gs_check_table((select oid from pg_class where relname='t1'),0,(select oid from pg_class where relname='index_t1'),0,2,10, '2s', false, 'full');
verify_code | output_filepath
-------------+---------------------------------------------------------------------------------------
0 | /$GAUSSLOG/gs_log/dump/dbverify_0_17168_766073338594117.log
(1 row)

Calling this system function is a high-risk operation. Exercise caution when performing this operation.
Currently, this API supports consistency check between Astore and Ustore tables and between B-tree and UB-tree indexes. If no consistency problem is found after the verification, the error code is 0. Contact Huawei technical support if an error code other than 0 is displayed.
Resumable verification and increment verification:
The information related to resumable verification and incremental verification is not persisted. After the database process is restarted, the previous verification is lost. When the verification is performed again, the full verification is performed from the beginning.
If the verification mode is increment and the last verification on the table and index is not complete, resumable verification is triggered and the verification starts from the position where the last verification is interrupted.
If the verification mode is increment and the last verification on the table and index is complete, increment verification is triggered to verify the incremental modification page.
If the verification mode is full, full verification is performed from the beginning.
I/O flow control:
By default, io_priority is set to a low priority for I/O flow control.
Use permission:
Only the initial user, users with the SYSADMIN, OPRADMIN, or MONADMIN permission can execute verification system functions. Only data tables or indexes in the current database can be verified.
Recommended application scenario:
You are advised to perform the verification during off-peak hours to ensure that most data is static data during the verification and ensure the integrity and accuracy of the verification.
gs_check_index(index_oid oid, partindex_oid oid, duration text, need_repair bool, mode text)
Description: Verifies forward data consistency between heap tables and indexes.
Constraints: The Astore and Ustore are supported. MOT storage engines are not supported. The verification of standby nodes is supported, but the verification of the logger node is not supported. The verification of common row-store tables, ILM compressed tables, and hash bucket tables is supported by heap tables. The verification of temporary tables, global temporary tables, and unlogged tables is not supported by heap tables. Indexes support B-tree and UB-tree index verification and are compatible with segment-page storage.
Parameters: For details, see Table gs_check_index parameters.
Return type: record
Category |
Parameter |
Type |
Description |
---|---|---|---|
Input parameter |
index_oid |
oid |
Index OID.
|
Input parameter |
partindex_oid |
oid |
Partitioned index OID.
|
Input parameter |
duration |
text |
Verification duration. The value can be in millisecond, second, minute, hour, or day, for example, 500ms, 60s, 10min, 2h, or 1d. The maximum value is 24h. There may be a millisecond-level, seconds-level, or minute-level error. If this parameter is set to 0, the verification is complete by default. The verification duration is the minimum value of the actual execution time and the configured time. If the execution time exceeds the configured time, the verification stops and the current verification position is recorded. The next scanning can be resumed from the recorded position. |
Input parameter |
need_repair |
bool |
Specifies whether to automatically repair inconsistency. That is, add or delete index tuples based on heap tables. Currently, this parameter can only be set to false. This parameter is a pre-embedded parameter. This version does not support automatic repair. |
Input parameter |
mode |
text |
Pre-embedded parameter of the validation mode. The value can be increment or full. Resumable verification, increment verification, and full verification are supported. |
Output parameter |
error_code |
int |
Error code. |
Output parameter |
output_filepath |
text |
Relative path for flushing parsed data to disks. The path is the gs_log/dump dictionary. The flushed file name is dbverify_error code_heap table OID_timestamp.log. Example: /$GAUSSLOG/gs_log/dump/dbverify_0_16384_123456.log |
When using the example, transfer parameters based on the parameter description and use the actual and matching OID. Otherwise, an error is reported.
Example 1:
gaussdb=# select * from gs_check_index((select oid from pg_class where relname='index_t1'),0, '1h', false, 'full');
verify_code | output_filepath
-------------+---------------------------------------------------------------------------------------
0 | /$GAUSSLOG/gs_log/dump/dbverify_0_17302_766074761373434.log
(1 row)
Example 2:
gaussdb=# select * from gs_check_index((select oid from pg_class where relname='index_range_2'),(select oid from pg_partition where parentid=(select oid from pg_class where relname='index_range_2')and relname='p1_a_idx'), '10s', false, 'full');
verify_code | output_filepath
-------------+---------------------------------------------------------------------------------------
0 | /$GAUSSLOG/gs_log/dump/dbverify_0_17306_766074834795344.log
(1 row)

Calling this system function is a high-risk operation. Exercise caution when performing this operation.
Currently, this API supports consistency check between Astore and Ustore tables and between B-tree and UB-tree indexes. If no consistency problem is found after the verification, the error code is 0. Contact Huawei technical support if an error code other than 0 is displayed.
Resumable verification and increment verification:
The information related to resumable verification and incremental verification is not persisted. After the database process is restarted, the previous verification is lost. When the verification is performed again, the full verification is performed from the beginning.
If the verification mode is increment and the last verification on the table and index is not complete, resumable verification is triggered and the verification starts from the position where the last verification is interrupted.
If the verification mode is increment and the last verification on the table and index is complete, increment verification is triggered to verify the incremental modification page.
If the verification mode is full, full verification is performed from the beginning.
I/O flow control:
By default, io_priority is set to a low priority for I/O flow control.
Use permission:
Only the initial user, users with the SYSADMIN, OPRADMIN, or MONADMIN permission can execute verification system functions. Only data tables or indexes in the current database can be verified.
Recommended application scenario:
You are advised to perform the verification during off-peak hours to ensure that most data is static data during the verification and ensure the integrity and accuracy of the verification.
gs_get_standby_bad_block_info()
Description: Displays the pages that have been detected on the standby node but have not been repaired. By default, only the initial user, users with the SYSADMIN permission, users with the OPRADMIN permission in the O&M mode, and users with the MONADMIN permission on the standby DN can view the information. Other users can view the information only after being granted permissions. There are four return values in the invalid_type column: NOT_PRESENT (the page does not exist), NOT_INITIALIZED (the page initialization fails), LSN_CHECK_ERROR (the LSN check fails), and CRC_CHECK_ERROR (the CRC check fails).
Return type: record
Example (If no page is detected but not repaired, no line is displayed.)
gaussdb=# SELECT * FROM gs_get_standby_bad_block_info();
spc_node | db_node | rel_node | bucket_node | fork_num | block_num | invalid_type | master_page_lsn
----------+---------+----------+-------------+----------+-----------+-----------------+-----------------
1663 | 16552 | 24745 | -1 | 0 | 0 | CRC_CHECK_ERROR | 0/B2009E8
(1 rows)
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot