forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit6db2703
committed
Fix portability issues with parsing of recovery_target_xid
The parsing of this parameter has been using strtoul(), which is notportable across platforms. On most Unix platforms, unsigned long has asize of 64 bits, while on Windows it is 32 bits. It is common inrecovery scenarios to rely on the output of txid_current() or even thenewer pg_current_xact_id() to get a transaction ID for setting uprecovery_target_xid. The value returned by those functions includes theepoch in the computed result, which would cause strtoul() to fail whereunsigned long has a size of 32 bits once the epoch is incremented.WAL records and 2PC data include only information about 32-bit XIDs andit is not possible to have XIDs across more than one epoch, sodiscarding the high bits from the transaction ID set has no impact onrecovery. On the contrary, the use of strtoul() prevents a consistentbehavior across platforms depending on the size of unsigned long.This commit changes the parsing of recovery_target_xid to usepg_strtouint64() instead, available down to 9.6. There is one TAP teststressing recovery with recovery_target_xid, where a tweak based onpg_reset{xlog,wal} is added to bump the XID epoch so as this change getstested, as per an idea from Alexander Lakhin.Reported-by: Alexander LakhinDiscussion:https://postgr.es/m/16780-107fd0c0385b1035@postgresql.orgBackpatch-through: 9.61 parentff76983 commit6db2703
File tree
2 files changed
+5
-1
lines changed- src
- backend/utils/misc
- test/recovery/t
2 files changed
+5
-1
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
11938 | 11938 |
| |
11939 | 11939 |
| |
11940 | 11940 |
| |
11941 |
| - | |
| 11941 | + | |
11942 | 11942 |
| |
11943 | 11943 |
| |
11944 | 11944 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
50 | 50 |
| |
51 | 51 |
| |
52 | 52 |
| |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
53 | 57 |
| |
54 | 58 |
| |
55 | 59 |
| |
|
0 commit comments
Comments
(0)