PostgreSQL 8.4devel Documentation | ||||
---|---|---|---|---|
Prev | Fast Backward | Chapter 9. Functions and Operators | Fast Forward | Next |
The functions shown in Table 9-56 assist in archive recovery. Except for the first three functions, these are restricted to superusers. All of these functions can only be executed during recovery.
Table 9-56. Recovery Control Functions
Name | Return Type | Description |
---|---|---|
pg_is_in_recovery ()
| bool | True if recovery is still in progress. |
pg_last_completed_xact_timestamp ()
| timestamp with time zone | Returns the original completion timestamp with timezone of the last completed transaction in the current recovery. |
pg_last_completed_xid ()
| integer | Returns the transaction id (32-bit) of last completed transaction in the current recovery. Later numbered transaction ids may already have completed. This is unrelated to transactions on the source server. |
pg_recovery_pause ()
| void | Pause recovery processing, unconditionally. |
pg_recovery_continue ()
| void | If recovery is paused, continue processing. |
pg_recovery_stop ()
| void | End recovery and begin normal processing. |
pg_recovery_pause_xid ()
| void | Continue recovery until specified xid completes, if it is ever seen, then pause recovery. |
pg_recovery_pause_time ()
| void | Continue recovery until a transaction with specified timestamp completes, if one is ever seen, then pause recovery. |
pg_recovery_pause_cleanup ()
| void | Continue recovery until the next cleanup record, then pause. |
pg_recovery_pause_advance ()
| void | Advance recovery specified number of records then pause. |
pg_recovery_pause
and pg_recovery_continue
allow
a superuser to control the progress of recovery of the database server.
This allows queries to be executed to determine how far recovery should
progress. If the superuser wishes recovery to complete and normal
processing mode to start, execute pg_recovery_stop
.
Variations of the pause function exist, mainly to allow PITR to dynamically
control where it should progress to. pg_recovery_pause_xid
and
pg_recovery_pause_time
allow the specification of a trial
recovery target. Recovery will then progress to that point, and then the
database can be inspected to see if this is the correct stopping point.
pg_recovery_pause_cleanup
allows recovery to progress only
as far as the next cleanup record. This is useful where a longer running
query needs to access the database in a consistent state and it is
more important that the query executes than it is that we keep processing
new WAL records. This can be used as shown:
select pg_recovery_pause_cleanup(); -- run very important query select from big_table1 join big_table2 on ... where ... select pg_recovery_continue;
pg_recovery_advance
allows recovery to progress record by
record, for very careful analysis or debugging. Step size can be 1 or
more records. If recovery is not yet paused then pg_recovery_advance
will process the specified number of records then pause. If recovery
is already paused, recovery will continue for another N records before
pausing again.
If you pause recovery while the server is waiting for a WAL file when operating in standby mode it will have apparently no effect until the file arrives. Once the server begins processing WAL records again it will notice the pause request and will act upon it. This is not a bug. pause.