Improve checks for GUC recovery_target_xid
David Steele <david@pgbackrest.org>
From: David Steele <david@pgbackrest.org>
To: Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2026-02-20T05:41:59Z
Lists: pgsql-hackers
Attachments
- recovery-target-xid-v1.patch (text/plain) patch v1
Hackers, Currently check_recovery_target_xid() converts invalid values to 0. So, for example, the following configuration added to postgresql.conf followed by a startup: recovery_target_xid = 'bogus' recovery_target_xid = '1.1' recovery_target_xid = '0' ... does not generate an error but recovery does not complete. There are many values that can prevent recovery from completing but we should at least catch obvious misconfiguration by the user. The origin of the problem is that we do not perform a range check in the GUC value passed-in for recovery_target_xid. This commit improves the situation by using adding end checking to strtou64() and by providing stricter range checks. Some test cases are added for the cases of an incorrect or a lower-bound timeline value, checking the sanity of the reports based on the contents of the server logs. Also add a comment that truncation of the input value is expected since users will generally be using the output from pg_current_xact_id() (or similar) to set recovery_target_xid (just as our tests do). This patch was promised in [1] -- here at last! Regards, -David [1] https://www.postgresql.org/message-id/cf04b7c6-7774-4ffb-86f5-ca85462d5fd6%40pgbackrest.org
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Improve tests for recovery_target_timeline GUC.
- 2007df43332b 19 (unreleased) landed
-
Improve validation of recovery_target_xid GUC values.
- bffd7130e942 19 (unreleased) landed