aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication/logical
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2021-02-23 10:14:38 +0100
committerPeter Eisentraut <peter@eisentraut.org>2021-02-23 10:27:02 +0100
commit6f6f284c7ee44264eb3e128e2bf54d9276711d11 (patch)
treec861d32584f751b28a065b98c03e1dd1370daa10 /src/backend/replication/logical
parentade89ba5f408e6034db7cc8a2c9b7858f5a214c4 (diff)
downloadpostgresql-6f6f284c7ee44264eb3e128e2bf54d9276711d11.tar.gz
postgresql-6f6f284c7ee44264eb3e128e2bf54d9276711d11.zip
Simplify printing of LSNs
Add a macro LSN_FORMAT_ARGS for use in printf-style printing of LSNs. Convert all applicable code to use it. Reviewed-by: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://www.postgresql.org/message-id/flat/CAExHW5ub5NaTELZ3hJUCE6amuvqAtsSxc7O+uK7y4t9Rrk23cw@mail.gmail.com
Diffstat (limited to 'src/backend/replication/logical')
-rw-r--r--src/backend/replication/logical/logical.c34
-rw-r--r--src/backend/replication/logical/origin.c3
-rw-r--r--src/backend/replication/logical/reorderbuffer.c3
-rw-r--r--src/backend/replication/logical/snapbuild.c20
-rw-r--r--src/backend/replication/logical/tablesync.c4
-rw-r--r--src/backend/replication/logical/worker.c7
6 files changed, 29 insertions, 42 deletions
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 0977aec711c..baeb45ff43c 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -514,9 +514,8 @@ CreateDecodingContext(XLogRecPtr start_lsn,
* replication.
*/
elog(DEBUG1, "cannot stream from %X/%X, minimum is %X/%X, forwarding",
- (uint32) (start_lsn >> 32), (uint32) start_lsn,
- (uint32) (slot->data.confirmed_flush >> 32),
- (uint32) slot->data.confirmed_flush);
+ LSN_FORMAT_ARGS(start_lsn),
+ LSN_FORMAT_ARGS(slot->data.confirmed_flush));
start_lsn = slot->data.confirmed_flush;
}
@@ -538,10 +537,8 @@ CreateDecodingContext(XLogRecPtr start_lsn,
(errmsg("starting logical decoding for slot \"%s\"",
NameStr(slot->data.name)),
errdetail("Streaming transactions committing after %X/%X, reading WAL from %X/%X.",
- (uint32) (slot->data.confirmed_flush >> 32),
- (uint32) slot->data.confirmed_flush,
- (uint32) (slot->data.restart_lsn >> 32),
- (uint32) slot->data.restart_lsn)));
+ LSN_FORMAT_ARGS(slot->data.confirmed_flush),
+ LSN_FORMAT_ARGS(slot->data.restart_lsn))));
return ctx;
}
@@ -567,8 +564,7 @@ DecodingContextFindStartpoint(LogicalDecodingContext *ctx)
XLogBeginRead(ctx->reader, slot->data.restart_lsn);
elog(DEBUG1, "searching for logical decoding starting point, starting at %X/%X",
- (uint32) (slot->data.restart_lsn >> 32),
- (uint32) slot->data.restart_lsn);
+ LSN_FORMAT_ARGS(slot->data.restart_lsn));
/* Wait for a consistent starting point */
for (;;)
@@ -688,8 +684,7 @@ output_plugin_error_callback(void *arg)
NameStr(state->ctx->slot->data.name),
NameStr(state->ctx->slot->data.plugin),
state->callback_name,
- (uint32) (state->report_location >> 32),
- (uint32) state->report_location);
+ LSN_FORMAT_ARGS(state->report_location));
else
errcontext("slot \"%s\", output plugin \"%s\", in the %s callback",
NameStr(state->ctx->slot->data.name),
@@ -1623,8 +1618,8 @@ LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn, XLogRecPtr restart
SpinLockRelease(&slot->mutex);
elog(DEBUG1, "got new restart lsn %X/%X at %X/%X",
- (uint32) (restart_lsn >> 32), (uint32) restart_lsn,
- (uint32) (current_lsn >> 32), (uint32) current_lsn);
+ LSN_FORMAT_ARGS(restart_lsn),
+ LSN_FORMAT_ARGS(current_lsn));
}
else
{
@@ -1638,14 +1633,11 @@ LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn, XLogRecPtr restart
SpinLockRelease(&slot->mutex);
elog(DEBUG1, "failed to increase restart lsn: proposed %X/%X, after %X/%X, current candidate %X/%X, current after %X/%X, flushed up to %X/%X",
- (uint32) (restart_lsn >> 32), (uint32) restart_lsn,
- (uint32) (current_lsn >> 32), (uint32) current_lsn,
- (uint32) (candidate_restart_lsn >> 32),
- (uint32) candidate_restart_lsn,
- (uint32) (candidate_restart_valid >> 32),
- (uint32) candidate_restart_valid,
- (uint32) (confirmed_flush >> 32),
- (uint32) confirmed_flush);
+ LSN_FORMAT_ARGS(restart_lsn),
+ LSN_FORMAT_ARGS(current_lsn),
+ LSN_FORMAT_ARGS(candidate_restart_lsn),
+ LSN_FORMAT_ARGS(candidate_restart_valid),
+ LSN_FORMAT_ARGS(confirmed_flush));
}
/* candidates are already valid with the current flush position, apply */
diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c
index 685eaa6134e..39471fddad6 100644
--- a/src/backend/replication/logical/origin.c
+++ b/src/backend/replication/logical/origin.c
@@ -789,8 +789,7 @@ StartupReplicationOrigin(void)
ereport(LOG,
(errmsg("recovered replication state of node %u to %X/%X",
disk_state.roident,
- (uint32) (disk_state.remote_lsn >> 32),
- (uint32) disk_state.remote_lsn)));
+ LSN_FORMAT_ARGS(disk_state.remote_lsn))));
}
/* now check checksum */
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 66554ca2d98..c3b963211e8 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -4366,8 +4366,7 @@ ReorderBufferSerializedPath(char *path, ReplicationSlot *slot, TransactionId xid
snprintf(path, MAXPGPATH, "pg_replslot/%s/xid-%u-lsn-%X-%X.spill",
NameStr(MyReplicationSlot->data.name),
- xid,
- (uint32) (recptr >> 32), (uint32) recptr);
+ xid, LSN_FORMAT_ARGS(recptr));
}
/*
diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c
index 752cf2d7dbc..e11788795f1 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -801,7 +801,7 @@ SnapBuildDistributeNewCatalogSnapshot(SnapBuild *builder, XLogRecPtr lsn)
continue;
elog(DEBUG2, "adding a new snapshot to %u at %X/%X",
- txn->xid, (uint32) (lsn >> 32), (uint32) lsn);
+ txn->xid, LSN_FORMAT_ARGS(lsn));
/*
* increase the snapshot's refcount for the transaction we are handing
@@ -1191,7 +1191,7 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn
{
ereport(DEBUG1,
(errmsg_internal("skipping snapshot at %X/%X while building logical decoding snapshot, xmin horizon too low",
- (uint32) (lsn >> 32), (uint32) lsn),
+ LSN_FORMAT_ARGS(lsn)),
errdetail_internal("initial xmin horizon of %u vs the snapshot's %u",
builder->initial_xmin_horizon, running->oldestRunningXid)));
@@ -1230,7 +1230,7 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn
ereport(LOG,
(errmsg("logical decoding found consistent point at %X/%X",
- (uint32) (lsn >> 32), (uint32) lsn),
+ LSN_FORMAT_ARGS(lsn)),
errdetail("There are no running transactions.")));
return false;
@@ -1274,7 +1274,7 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn
ereport(LOG,
(errmsg("logical decoding found initial starting point at %X/%X",
- (uint32) (lsn >> 32), (uint32) lsn),
+ LSN_FORMAT_ARGS(lsn)),
errdetail("Waiting for transactions (approximately %d) older than %u to end.",
running->xcnt, running->nextXid)));
@@ -1298,7 +1298,7 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn
ereport(LOG,
(errmsg("logical decoding found initial consistent point at %X/%X",
- (uint32) (lsn >> 32), (uint32) lsn),
+ LSN_FORMAT_ARGS(lsn)),
errdetail("Waiting for transactions (approximately %d) older than %u to end.",
running->xcnt, running->nextXid)));
@@ -1323,7 +1323,7 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn
ereport(LOG,
(errmsg("logical decoding found consistent point at %X/%X",
- (uint32) (lsn >> 32), (uint32) lsn),
+ LSN_FORMAT_ARGS(lsn)),
errdetail("There are no old transactions anymore.")));
}
@@ -1477,7 +1477,7 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn)
* no hope continuing to decode anyway.
*/
sprintf(path, "pg_logical/snapshots/%X-%X.snap",
- (uint32) (lsn >> 32), (uint32) lsn);
+ LSN_FORMAT_ARGS(lsn));
/*
* first check whether some other backend already has written the snapshot
@@ -1520,7 +1520,7 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn)
/* to make sure only we will write to this tempfile, include pid */
sprintf(tmppath, "pg_logical/snapshots/%X-%X.snap.%u.tmp",
- (uint32) (lsn >> 32), (uint32) lsn, MyProcPid);
+ LSN_FORMAT_ARGS(lsn), MyProcPid);
/*
* Unlink temporary file if it already exists, needs to have been before a
@@ -1670,7 +1670,7 @@ SnapBuildRestore(SnapBuild *builder, XLogRecPtr lsn)
return false;
sprintf(path, "pg_logical/snapshots/%X-%X.snap",
- (uint32) (lsn >> 32), (uint32) lsn);
+ LSN_FORMAT_ARGS(lsn));
fd = OpenTransientFile(path, O_RDONLY | PG_BINARY);
@@ -1854,7 +1854,7 @@ SnapBuildRestore(SnapBuild *builder, XLogRecPtr lsn)
ereport(LOG,
(errmsg("logical decoding found consistent point at %X/%X",
- (uint32) (lsn >> 32), (uint32) lsn),
+ LSN_FORMAT_ARGS(lsn)),
errdetail("Logical decoding will begin using saved snapshot.")));
return true;
diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c
index 24a6ce5d8ed..feb634e7ac0 100644
--- a/src/backend/replication/logical/tablesync.c
+++ b/src/backend/replication/logical/tablesync.c
@@ -1120,9 +1120,7 @@ copy_table_done:
elog(DEBUG1,
"LogicalRepSyncTableStart: '%s' origin_startpos lsn %X/%X",
- originname,
- (uint32) (*origin_startpos >> 32),
- (uint32) *origin_startpos);
+ originname, LSN_FORMAT_ARGS(*origin_startpos));
/*
* We are done with the initial data synchronization, update the state.
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index cfc924cd893..18d05286b65 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -2359,10 +2359,9 @@ send_feedback(XLogRecPtr recvpos, bool force, bool requestReply)
elog(DEBUG2, "sending feedback (force %d) to recv %X/%X, write %X/%X, flush %X/%X",
force,
- (uint32) (recvpos >> 32), (uint32) recvpos,
- (uint32) (writepos >> 32), (uint32) writepos,
- (uint32) (flushpos >> 32), (uint32) flushpos
- );
+ LSN_FORMAT_ARGS(recvpos),
+ LSN_FORMAT_ARGS(writepos),
+ LSN_FORMAT_ARGS(flushpos));
walrcv_send(wrconn, reply_message->data, reply_message->len);