Restoration Control Functions
Restoration control functions provide information about the status of standby nodes. These functions may be executed both during restoration and in normal running.
pg_is_in_recovery()
Description: Returns true if restoration is still in progress.
Return type: Boolean
pg_last_xlog_receive_location()
Description: Obtains the last transaction log location received and synchronized to disk by streaming replication. While streaming replication is in progress, this will increase monotonically. If restoration has been completed, then this value will remain static at the value of the last WAL record received and synchronized to disk during restoration. If streaming replication is disabled or if it has not yet started, the function returns a null value.
Return type: text
pg_last_xlog_replay_location()
Description: Obtains last transaction log location replayed during restoration. If restoration is still in progress, this will increase monotonically. If restoration has been completed, then this value will remain static at the value of the last WAL record received during that restoration. When the server has been started normally without restoration, the function returns a null value.
Return type: text
pg_last_xact_replay_timestamp()
Description: Obtains the timestamp of last transaction replayed during restoration. This is the time to commit a transaction or abort a WAL record on the primary node. If no transactions have been replayed during restoration, this function will return a null value. If restoration is still in progress, this will increase monotonically. If restoration has been completed, then this value will remain static at the value of the last WAL record received during that restoration. If the server normally starts without manual intervention, this function will return a null value.
Return type: timestamp with time zone
Restoration control functions control restoration threads. These functions may be executed only during restoration.
pg_is_xlog_replay_paused()
Description: Returns true if restoration is paused.
Return type: Boolean
pg_xlog_replay_pause()
Description: Pauses restoration immediately.
Return type: void
pg_xlog_replay_resume()
Description: Restarts restoration if it was paused.
Return type: void
gs_get_active_archiving_standby()
Description: Queries information about archive standby nodes in the same shard. The standby node name, archive location, and number of archived logs are returned.
Return type: text or int
gs_pitr_get_warning_for_xlog_force_recycle()
Description: Checks whether logs are recycled because a large number of logs are stacked in the archive slot after archiving is enabled.
Return type: Boolean
gs_pitr_clean_history_global_barriers(stop_barrier_timestamp cstring)
Description: Clears all barrier records generated before the specified time. The earliest barrier record is returned. The input parameter is of the cstring type and is a Linux timestamp. You need to perform this operation as an administrator or O&M administrator.
Return type: text
gs_pitr_archive_slot_force_advance(stop_barrier_timestamp cstring)
Description: Forcibly updates the archive slot and clears unnecessary barrier records. The new archive slot location is returned. The input parameter is of the cstring type and is a Linux timestamp. You need to perform this operation as an administrator or O&M administrator.
Return type: text
gs_recent_barrier_buffer_info(start_time text, end_time text)
Description: Queries barrier information based on the time range entered by the user to obtain time_stamp, CSN, LSN, and standard_time.
Return type: records
gaussdb=# SELECT * FROM gs_recent_barrier_buffer_info('2024-01-15 23:27:50', '2024-01-15 23:28:00');
timestamp | lsn | csn | standard_time
------------+-------------------+----------+---------------------
1705332470 | 00000000/15FFBBA0 | 41020421 | 2024-01-15 23:27:50
1705332471 | 00000000/15FFBDF0 | 41020422 | 2024-01-15 23:27:51
1705332472 | 00000000/15FFC058 | 41020423 | 2024-01-15 23:27:52
1705332472 | 00000000/15FFC0F8 | 41020424 | 2024-01-15 23:27:52
1705332473 | 00000000/15FFC348 | 41020425 | 2024-01-15 23:27:53
1705332474 | 00000000/15FFC598 | 41020426 | 2024-01-15 23:27:54
1705332475 | 00000000/15FFC638 | 41020427 | 2024-01-15 23:27:55
1705332476 | 00000000/15FFC888 | 41020428 | 2024-01-15 23:27:56
1705332476 | 00000000/15FFDC80 | 41020433 | 2024-01-15 23:27:56
1705332477 | 00000000/15FFDD20 | 41020434 | 2024-01-15 23:27:57
1705332478 | 00000000/15FFDF70 | 41020435 | 2024-01-15 23:27:58
1705332479 | 00000000/15FFE1D8 | 41020436 | 2024-01-15 23:27:59
1705332480 | 00000000/15FFE278 | 41020437 | 2024-01-15 23:28:00
1705332480 | 00000000/15FFE4C8 | 41020438 | 2024-01-15 23:28:00
(14 rows)
gs_show_obs_media_files(slot_name cstring, src cstring, offset int32, limit int32)
Description: Queries the OBS file list based on the archive slot (slot_name) and OBS directory address (src) entered by the user.
Return type: records
gaussdb=# SELECT gs_show_obs_media_files('ssh','cn_5001/pg_xlog',1, 5);
gs_show_obs_media_files
-------------------------------------------------------------------------------------------------
(wstdist_ssh/archive/cn_5001/pg_xlog/000000010000000000000010_01_01_00000000_00000000_00000003)
(wstdist_ssh/archive/cn_5001/pg_xlog/000000010000000000000010_02_01_00000000_00000000_00000003)
(wstdist_ssh/archive/cn_5001/pg_xlog/000000010000000000000010_03_01_00000000_00000000_00000003)
(wstdist_ssh/archive/cn_5001/pg_xlog/000000010000000000000011_00_01_00000000_00000000_00000003)
(wstdist_ssh/archive/cn_5001/pg_xlog/000000010000000000000011_01_01_00000000_00000000_00000003)
(5 rows)
gs_upload_obs_media_file(slot_name cstring, src cstring, dest cstring, is_forced bool)
Description: Uploads OBS files based on the archive slot (slot_name), source address (src), OBS address (dest), and whether to forcibly upload files (is_forced).
Return type: void
gaussdb=# SELECT * FROM gs_upload_obs_media_file('ssh', '/data/gauss/log/stwang/test/000000010000000000000019_02_01_00000000_00000000_00000003', 'cn_5001/pg_xlog/000000010000000000000019_02_01_00000000_00000000_00000003', true);
gs_upload_obs_media_file
----------------------------
(1 row)
gs_download_obs_media_file(slot_name cstring, src cstring, dest cstring)
Description: Downloads OBS files based on the archive slot (slot_name), download source address (src), and local destination address (dest).
Return type: void
gaussdb=# SELECT * FROM gs_download_obs_media_file('ssh','cn_5001/pg_xlog/000000010000000000000019_02_01_00000000_00000000_00000003','/data/gauss/log/stwang/test');
gs_download_obs_media_file
------------------------------
(1 row)
While restoration is paused, no further database changes are applied. In hot standby mode, all new queries will see the same consistent snapshot of the database, and no further query conflicts will be generated until restoration is resumed.
If streaming replication is disabled, the paused state may continue indefinitely without problem. While streaming replication is in progress, WAL records will continue to be received, which will eventually fill available disk space. This progress depends on the duration of the pause, the rate of WAL generation, and available disk space.
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