Skip to content

Commit c9c401a

Browse files
committed
Improve error messages for some callers of XLogReadRecord()
A couple of code paths related to logical decoding (WAL sender, slot advancing, etc.) use XLogReadRecord(), feeding on error messages generated by walreader.c on a failure. All those messages have no context, making it harder to spot from where an error could come even if these should not happen. All the other callers of XLogReadRecord() do that already. Reviewed-by: Kyotaro Horiguchi Discussion: https://postgr.es/m/YYnTH6OyOwQcAdkw@paquier.xyz
1 parent 4168a47 commit c9c401a

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

src/backend/replication/logical/logical.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,9 @@ DecodingContextFindStartpoint(LogicalDecodingContext *ctx)
605605
/* the read_page callback waits for new WAL */
606606
record = XLogReadRecord(ctx->reader, &err);
607607
if (err)
608-
elog(ERROR, "%s", err);
608+
elog(ERROR, "could not find logical decoding starting point: %s", err);
609609
if (!record)
610-
elog(ERROR, "no record found"); /* shouldn't happen */
610+
elog(ERROR, "could not find logical decoding starting point");
611611

612612
LogicalDecodingProcessRecord(ctx, ctx->reader);
613613

src/backend/replication/logical/logicalfuncs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool bin
276276

277277
record = XLogReadRecord(ctx->reader, &errm);
278278
if (errm)
279-
elog(ERROR, "%s", errm);
279+
elog(ERROR, "could not find record for logical decoding: %s", errm);
280280

281281
/*
282282
* The {begin_txn,change,commit_txn}_wrapper callbacks above will

src/backend/replication/slotfuncs.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,8 @@ pg_logical_replication_slot_advance(XLogRecPtr moveto)
529529
*/
530530
record = XLogReadRecord(ctx->reader, &errm);
531531
if (errm)
532-
elog(ERROR, "%s", errm);
532+
elog(ERROR, "could not find record while advancing replication slot: %s",
533+
errm);
533534

534535
/*
535536
* Process the record. Storage-level changes are ignored in

src/backend/replication/walsender.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -2979,7 +2979,8 @@ XLogSendLogical(void)
29792979

29802980
/* xlog record was invalid */
29812981
if (errm != NULL)
2982-
elog(ERROR, "%s", errm);
2982+
elog(ERROR, "could not find record while sending logically-decoded data: %s",
2983+
errm);
29832984

29842985
if (record != NULL)
29852986
{

0 commit comments

Comments
 (0)