diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index a3309beebcf..ba2fbdcf02a 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5341,7 +5341,7 @@ readRecoveryCommandFile(void) else if (strcmp(item->name, "recovery_target_xid") == 0) { errno = 0; - recoveryTargetXid = (TransactionId) strtoul(item->value, NULL, 0); + recoveryTargetXid = (TransactionId) pg_strtouint64(item->value, NULL, 0); if (errno == EINVAL || errno == ERANGE) ereport(FATAL, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), diff --git a/src/test/recovery/t/003_recovery_targets.pl b/src/test/recovery/t/003_recovery_targets.pl index 824fa4da529..aff5402226d 100644 --- a/src/test/recovery/t/003_recovery_targets.pl +++ b/src/test/recovery/t/003_recovery_targets.pl @@ -47,6 +47,10 @@ sub test_recovery_standby my $node_master = get_new_node('master'); $node_master->init(has_archiving => 1, allows_streaming => 1); +# Bump the transaction ID epoch. This is useful to stress the portability +# of recovery_target_xid parsing. +system_or_bail('pg_resetwal', '-e', '1', $node_master->data_dir); + # Start it $node_master->start;