Skip to content

Commit ab9c433

Browse files
committed
Don't build full initial logical decoding snapshot if NOEXPORT_SNAPSHOT.
Earlier commits (56e19d9 and 2bef06d) make it cheaper to create a logical slot if not exporting the initial snapshot. If NOEXPORT_SNAPSHOT is specified, we can skip the overhead, not just when creating a slot via sql (which can't export snapshots). As NOEXPORT_SNAPSHOT has only recently been introduced, this shouldn't be backpatched.
1 parent 56e19d9 commit ab9c433

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/backend/replication/walsender.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,7 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
873873
if (cmd->kind == REPLICATION_KIND_LOGICAL)
874874
{
875875
LogicalDecodingContext *ctx;
876+
bool need_full_snapshot = false;
876877

877878
/*
878879
* Do options check early so that we can bail before calling the
@@ -884,6 +885,8 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
884885
ereport(ERROR,
885886
(errmsg("CREATE_REPLICATION_SLOT ... EXPORT_SNAPSHOT "
886887
"must not be called inside a transaction")));
888+
889+
need_full_snapshot = true;
887890
}
888891
else if (snapshot_action == CRS_USE_SNAPSHOT)
889892
{
@@ -906,10 +909,11 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
906909
ereport(ERROR,
907910
(errmsg("CREATE_REPLICATION_SLOT ... USE_SNAPSHOT "
908911
"must not be called in a subtransaction")));
912+
913+
need_full_snapshot = true;
909914
}
910915

911-
ctx = CreateInitDecodingContext(cmd->plugin, NIL,
912-
true, /* build snapshot */
916+
ctx = CreateInitDecodingContext(cmd->plugin, NIL, need_full_snapshot,
913917
logical_read_xlog_page,
914918
WalSndPrepareWrite, WalSndWriteData);
915919

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy