Hi,
I've been puzzled by this message:
~~~
LOG: fetching timeline history file for timeline 17 from primary server
FATAL: could not receive timeline history file from the primary server:
ERROR: could not open file "pg_xlog/00000011.history": No such file or
directory
~~~
It took me a while to understand that the timeline id 11 in hexadecimal
is the same as the timeline id 17 in decimal.
It appears that the first message is formatted with %u instead of %X,
and there some others places with the some format, while WAL filename
and history file used hexadecimal.
There is another place where timeline id is used : pg_waldump, and in
these tools, timeline id ( -t or --timeline ) should be given in
decimal, while filename gives it in hexadecimal : imho, it's not
user-friendly, and can lead to user's bad input for timeline id.
The attached patch proposes to change the format of timelineid from %u
to %X.
Regarding .po files, I don't know how to manage them. Is there any
routine to spread the modifications? Or should I identify and change
each message?
best regards,
--
Sébastien
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index f390c177e4..77b0fbc962 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -45,7 +45,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
CheckPoint *checkpoint = (CheckPoint *) rec;
appendStringInfo(buf, "redo %X/%X; "
- "tli %u; prev tli %u; fpw %s; xid %u:%u; oid %u; multi %u; offset %u; "
+ "tli %X; prev tli %X; fpw %s; xid %u:%u; oid %u; multi %u; offset %u; "
"oldest xid %u in DB %u; oldest multi %u in DB %u; "
"oldest/newest commit timestamp xid: %u/%u; "
"oldest running xid %u; %s",
@@ -135,7 +135,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
xl_end_of_recovery xlrec;
memcpy(&xlrec, rec, sizeof(xl_end_of_recovery));
- appendStringInfo(buf, "tli %u; prev tli %u; time %s",
+ appendStringInfo(buf, "tli %X; prev tli %X; time %s",
xlrec.ThisTimeLineID, xlrec.PrevTimeLineID,
timestamptz_to_str(xlrec.end_time));
}
diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c
index aa6c929477..97ff6e80b6 100644
--- a/src/backend/access/transam/xlogreader.c
+++ b/src/backend/access/transam/xlogreader.c
@@ -1329,7 +1329,7 @@ XLogReaderValidatePageHeader(XLogReaderState *state, XLogRecPtr recptr,
XLogFileName(fname, state->seg.ws_tli, segno, state->segcxt.ws_segsize);
report_invalid_record(state,
- "out-of-sequence timeline ID %u (after %u) in WAL segment %s, LSN %X/%X, offset %u",
+ "out-of-sequence timeline ID %X (after %X) in WAL segment %s, LSN %X/%X, offset %u",
hdr->xlp_tli,
state->latestPageTLI,
fname,
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 2a5352f879..c814ef2767 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -3080,7 +3080,7 @@ ReadRecord(XLogPrefetcher *xlogprefetcher, int emode,
XLogFileName(fname, xlogreader->seg.ws_tli, segno,
wal_segment_size);
ereport(emode_for_corrupt_record(emode, xlogreader->EndRecPtr),
- (errmsg("unexpected timeline ID %u in WAL segment %s, LSN %X/%X, offset %u",
+ (errmsg("unexpected timeline ID %X in WAL segment %s, LSN %X/%X, offset %u",
xlogreader->latestPageTLI,
fname,
LSN_FORMAT_ARGS(xlogreader->latestPagePtr),
@@ -3719,7 +3719,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
tli = tliOfPointInHistory(tliRecPtr, expectedTLEs);
if (curFileTLI > 0 && tli < curFileTLI)
- elog(ERROR, "according to history file, WAL location %X/%X belongs to timeline %u, but previous recovered WAL file came from timeline %u",
+ elog(ERROR, "according to history file, WAL location %X/%X belongs to timeline %X, but previous recovered WAL file came from timeline %X",
LSN_FORMAT_ARGS(tliRecPtr),
tli, curFileTLI);
}
@@ -4019,7 +4019,7 @@ rescanLatestTimeLine(TimeLineID replayTLI, XLogRecPtr replayLSN)
if (!found)
{
ereport(LOG,
- (errmsg("new timeline %u is not a child of database system timeline %u",
+ (errmsg("new timeline %X is not a child of database system timeline %X",
newtarget,
replayTLI)));
return false;
@@ -4033,7 +4033,7 @@ rescanLatestTimeLine(TimeLineID replayTLI, XLogRecPtr replayLSN)
if (currentTle->end < replayLSN)
{
ereport(LOG,
- (errmsg("new timeline %u forked off current database system timeline %u before current recovery point %X/%X",
+ (errmsg("new timeline %X forked off current database system timeline %X before current recovery point %X/%X",
newtarget,
replayTLI,
LSN_FORMAT_ARGS(replayLSN))));
@@ -4052,7 +4052,7 @@ rescanLatestTimeLine(TimeLineID replayTLI, XLogRecPtr replayLSN)
restoreTimeLineHistoryFiles(oldtarget + 1, newtarget);
ereport(LOG,
- (errmsg("new target timeline is %u",
+ (errmsg("new target timeline is %X",
recoveryTargetTLI)));
return true;
diff --git a/src/backend/backup/backup_manifest.c b/src/backend/backup/backup_manifest.c
index fabd2ca299..1ea3facb67 100644
--- a/src/backend/backup/backup_manifest.c
+++ b/src/backend/backup/backup_manifest.c
@@ -250,7 +250,7 @@ AddWALInfoToBackupManifest(backup_manifest_info *manifest, XLogRecPtr startptr,
*/
if (first_wal_range && endtli != entry->tli)
ereport(ERROR,
- errmsg("expected end timeline %u but found timeline %u",
+ errmsg("expected end timeline %X but found timeline %X",
starttli, entry->tli));
/*
@@ -274,12 +274,12 @@ AddWALInfoToBackupManifest(backup_manifest_info *manifest, XLogRecPtr startptr,
*/
if (XLogRecPtrIsInvalid(entry->begin))
ereport(ERROR,
- errmsg("expected start timeline %u but found timeline %u",
+ errmsg("expected start timeline %X but found timeline %X",
starttli, entry->tli));
}
AppendToManifest(manifest,
- "%s{ \"Timeline\": %u, \"Start-LSN\": \"%X/%X\", \"End-LSN\": \"%X/%X\" }",
+ "%s{ \"Timeline\": %X, \"Start-LSN\": \"%X/%X\", \"End-LSN\": \"%X/%X\" }",
first_wal_range ? "" : ",\n",
entry->tli,
LSN_FORMAT_ARGS(tl_beginptr),
@@ -301,7 +301,7 @@ AddWALInfoToBackupManifest(backup_manifest_info *manifest, XLogRecPtr startptr,
*/
if (!found_start_timeline)
ereport(ERROR,
- errmsg("start timeline %u not found in history of timeline %u",
+ errmsg("start timeline %X not found in history of timeline %X",
starttli, endtli));
/* Terminate the list of WAL ranges. */
diff --git a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
index 560ec974fa..7c310c8ae2 100644
--- a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
+++ b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
@@ -564,7 +564,7 @@ libpqrcv_readtimelinehistoryfile(WalReceiverConn *conn,
/*
* Request the primary to send over the history file for given timeline.
*/
- snprintf(cmd, sizeof(cmd), "TIMELINE_HISTORY %u", tli);
+ snprintf(cmd, sizeof(cmd), "TIMELINE_HISTORY %X", tli);
res = libpqrcv_PQexec(conn->streamConn, cmd);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index b0cfddd548..a9702e5679 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -361,7 +361,7 @@ WalReceiverMain(void)
if (primaryTLI < startpointTLI)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("highest timeline %u of the primary is behind recovery timeline %u",
+ errmsg("highest timeline %X of the primary is behind recovery timeline %X",
primaryTLI, startpointTLI)));
/*
@@ -414,11 +414,11 @@ WalReceiverMain(void)
{
if (first_stream)
ereport(LOG,
- (errmsg("started streaming WAL from primary at %X/%X on timeline %u",
+ (errmsg("started streaming WAL from primary at %X/%X on timeline %X",
LSN_FORMAT_ARGS(startpoint), startpointTLI)));
else
ereport(LOG,
- (errmsg("restarted WAL streaming at %X/%X on timeline %u",
+ (errmsg("restarted WAL streaming at %X/%X on timeline %X",
LSN_FORMAT_ARGS(startpoint), startpointTLI)));
first_stream = false;
@@ -499,7 +499,7 @@ WalReceiverMain(void)
{
ereport(LOG,
(errmsg("replication terminated by primary server"),
- errdetail("End of WAL reached on timeline %u at %X/%X.",
+ errdetail("End of WAL reached on timeline %X at %X/%X.",
startpointTLI,
LSN_FORMAT_ARGS(LogstreamResult.Write))));
endofwal = true;
@@ -621,7 +621,7 @@ WalReceiverMain(void)
}
else
ereport(LOG,
- (errmsg("primary server contains no more WAL on requested timeline %u",
+ (errmsg("primary server contains no more WAL on requested timeline %X",
startpointTLI)));
/*
@@ -756,7 +756,7 @@ WalRcvFetchTimeLineHistoryFiles(TimeLineID first, TimeLineID last)
char expectedfname[MAXFNAMELEN];
ereport(LOG,
- (errmsg("fetching timeline history file for timeline %u from primary server",
+ (errmsg("fetching timeline history file for timeline %X from primary server",
tli)));
walrcv_readtimelinehistoryfile(wrconn, tli, &fname, &content, &len);
@@ -770,7 +770,7 @@ WalRcvFetchTimeLineHistoryFiles(TimeLineID first, TimeLineID last)
if (strcmp(fname, expectedfname) != 0)
ereport(ERROR,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg_internal("primary reported unexpected file name for timeline history file of timeline %u",
+ errmsg_internal("primary reported unexpected file name for timeline history file of timeline %X",
tli)));
/*
diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c
index 858d8d9f2f..d32dabe966 100644
--- a/src/bin/pg_rewind/pg_rewind.c
+++ b/src/bin/pg_rewind/pg_rewind.c
@@ -856,7 +856,7 @@ getTimelineHistory(ControlFileData *controlFile, int *nentries)
TimeLineHistoryEntry *entry;
entry = &history[i];
- pg_log_debug("%u: %X/%X - %X/%X", entry->tli,
+ pg_log_debug("%X: %X/%X - %X/%X", entry->tli,
LSN_FORMAT_ARGS(entry->begin),
LSN_FORMAT_ARGS(entry->end));
}
diff --git a/src/bin/pg_rewind/timeline.c b/src/bin/pg_rewind/timeline.c
index 2d445dac32..249f058255 100644
--- a/src/bin/pg_rewind/timeline.c
+++ b/src/bin/pg_rewind/timeline.c
@@ -67,7 +67,7 @@ rewind_parseTimeLineHistory(char *buffer, TimeLineID targetTLI, int *nentries)
if (*ptr == '\0' || *ptr == '#')
continue;
- nfields = sscanf(fline, "%u\t%X/%X", &tli, &switchpoint_hi, &switchpoint_lo);
+ nfields = sscanf(fline, "%X\t%X/%X", &tli, &switchpoint_hi, &switchpoint_lo);
if (nfields < 1)
{
diff --git a/src/bin/pg_verifybackup/pg_verifybackup.c b/src/bin/pg_verifybackup/pg_verifybackup.c
index 7634dfc285..2a54d7ab52 100644
--- a/src/bin/pg_verifybackup/pg_verifybackup.c
+++ b/src/bin/pg_verifybackup/pg_verifybackup.c
@@ -807,14 +807,14 @@ parse_required_wal(verifier_context *context, char *pg_waldump_path,
{
char *pg_waldump_cmd;
- pg_waldump_cmd = psprintf("\"%s\" --quiet --path=\"%s\" --timeline=%u --start=%X/%X --end=%X/%X\n",
+ pg_waldump_cmd = psprintf("\"%s\" --quiet --path=\"%s\" --timeline=%X --start=%X/%X --end=%X/%X\n",
pg_waldump_path, wal_directory, this_wal_range->tli,
LSN_FORMAT_ARGS(this_wal_range->start_lsn),
LSN_FORMAT_ARGS(this_wal_range->end_lsn));
fflush(NULL);
if (system(pg_waldump_cmd) != 0)
report_backup_error(context,
- "WAL parsing failed for timeline %u",
+ "WAL parsing failed for timeline %X",
this_wal_range->tli);
this_wal_range = this_wal_range->next;
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 44b5c8726e..23dc7354ba 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -1007,7 +1007,7 @@ main(int argc, char **argv)
private.startptr = (uint64) xlogid << 32 | xrecoff;
break;
case 't':
- if (sscanf(optarg, "%u", &private.timeline) != 1)
+ if (sscanf(optarg, "%X", &private.timeline) != 1)
{
pg_log_error("invalid timeline specification: \"%s\"", optarg);
goto bad_argument;