diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 2556bddcdf..9c72fe711b 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5409,7 +5409,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 e867479f20..8051cf806b 100644 --- a/src/test/recovery/t/003_recovery_targets.pl +++ b/src/test/recovery/t/003_recovery_targets.pl @@ -49,6 +49,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;