diff --git a/src/backend/replication/logical/logicalfuncs.c b/src/backend/replication/logical/logicalfuncs.c index 4d355b1f976..5670e6f3111 100644 --- a/src/backend/replication/logical/logicalfuncs.c +++ b/src/backend/replication/logical/logicalfuncs.c @@ -49,6 +49,7 @@ #include "storage/fd.h" #include "polar_dma/polar_dma.h" +#include "replication/snapbuild.h" /* private date for writing out data */ typedef struct DecodingOutputState @@ -335,6 +336,7 @@ pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool bin if (upto_nchanges != 0 && upto_nchanges <= p->returned_rows) break; + IncreaseNInitialRunningXacts(ctx->snapshot_builder); CHECK_FOR_INTERRUPTS(); } diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index b6866cc9b23..7c429af2614 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -354,6 +354,8 @@ AllocateSnapshotBuilder(ReorderBuffer *reorder, MemoryContext oldcontext; SnapBuild *builder; + ereport(WARNING, (errmsg("NInitialRunningXacts is %u , InitialRunningXacts is %p", + NInitialRunningXacts, InitialRunningXacts))); /* allocate memory in own context, to have better accountability */ context = AllocSetContextCreate(CurrentMemoryContext, "snapshot builder context", @@ -385,6 +387,14 @@ AllocateSnapshotBuilder(ReorderBuffer *reorder, return builder; } +void +IncreaseNInitialRunningXacts(SnapBuild *builder) +{ + NInitialRunningXacts = 3; + InitialRunningXacts = MemoryContextAlloc(builder->context, sizeof(TransactionId) * 3); + sleep(5); +} + /* * Free a snapshot builder. */ diff --git a/src/include/replication/snapbuild.h b/src/include/replication/snapbuild.h index 4df3c3f2f73..e56ab99ba49 100644 --- a/src/include/replication/snapbuild.h +++ b/src/include/replication/snapbuild.h @@ -58,6 +58,7 @@ struct xl_heap_new_cid; struct xl_running_xacts; extern void CheckPointSnapBuild(void); +extern void IncreaseNInitialRunningXacts(SnapBuild *builder); extern SnapBuild *AllocateSnapshotBuilder(struct ReorderBuffer *cache, TransactionId xmin_horizon, XLogRecPtr start_lsn,