Only cluster 8.3.0 and later versions support the function of scanning residual files. All functions described in this section can be invoked only by the sysadmin role.
Description: This function scans all residual file records in the database connected to the current node. It is an instance-level function and is related to the current database, and it can run on any instance.
Return type: record
The following information is displayed:
Field |
Type |
Description |
|---|---|---|
pgscrf |
text |
Local path of the metadata file that records residual file information. |
Example:
1 2 3 4 5 6 | SELECT * FROM pg_scan_residualfiles(); pgscrf -------------------------------------------------------------------- pg_residualfiles/pgscrf_meta_1663_16323_20231027143716005244 pg_residualfiles/pgscrf_meta_2147484281_16323_20231027143716005713 (2 rows) |
The restrictions on using this function are as follows:
Description: Unified CN execution function of pg_scan_residualfiles() This function is a cluster-level function and is related to the current database. It runs on CNs.
Parameter description: query_flag. The parameter type is int, indicating the execution range. 1 indicates the CN, 2 indicates the primary DN, and 4 indicates the standby DN. The query union set can be obtained through the OR operation. For example, 1|2=3 indicates the CN and primary DN, and 1|2|4=7 indicates the CN, primary DN, and standby DN. The default value is 7.
Return type: record
The command output is as follows.
Field |
Type |
Description |
|---|---|---|
nodename |
name |
Node name. |
instance_id |
text |
Instance name. |
pgscrf |
text |
Local path of the metadata file that records residual file information. |
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | SELECT * FROM pgxc_scan_residualfiles(); node_name | instance_id | pgscrf --------------+-------------+-------------------------------------------------------------------- dn_6001_6002 | dn_6001 | pg_residualfiles/pgscrf_meta_1663_16323_20231027144103839354 dn_6001_6002 | dn_6001 | pg_residualfiles/pgscrf_meta_2147484281_16323_20231027144103839826 cn_5001 | cn_5001 | pg_residualfiles/pgscrf_meta_1663_16323_20231027144103946217 dn_6007_6008 | dn_6008 | pg_residualfiles/pgscrf_meta_1663_16323_20231027144104171311 (4 rows) SELECT * FROM pgxc_scan_residualfiles(1); node_name | instance_id | pgscrf -----------+-------------+-------------------------------------------------------------- cn_5001 | cn_5001 | pg_residualfiles/pgscrf_meta_1663_16323_20231027144421861628 (1 row) SELECT * FROM pgxc_scan_residualfiles(2); node_name | instance_id | pgscrf --------------+-------------+-------------------------------------------------------------------- dn_6001_6002 | dn_6001 | pg_residualfiles/pgscrf_meta_1663_16323_20231027144424210395 dn_6001_6002 | dn_6001 | pg_residualfiles/pgscrf_meta_2147484281_16323_20231027144424210855 (2 rows) SELECT * FROM pgxc_scan_residualfiles(4); node_name | instance_id | pgscrf --------------+-------------+-------------------------------------------------------------- dn_6007_6008 | dn_6008 | pg_residualfiles/pgscrf_meta_1663_16323_20231027144427492060 (1 row) |
The restrictions on using this function are as follows:
Description: Obtains all residual file records scanned on the current node. This function is an instance-level function and is irrelevant to the current database. It can run on any instance.
Return type: record
The command output is as follows.
Field |
Type |
Description |
|---|---|---|
handled |
bool |
Whether residual files have been processed, moved, or modified. |
dbname |
text |
Database name |
residualfile |
text |
Path of the residual file |
size |
bigint |
File size, in bytes. For residual files in the OBS path, the value of this parameter is 0. |
inode |
bigint |
Inode in the stat information of the residual file. For residual files in the OBS path, the value of this parameter is 0. |
atime |
timestamptz |
Access time in the stat information of the residual file. For residual files in the OBS path, the value of this parameter is empty. |
mtime |
timestamptz |
Modify time in the stat information of the residual file. For residual files in the OBS path, the value of this parameter is empty. |
ctime |
timestamptz |
Change time in the stat information of the residual file. For residual files in the OBS path, the value of this parameter is empty. |
filepath |
text |
Local path of the metadata file that records residual file information, corresponding to the pgscrf_meta file. |
notes |
text |
Notes |
Description: Unified CN execution function of pg_get_scan_residualfiles() This function is a cluster-level function and is irrelevant to the current database. It runs on CNs.
The query_flag parameter is of the int type and indicates the execution range. 1 indicates the CN, 2 indicates the primary DN, and 4 indicates the standby DN. The query union set can be obtained through the OR operation. For example, 1|2=3 indicates the CN and primary DN, and 1|2|4=7 indicates the CN, primary DN, and standby DN. The default value is 7.
Return type: record
The command output is as follows.
Field |
Type |
Description |
|---|---|---|
nodename |
name |
Node name |
instance_id |
text |
Instance name |
handled |
bool |
Whether residual files have been processed, moved, or modified. |
dbname |
text |
Database name |
residualfile |
text |
Path of the residual file |
size |
bigint |
File size, in bytes. For residual files in the OBS path, the value of this parameter is 0. |
inode |
bigint |
Inode in the stat information of the residual file. For residual files in the OBS path, the value of this parameter is 0. |
atime |
timestamptz |
Access time in the stat information of the residual file. For residual files in the OBS path, the value of this parameter is empty. |
mtime |
timestamptz |
Modify time in the stat information of the residual file. For residual files in the OBS path, the value of this parameter is empty. |
ctime |
timestamptz |
Change time in the stat information of the residual file. For residual files in the OBS path, the value of this parameter is empty. |
filepath |
text |
Local path of the metadata file that records residual file information, corresponding to the pgscrf_meta file. |
notes |
text |
Notes |
Description: Archives all residual file records scanned on the database connected to the current node. This function is an instance-level function and is related to the current database. It can run on any instance.
Return type: record
The command output is as follows.
Field |
Type |
Description |
|---|---|---|
archive |
text |
Path of the local folder after archiving. Residual files in the OBS path are archived in the corresponding OBS database directory. |
count |
bigint |
Number of archived residual files. |
size |
bigint |
Total size of archived residual files, in bytes. |
Example:
1 2 3 4 5 | SELECT * FROM pg_archive_scan_residualfiles(); archive | count | size --------------------------------------------------------------+-------+------- pg_residualfiles/archive/pgscrf_archive_20231027144613791801 | 4 | 81920 (1 row) |
Description: Unified CN execution function of pg_archive_scan_residualfiles() This function is a cluster-level function and is related to the current database. It runs on CNs.
The query_flag parameter is of the int type and indicates the execution range. 1 indicates the CN, 2 indicates the primary DN, and 4 indicates the standby DN. The query union set can be obtained through the OR operation. For example, 1|2=3 indicates the CN and primary DN, and 1|2|4=7 indicates the CN, primary DN, and standby DN. The default value is 7.
Return type: record
The command output is as follows.
Field |
Type |
Description |
|---|---|---|
nodename |
name |
Node name. |
instance_id |
text |
Instance name. |
archive |
text |
Path of the local folder after archiving. Residual files in the OBS path are archived in the corresponding OBS database directory. |
count |
bigint |
Number of archived residual files. |
size |
bigint |
Total size of archived residual files, in bytes. |
Example:
1 2 3 4 5 6 | SELECT * FROM pgxc_archive_scan_residualfiles(); node_name | instance_id | archive | count | size --------------+-------------+--------------------------------------------------------------+-------+------- cn_5001 | cn_5001 | pg_residualfiles/archive/pgscrf_archive_20231027145050896440 | 1 | 40960 dn_6007_6008 | dn_6008 | pg_residualfiles/archive/pgscrf_archive_20231027145051018138 | 1 | 24576 (2 rows) |
Description: Deletes all archived residual file records on the current node. This function is an instance-level function and is irrelevant to the current database. It can run on any instance.
Return type: record
The command output is as follows.
Field |
Type |
Description |
|---|---|---|
count |
bigint |
Number of residual files that have been deleted from the archive. For residual files in the local path, the number of deleted files is counted. For residual files in the OBS path, the number of deleted table directories is counted. |
size |
bigint |
Total size of residual files that have been deleted from the archive, in bytes. For residual files in the OBS path, the value of this parameter is 0. |
Example:
1 2 3 4 5 | SELECT * FROM pg_rm_scan_residualfiles_archive(); count | size -------+------- 4 | 81920 (1 row) |
Description: Unified CN execution function of pg_rm_scan_residualfiles_archive() This function is a cluster-level function and is irrelevant to the current database. It runs on CNs.
The query_flag parameter is of the int type and indicates the execution range. 1 indicates the CN, 2 indicates the primary DN, and 4 indicates the standby DN. The query union set can be obtained through the OR operation. For example, 1|2=3 indicates the CN and primary DN, and 1|2|4=7 indicates the CN, primary DN, and standby DN. The default value is 7.
Return type: record
The command output is as follows.
Field |
Type |
Description |
|---|---|---|
nodename |
name |
Node name. |
instance_id |
text |
Instance name. |
count |
bigint |
Number of residual files that have been deleted from the archive. For residual files in the local path, the number of deleted files is counted. For residual files in the OBS path, the number of deleted table directories is counted. |
size |
bigint |
Total size of residual files that have been deleted from the archive, in bytes. For residual files in the OBS path, the value of this parameter is 0. |
Example:
1 2 3 4 5 6 7 8 | SELECT * FROM pgxc_rm_scan_residualfiles_archive(); node_name | instance_id | count | size --------------+-------------+-------+------- dn_6001_6002 | dn_6001 | 4 | 81920 cn_5001 | cn_5001 | 1 | 40960 dn_6007_6008 | dn_6008 | 1 | 24576 coordinator1 | coordinator1| 1 | 0 (4 rows) |