{"Entry":{"collection":"guc","key":"recovery_target_action","name":"recovery_target_action","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Write-Ahead Log / Recovery Target","category_zh":"","changed_in":[],"changes":[{"documentation_changed":false,"fields":{},"from":"11","status":"added","to":"12"},{"documentation_changed":true,"fields":{},"from":"12","status":"changed","to":"13"},{"documentation_changed":true,"fields":{},"from":"13","status":"changed","to":"14"},{"documentation_changed":true,"fields":{},"from":"14","status":"changed","to":"15"},{"documentation_changed":true,"fields":{},"from":"15","status":"changed","to":"16"},{"documentation_changed":true,"fields":{},"from":"16","status":"changed","to":"17"},{"documentation_changed":true,"fields":{},"from":"17","status":"changed","to":"18"},{"documentation_changed":true,"fields":{},"from":"18","status":"changed","to":"19"},{"documentation_changed":true,"fields":{},"from":"19","status":"changed","to":"20"}],"content_hash":"9192c64eed5cddbb947811c0245de00217f26d01041e7a3594915436d14c1050","context":"","default_changed_in":[],"default_history":[{"from":"12","to":"19","value":"pause"}],"editorial":{"advice":{"olap":"For a large restore, budget WAL replay and inspection time first. Validate the reached point read-only; do not let heavy analytical queries delay or contaminate the recovery decision.","oltp":"This is not a steady-state performance knob. Set recovery_target_action only on an isolated recovery instance after recording target evidence, base backup, timeline, and expected boundary; rehearse and require a second-person review.","small":"Prefer a backup tool that generates a controlled recovery configuration. Never leave target settings in ordinary primary/standby templates, and clean up signal files and targets afterward."},"mechanism":["Selects what PostgreSQL does after it reaches a configured recovery target. The value is read when recovery starts.","pause leaves recovery paused for inspection, promote ends recovery and opens the server for normal service, and shutdown stops the server at the target. pause requires hot_standby for query inspection.","The setting has no effect without a stopping target. With shutdown, recovery.signal is not removed, so an unchanged restart reaches the target and shuts down again; remove or change the recovery configuration deliberately after validation."],"pitfalls":["Expecting an action when no stopping target is configured.","Using pause with hot_standby disabled and expecting to inspect the database with queries.","Using promote before the recovered state has been verified.","Using shutdown and restarting with recovery.signal and the same target still present.","Treating shutdown as permanent removal of later WAL; the next start still replays from the last checkpoint to the target."],"references":[{"title":"PostgreSQL 19 Beta 4: recovery_target_action","url":"https://www.postgresql.org/docs/19/runtime-config-wal.html#GUC-RECOVERY-TARGET-ACTION"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["recovery_target","recovery_target_time","recovery_target_lsn","recovery_target_inclusive","recovery_target_timeline","hot_standby"],"summary":"recovery_target_action sets the action to perform upon reaching the recovery target. It is a postmaster setting present in PG12–18; the latest recorded boot default is pause."},"enumvals":[],"first_version":"12","group":"Write-Ahead Log","group_slug":"wal","imported_at":"2026-09-27T17:57:31.875341+08:00","intro_commit":{"authored_at":"2018-11-25T16:31:16+01:00","discussion":["https://www.postgresql.org/message-id/flat/607741529606767@web3g.yandex.ru/"],"hash":"2dedf4d9a899b36d1a8ed29be5efbd1b31a8fe85","subject":"Integrate recovery.conf into postgresql.conf","url":"https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=2dedf4d9a899b36d1a8ed29be5efbd1b31a8fe85"},"key":"recovery_target_action","last_version":"20","max_val":"","min_val":"","name":"recovery_target_action","position":326,"present_in":["12","13","14","15","16","17","18","19","20"],"short_desc":"Specifies what action the server should take once the recovery target is reached.","short_desc_zh":"","source_rev":"english-manuals:3f241cbf180d93dc3cb3f8e98e142c563f24a11a5e2fad9d809cd28198407090","unit":"","vartype":"enum"}},"Definition":{"Collection":"guc","Key":"recovery_target_action","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"recovery_target_action","SourceRevision":"english-manuals:3f241cbf180d93dc3cb3f8e98e142c563f24a11a5e2fad9d809cd28198407090","Facts":{"boot_val":"pause","category":"Write-Ahead Log / Recovery Target","context":"postmaster","description":"Specifies what action the server should take once the recovery target is reached. The default is pause, which means recovery will be paused. promote means the recovery process will finish and the server will start to accept connections. Finally shutdown will stop the server after reaching the recovery target. The intended use of the pause setting is to allow queries to be executed against the database to check if this recovery target is the most desirable point for recovery. The paused state can be resumed by using pg_wal_replay_resume() (see Table 9.99), which then causes recovery to end. If this recovery target is not the desired stopping point, then shut down the server, change the recovery target settings to a later target and restart to continue recovery. The shutdown setting is useful to have the instance ready at the exact replay point desired. The instance will still be able to replay more WAL records (and in fact will have to replay WAL records since the last checkpoint next time it is started). Note that because recovery.signal will not be removed when recovery_target_action is set to shutdown, any subsequent start will end with immediate shutdown unless the configuration is changed or the recovery.signal file is removed manually. This setting has no effect if no recovery target is set. If hot_standby is not enabled, a setting of pause will act the same as shutdown. If the recovery target is reached while a promotion is ongoing, a setting of pause will act the same as promote. In any case, if a recovery target is configured but the archive recovery ends before the target is reached, the server will shut down with a fatal error.","doc":{"anchor":"GUC-RECOVERY-TARGET-ACTION","file":"runtime-config-wal.html","lang":"en","sha256":"d2646404a06e8f7ac655204b4f28c049ae8f3fd4f2272db080fcefa2c4af0763","slug":"18"},"documented":true,"enumvals":["pause","promote","shutdown"],"extra_desc":null,"lang":"en","max_val":null,"metadata_version":"18","min_val":null,"name":"recovery_target_action","short_desc":"Sets the action to perform upon reaching the recovery target.","source":"pg-settings-source-snapshot","unit":null,"vartype":"enum"},"ManualEvidence":{"doc":{"anchor":"GUC-RECOVERY-TARGET-ACTION","file":"runtime-config-wal.html","lang":"en","sha256":"d2646404a06e8f7ac655204b4f28c049ae8f3fd4f2272db080fcefa2c4af0763","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"recovery_target_action","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"recovery_target_action","Summary":"","BodyHTML":"\u003cp\u003e指定在达到恢复目标时服务器应该立刻采取的动作。默认动作是\u003ccode\u003epause\u003c/code\u003e，这表示恢复将会被暂停。\u003ccode\u003epromote\u003c/code\u003e表示恢复处理将会结束并且服务器将开始接受连接。最后，\u003ccode\u003eshutdown\u003c/code\u003e将在达到恢复目标之后停止服务器。\u003c/p\u003e\u003cp\u003e使用\u003ccode\u003epause\u003c/code\u003e设置的目的是允许对数据库执行查询，以检查这个恢复目标是否为最合适的恢复位置。暂停的状态可以使用\u003ccode\u003epg_wal_replay_resume()\u003c/code\u003e（见\u003ca href=\"/docs/18/functions-admin.html#FUNCTIONS-RECOVERY-CONTROL-TABLE\" rel=\"nofollow\"\u003e表 9.99\u003c/a\u003e）继续，这会让恢复终结。如果这个恢复目标不是想要的停止点，那么关闭服务器，将恢复目标设置改为一个稍后的目标并且重启以继续恢复。\u003c/p\u003e\u003cp\u003e要让实例在想要的重放点那里准备好，\u003ccode\u003eshutdown\u003c/code\u003e设置可以派上用场。该实例将仍能重放更多 WAL 记录（并且事实上，下次启动时必须重新回放自上一个检查点以来的 WAL 记录）。\u003c/p\u003e\u003cp\u003e注意由于在\u003ccode\u003erecovery_target_action\u003c/code\u003e被设置为\u003ccode\u003eshutdown\u003c/code\u003e时，\u003ccode\u003erecovery.signal\u003c/code\u003e将不会被移除，任何后续的启动都将会以立刻关闭为终结，除非该配置被改变或者\u003ccode\u003erecovery.signal\u003c/code\u003e文件被手工移除。\u003c/p\u003e\u003cp\u003e如果没有设置恢复目标，这个设置没有效果。如果没有启用\u003ca href=\"/docs/18/runtime-config-replication.html#GUC-HOT-STANDBY\" rel=\"nofollow\"\u003ehot_standby\u003c/a\u003e，\u003ccode\u003epause\u003c/code\u003e设置的动作将和\u003ccode\u003eshutdown\u003c/code\u003e一样。如果在备库提升期间达到恢复目标，\u003ccode\u003epause\u003c/code\u003e 的设置将与 \u003ccode\u003epromote\u003c/code\u003e的行为相同。\u003c/p\u003e\u003cp\u003e在任何情况下，如果已配置了恢复目标，但归档恢复在达到目标之前结束，则服务器将关闭，并出现致命错误。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"471eac9d100ea16f61ea537867e553ecb6176a34d6f6e0c6c54c3286abfef3dd","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e指定在达到恢复目标时服务器应该立刻采取的动作。默认动作是\u003ccode class=\"literal\"\u003epause\u003c/code\u003e，这表示恢复将会被暂停。\u003ccode class=\"literal\"\u003epromote\u003c/code\u003e表示恢复处理将会结束并且服务器将开始接受连接。最后，\u003ccode class=\"literal\"\u003eshutdown\u003c/code\u003e将在达到恢复目标之后停止服务器。\u003c/p\u003e\u003cp\u003e使用\u003ccode class=\"literal\"\u003epause\u003c/code\u003e设置的目的是允许对数据库执行查询，以检查这个恢复目标是否为最合适的恢复位置。暂停的状态可以使用\u003ccode class=\"function\"\u003epg_wal_replay_resume()\u003c/code\u003e（见\u003ca href=\"/docs/18/functions-admin.html#FUNCTIONS-RECOVERY-CONTROL-TABLE\" title=\"表 9.99. 恢复控制函数\"\u003e表 9.99\u003c/a\u003e）继续，这会让恢复终结。如果这个恢复目标不是想要的停止点，那么关闭服务器，将恢复目标设置改为一个稍后的目标并且重启以继续恢复。\u003c/p\u003e\u003cp\u003e要让实例在想要的重放点那里准备好，\u003ccode class=\"literal\"\u003eshutdown\u003c/code\u003e设置可以派上用场。该实例将仍能重放更多 WAL 记录（并且事实上，下次启动时必须重新回放自上一个检查点以来的 WAL 记录）。\u003c/p\u003e\u003cp\u003e注意由于在\u003ccode class=\"varname\"\u003erecovery_target_action\u003c/code\u003e被设置为\u003ccode class=\"literal\"\u003eshutdown\u003c/code\u003e时，\u003ccode class=\"filename\"\u003erecovery.signal\u003c/code\u003e将不会被移除，任何后续的启动都将会以立刻关闭为终结，除非该配置被改变或者\u003ccode class=\"filename\"\u003erecovery.signal\u003c/code\u003e文件被手工移除。\u003c/p\u003e\u003cp\u003e如果没有设置恢复目标，这个设置没有效果。如果没有启用\u003ca href=\"/docs/18/runtime-config-replication.html#GUC-HOT-STANDBY\"\u003ehot_standby\u003c/a\u003e，\u003ccode class=\"literal\"\u003epause\u003c/code\u003e设置的动作将和\u003ccode class=\"literal\"\u003eshutdown\u003c/code\u003e一样。如果在备库提升期间达到恢复目标，\u003ccode class=\"literal\"\u003epause\u003c/code\u003e 的设置将与 \u003ccode class=\"literal\"\u003epromote\u003c/code\u003e的行为相同。\u003c/p\u003e\u003cp\u003e在任何情况下，如果已配置了恢复目标，但归档恢复在达到目标之前结束，则服务器将关闭，并出现致命错误。\u003c/p\u003e","doc_same_as":""}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["12","13","14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
