summaryrefslogtreecommitdiff
path: root/src/backend/replication
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/replication')
-rw-r--r--src/backend/replication/logical/logical.c2
-rw-r--r--src/backend/replication/slot.c20
2 files changed, 19 insertions, 3 deletions
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index e1f14aeecb5..656ec8f5555 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1921,7 +1921,7 @@ UpdateDecodingStats(LogicalDecodingContext *ctx)
repSlotStat.total_txns = rb->totalTxns;
repSlotStat.total_bytes = rb->totalBytes;
- pgstat_report_replslot(&repSlotStat);
+ pgstat_report_replslot(ctx->slot, &repSlotStat);
rb->spillTxns = 0;
rb->spillCount = 0;
diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index ed4c8b3ad55..2217af70d43 100644
--- a/src/backend/replication/slot.c
+++ b/src/backend/replication/slot.c
@@ -356,7 +356,7 @@ ReplicationSlotCreate(const char *name, bool db_specific,
* ReplicationSlotAllocationLock.
*/
if (SlotIsLogical(slot))
- pgstat_report_replslot_create(NameStr(slot->data.name));
+ pgstat_create_replslot(slot);
/*
* Now that the slot has been marked as in_use and active, it's safe to
@@ -400,6 +400,22 @@ SearchNamedReplicationSlot(const char *name, bool need_lock)
}
/*
+ * Return the index of the replication slot in
+ * ReplicationSlotCtl->replication_slots.
+ *
+ * This is mainly useful to have an efficient key for storing replication slot
+ * stats.
+ */
+int
+ReplicationSlotIndex(ReplicationSlot *slot)
+{
+ Assert(slot >= ReplicationSlotCtl->replication_slots &&
+ slot < ReplicationSlotCtl->replication_slots + max_replication_slots);
+
+ return slot - ReplicationSlotCtl->replication_slots;
+}
+
+/*
* Find a previously created slot and mark it as used by this process.
*
* An error is raised if nowait is true and the slot is currently in use. If
@@ -746,7 +762,7 @@ ReplicationSlotDropPtr(ReplicationSlot *slot)
* doesn't seem worth doing as in practice this won't happen frequently.
*/
if (SlotIsLogical(slot))
- pgstat_report_replslot_drop(NameStr(slot->data.name));
+ pgstat_drop_replslot(slot);
/*
* We release this at the very end, so that nobody starts trying to create