v01_minor_improvement_in_snapbuild.patch
application/octet-stream
Filename: v01_minor_improvement_in_snapbuild.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
Series: patch v1
| File | + | − |
|---|---|---|
| src/backend/replication/logical/snapbuild.c | 3 | 32 |
diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c
index 0d7bddbe4ed..d234af82d52 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;
@@ -940,20 +932,6 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
TransactionId xmax = xid;
- /*
- * Transactions preceding BUILDING_SNAPSHOT will neither be decoded, nor
- * will they be part of a snapshot. So we don't need to record anything.
- */
- if (builder->state == SNAPBUILD_START ||
- (builder->state == SNAPBUILD_BUILDING_SNAPSHOT &&
- TransactionIdPrecedes(xid, builder->next_phase_at)))
- {
- /* ensure that only commits after this are getting replayed */
- if (builder->start_decoding_at <= lsn)
- builder->start_decoding_at = lsn + 1;
- return;
- }
-
if (builder->state < SNAPBUILD_CONSISTENT)
{
/* ensure that only commits after this are getting replayed */
@@ -1054,13 +1032,6 @@ SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid,
/* if there's any reason to build a historic snapshot, do so now */
if (needs_snapshot)
{
- /*
- * If we haven't built a complete snapshot yet there's no need to hand
- * it out, it wouldn't (and couldn't) be used anyway.
- */
- if (builder->state < SNAPBUILD_FULL_SNAPSHOT)
- return;
-
/*
* Decrease the snapshot builder's refcount of the old snapshot, note
* that it still will be used if it has been handed out to the