diff --git a/src/backend/replication/logical/decode.c b/src/backend/replication/logical/decode.c index d48d88081f..73e38cafd8 100644 --- a/src/backend/replication/logical/decode.c +++ b/src/backend/replication/logical/decode.c @@ -1397,12 +1397,17 @@ seq_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf) ReorderBufferProcessXid(ctx->reorder, XLogRecGetXid(r), buf->origptr); + elog(LOG, "XXX: seq_decode. snapshot is %s", SnapBuildIdentify(builder)); + /* * If we don't have snapshot or we are just fast-forwarding, there is no * point in decoding sequences. */ if (SnapBuildCurrentState(builder) < SNAPBUILD_FULL_SNAPSHOT) + { + elog(LOG, "XXX: skipped"); return; + } /* only interested in our database */ XLogRecGetBlockTag(r, 0, &target_locator, NULL, NULL); @@ -1437,14 +1442,22 @@ seq_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf) target_locator, NULL); + elog(LOG, "XXX: the sequence is %s", transactional ? "transactional" : "non-transactional"); + /* Skip the change if already processed (per the snapshot). */ if (transactional && !SnapBuildProcessChange(builder, xid, buf->origptr)) + { + elog(LOG, "XXX: already decoded: skipped"); return; + } else if (!transactional && (SnapBuildCurrentState(builder) != SNAPBUILD_CONSISTENT || SnapBuildXactNeedsSkip(builder, buf->origptr))) + { + elog(LOG, "XXX: not consistent: skipped"); return; + } /* * We also skip decoding in fast_forward mode. This check must be last @@ -1527,13 +1540,18 @@ smgr_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf) ReorderBufferProcessXid(ctx->reorder, XLogRecGetXid(r), buf->origptr); + elog(LOG, "XXX: smgr_decode. snapshot is %s", SnapBuildIdentify(builder)); + /* * If we don't have snapshot or we are just fast-forwarding, there is no * point in decoding relfilenode information. */ if (SnapBuildCurrentState(builder) < SNAPBUILD_FULL_SNAPSHOT || ctx->fast_forward) + { + elog(LOG, "XXX: skipped"); return; + } /* only interested in our database */ xlrec = (xl_smgr_create *) XLogRecGetData(r); diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index fec190a8b2..efb2afb09d 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -2135,3 +2135,27 @@ CheckPointSnapBuild(void) } FreeDir(snap_dir); } + +char * +SnapBuildIdentify(SnapBuild *builder) +{ + char *ret = NULL; + + switch (builder->state) + { + case SNAPBUILD_START: + ret = "SNAPBUILD_START"; + break; + case SNAPBUILD_BUILDING_SNAPSHOT: + ret = "SNAPBUILD_BUILDING_SNAPSHOT"; + break; + case SNAPBUILD_FULL_SNAPSHOT: + ret = "SNAPBUILD_FULL_SNAPSHOT"; + break; + case SNAPBUILD_CONSISTENT: + ret = "SNAPBUILD_CONSISTENT"; + break; + } + + return ret; +} diff --git a/src/include/replication/snapbuild.h b/src/include/replication/snapbuild.h index 63f50a13d6..bf257f5f5a 100644 --- a/src/include/replication/snapbuild.h +++ b/src/include/replication/snapbuild.h @@ -91,4 +91,6 @@ extern void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn, struct xl_running_xacts *running); extern void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn); +extern char *SnapBuildIdentify(SnapBuild *builder); + #endif /* SNAPBUILD_H */