summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier2021-11-10 03:00:33 +0000
committerMichael Paquier2021-11-10 03:00:33 +0000
commitc9c401a5e13accc4a3a775e3feeabdc5940c9178 (patch)
treec616ef270413dfa847f4e97483f23ef4c694e14f
parent4168a4745492cd54a0ffffc271b452525ef4dc60 (diff)
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/[email protected]
-rw-r--r--src/backend/replication/logical/logical.c4
-rw-r--r--src/backend/replication/logical/logicalfuncs.c2
-rw-r--r--src/backend/replication/slotfuncs.c3
-rw-r--r--src/backend/replication/walsender.c3
4 files changed, 7 insertions, 5 deletions
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index aae0ae5b8a..b7d9521576 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -605,9 +605,9 @@ DecodingContextFindStartpoint(LogicalDecodingContext *ctx)
/* the read_page callback waits for new WAL */
record = XLogReadRecord(ctx->reader, &err);
if (err)
- elog(ERROR, "%s", err);
+ elog(ERROR, "could not find logical decoding starting point: %s", err);
if (!record)
- elog(ERROR, "no record found"); /* shouldn't happen */
+ elog(ERROR, "could not find logical decoding starting point");
LogicalDecodingProcessRecord(ctx, ctx->reader);
diff --git a/src/backend/replication/logical/logicalfuncs.c b/src/backend/replication/logical/logicalfuncs.c
index 2609a0a710..6cd2279a2e 100644
--- a/src/backend/replication/logical/logicalfuncs.c
+++ b/src/backend/replication/logical/logicalfuncs.c
@@ -276,7 +276,7 @@ pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool bin
record = XLogReadRecord(ctx->reader, &errm);
if (errm)
- elog(ERROR, "%s", errm);
+ elog(ERROR, "could not find record for logical decoding: %s", errm);
/*
* The {begin_txn,change,commit_txn}_wrapper callbacks above will
diff --git a/src/backend/replication/slotfuncs.c b/src/backend/replication/slotfuncs.c
index a80298ba53..46175b7007 100644
--- a/src/backend/replication/slotfuncs.c
+++ b/src/backend/replication/slotfuncs.c
@@ -529,7 +529,8 @@ pg_logical_replication_slot_advance(XLogRecPtr moveto)
*/
record = XLogReadRecord(ctx->reader, &errm);
if (errm)
- elog(ERROR, "%s", errm);
+ elog(ERROR, "could not find record while advancing replication slot: %s",
+ errm);
/*
* Process the record. Storage-level changes are ignored in
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index fff7dfc640..7950afb173 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2979,7 +2979,8 @@ XLogSendLogical(void)
/* xlog record was invalid */
if (errm != NULL)
- elog(ERROR, "%s", errm);
+ elog(ERROR, "could not find record while sending logically-decoded data: %s",
+ errm);
if (record != NULL)
{