Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w5lM8-003bQn-0w for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Mar 2026 14:06:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w5lM6-003248-2n for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Mar 2026 14:06:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w5lM6-003240-1h for pgsql-hackers@lists.postgresql.org; Thu, 26 Mar 2026 14:06:38 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w5lM1-000000019IZ-1LZS for pgsql-hackers@lists.postgresql.org; Thu, 26 Mar 2026 14:06:37 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-482f454be5bso19787405e9.0 for ; Thu, 26 Mar 2026 07:06:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1774533991; x=1775138791; darn=lists.postgresql.org; h=message-id:date:mime-version:comments:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=A5ojRVssd5cqe3y4wsFtkFVYhUP4IkOFWvbS7cSPnVQ=; b=JLOpJb8nb6npoKz9+z3Siitwr2QpyRYbkZI6+TmH0/Op2sZr4lEFfeKSOSt7Jcepsg qAwO4YOigr+a8yq/8E0Lh60eyxATsndsnhit/jmptG+l8vdOs5yVoCJI54DKQPC4liJc 0GYbunDLrgil3hkmgKDCT/o211XgjaKjM2R8ktiBFrQDUfTDbsUnsOHWGIWJRSe7hXhK vrtB8FkfAV8qcowxtzLfvGXyi8ooggkRtNBVlB71ujy8Srf4JM+sh2Yxo7sHoFMDa3Cm d6KPQWQgLNk87Qx0SoOjmVvuB1ZuQrO41RUMc7zfNyQewmJ3C88BcPyCBHcAew1iMPdW mxKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774533991; x=1775138791; h=message-id:date:mime-version:comments:references:in-reply-to :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=A5ojRVssd5cqe3y4wsFtkFVYhUP4IkOFWvbS7cSPnVQ=; b=iHH/jp6zuiMQDbThMR4nh33sf/ibuNMr8W7UXWBCUeijOb2975KcHHFpatqzBGjbnZ WUUUIGue+dYhpcrqhDMy8GFtlaG754qlVJDUuQms/ALweRcH0TUD79TkOORbwBh6/C/R hGqnBwbaZbasTIq/mO/2nw1Fv+4KeK/ZZ/bYSVB94rd42V70OD3sl/ijKrs4YJC9dmeH NUFcbaIwxeM221i+WyhlvNxHa2M/tnkEMUKqw1flH9fatOC2YYk8tLZ9C4krNIzYnoIN S4xz1emcDzqxZ6q2kOwPmLfFNIkm64Ge0MQQEY/AqJrLlRpHuCJjEzL73+XWCxhB8aem dMiA== X-Forwarded-Encrypted: i=1; AJvYcCV+uw4GzFi25vqM59tGberocxAyVhp8XX0n7x28RMJ/LnKoA235PibASifLTHTRGlhf28bzz9o+Du6d4Qkl@lists.postgresql.org X-Gm-Message-State: AOJu0Yzt/HW4OCJBIZXA+ETwOHqitA5+wKEosq+N6T0A9xi9MAeYi3UE InzbzS0zYtJfiOEFpeof7ezDzMBafEERbEWblEfmRZIK2FQEbdpDEu1mKMZK426Pno4= X-Gm-Gg: ATEYQzyMpK9xba8cc5QYPcpLJveyMmKQp4IzWnO2nk4kQ0C8/yPT7TiaB5UXzDt9qey IDkFv2ujKWRkxn9A3iWMrRcHOacCtg80fAIRIv5bUN7EgUY6Z1xJfDkV6gQp2623SjXQltZb1lG hE7BpOcD/DcbVlDwGwe7R7MHzqmmYoIpcfgPG24z/+/j8UPfAJ3kNephKCJ2Cy1ERgkML7RjwHX ii4Vr7F+71y+05UeuI14Axme3g1k29v7SYB9MktwU4hVhMj8MXkMh093RL3GILKPToWfn/5sZyG aG3L/yq2EipG4rRnmF/lUN8ppIqACQL9MFsGSXhCykpvmry8txqHmP9G2PZJraqs0F5+qwPWdC8 VXkCQRzH7rYkuQXuxGXBNYMI0AFXC4Cbs/JPVgv+SDAajcjb788XNjjVWlv5LhbF6ykXaUt60lS qCjmueeXjW2H6y0IP49MkrWwS/jb63FHEI3YYP X-Received: by 2002:a05:600c:468f:b0:485:3c2e:60d5 with SMTP id 5b1f17b1804b1-48722b92fdcmr27809145e9.2.1774533990727; Thu, 26 Mar 2026 07:06:30 -0700 (PDT) Received: from localhost (109-81-168-142.rct.o2.cz. [109.81.168.142]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48722be608bsm44008745e9.0.2026.03.26.07.06.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 07:06:30 -0700 (PDT) From: Antonin Houska To: Alvaro Herrera cc: Srinath Reddy Sadipiralla , Mihail Nikalayeu , Matthias van de Meent , Pg Hackers , Robert Treat Subject: Re: Adding REPACK [concurrently] In-reply-to: <202603252005.quy5h4oipoxd@alvherre.pgsql> References: <202603252005.quy5h4oipoxd@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Wed, 25 Mar 2026 21:12:48 +0100." X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.3 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Date: Thu, 26 Mar 2026 15:06:29 +0100 Message-ID: <43861.1774533989@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=-=-= Content-Type: text/plain Alvaro Herrera wrote: > (I omitted the last three patches in the series, and > squashed my proposed changes into 0003, as announced in my previous > posting.) I've updated the comment about on-disk attributes in repack_store_change(), but when verifying it, I hit an error when more than one UPDATEs (in separate transactions) were executed during a single run of REPACK. The problem is that reorderbuffer.c sets up an internal (sub)transaction before replaying each decoded transaction. Therefore the tuple slot should not be allocated in TopTransactionContext. I chose TopMemoryContext instead. BTW, if you want to verify that the updated comment is correct, just add elog(ERROR) next to it and run repack_toast.spec. The statement UPDATE repack_test SET i=3 where i=1; will then reach it. -- Antonin Houska Web: https://www.cybertec-postgresql.com --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=nocfbot_fix_repack_store_change.diff 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)); } --=-=-=--