The pgxc residual file management function only operates on the CN and the current primary DN, and does not verify or clear residual files on the standby DN. Therefore, after the primary DN is cleared, you need to clear residual files on the standby DN or build the standby DN in a timely manner. This prevents residual files on the standby DN from being copied back to the primary DN due to incremental build after a primary/standby switchover.
The following example uses two user-created databases, db1 and db2.
1 | db1=# select * from pgxc_get_residualfiles() order by 4, 6; -- order by is optional. |
In the current cluster:
1 | db1=# SELECT * FROM pgxc_verify_residualfiles(); |
Verification functions are at the database level. Therefore, when a verification function is called in the db1 database, it only verifies residual files in db1.
You can call the get function again to check whether the verification is complete.
1 | db1=# SELECT * FROM pgxc_get_residualfiles() order by 4, 6; |
As shown in the preceding figure, the residual files in the db1 database have been verified, and the residual files in the db2 database are not verified.
1 | db1=# SELECT * FROM pgxc_rm_residualfiles(); |
The result shows that the residual files in the db1 database are deleted (isdeleted is marked as t) and the residual files in the db2 database are not deleted.
In addition, nine query results are displayed. Compared with the previous query results, a record for the residual file ending with 9438 is missing. This is because the record file that records the residual file ending with 9438 contains only one record, which is deleted in step 3. If all residual files in a record file are deleted, the record file is also deleted. Deleted files are backed up in the pg_residualfiles/backup directory.
Query the verification result:
All residual files recorded in the record file whose name ends with 8342 have been deleted, so the record file is deleted and backed up in the backup directory. As a result, no records are found.