diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index 0d7bddbe4ed..aac907ddc2d 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -578,8 +578,6 @@ SnapBuildExportSnapshot(SnapBuild *builder) Snapshot SnapBuildGetOrBuildSnapshot(SnapBuild *builder) { - Assert(builder->state == SNAPBUILD_CONSISTENT); - /* only build a new snapshot if we don't have a prebuilt one */ if (builder->snapshot == NULL) { @@ -660,21 +658,15 @@ SnapBuildProcessChange(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn) */ if (!ReorderBufferXidHasBaseSnapshot(builder->reorder, xid)) { - /* only build a new snapshot if we don't have a prebuilt one */ - if (builder->snapshot == NULL) - { - builder->snapshot = SnapBuildBuildSnapshot(builder); - /* increase refcount for the snapshot builder */ - SnapBuildSnapIncRefcount(builder->snapshot); - } + Snapshot snapshot = SnapBuildGetOrBuildSnapshot(builder); /* * Increase refcount for the transaction we're handing the snapshot * out to. */ - SnapBuildSnapIncRefcount(builder->snapshot); + SnapBuildSnapIncRefcount(snapshot); ReorderBufferSetBaseSnapshot(builder->reorder, xid, lsn, - builder->snapshot); + snapshot); } return true;