nocfbot_fix_repack_store_change.diff

text/x-diff

Filename: nocfbot_fix_repack_store_change.diff
Type: text/x-diff
Part: 0
Message: Re: Adding REPACK [concurrently]

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
File+
src/backend/replication/pgoutput_repack/pgoutput_repack.c 7 3
diff --git a/src/backend/replication/pgoutput_repack/pgoutput_repack.c b/src/backend/replication/pgoutput_repack/pgoutput_repack.c
index cc9ce615b18..5fe3115509e 100644
--- a/src/backend/replication/pgoutput_repack/pgoutput_repack.c
+++ b/src/backend/replication/pgoutput_repack/pgoutput_repack.c
@@ -202,7 +202,11 @@ repack_store_change(LogicalDecodingContext *ctx, Relation relation,
 		/* Initialize the slot, if not done already */
 		if (dstate->slot == NULL)
 		{
-			MemoryContextSwitchTo(oldcxt);
+			/*
+			 * We are in the decoding worker, so no worries about polluting
+			 * memory of the backend executing REPACK.
+			 */
+			MemoryContextSwitchTo(TopMemoryContext);
 			dstate->slot = MakeSingleTupleTableSlot(desc, &TTSOpsHeapTuple);
 			MemoryContextSwitchTo(dstate->change_cxt);
 		}
@@ -247,8 +251,8 @@ repack_store_change(LogicalDecodingContext *ctx, Relation relation,
 				 * attributes (those actually should never appear on disk), so
 				 * only TOASTed attribute can be seen here.
 				 *
-				 * FIXME in what circumstances can an ONDISK attr appear? Why
-				 * aren't these written separately?
+				 * We get here if the table has external values but only
+				 * in-line values are being updated now.
 				 */
 				Assert(VARATT_IS_EXTERNAL_ONDISK(varlen));
 			}