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.98.2) (envelope-from ) id 1xIU18-00000003id4-3cwe for pgsql-hackers@arkaria.postgresql.org; Sun, 18 Oct 2026 16:45:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xIU15-00000003RW2-38LV for pgsql-hackers@arkaria.postgresql.org; Sun, 18 Oct 2026 16:45:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xIU15-00000003RVt-17yR for pgsql-hackers@lists.postgresql.org; Sun, 18 Oct 2026 16:45:47 +0000 Received: from mail-dy1-x132c.google.com ([2607:f8b0:4864:20::132c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xIU13-00000002prD-0iyT for pgsql-hackers@lists.postgresql.org; Sun, 18 Oct 2026 16:45:47 +0000 Received: by mail-dy1-x132c.google.com with SMTP id 5a478bee46e88-3584f70a5aaso139908eec.1 for ; Sun, 18 Oct 2026 09:45:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792341943; x=1792946743; darn=lists.postgresql.org; h=mime-version:content-transfer-encoding:content-type:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=5M7rmVBgtjjsU8nMwoFmp/4vWA288KLQHgZWjDMX64g=; b=D0QlV3VgtcH/1h+KsJFFqFQxvOSfc8EcUbw0nMiHjreO0TI/OMR/uXDTVABDOz6pft 5Xraj1PJoMbLTYyx7YnQZ5+qc1nw0g0H5EdixcIA+cvNeqoyCG2X8YTvTgvT0BtSE3Wq SUXNHFUYC5Dm9eX1Bt6hiHCX/pOmb3yYmuUUJLDZrP73dSfWg+t7gz5nV+sqPHJYFSdO 5srA228yV2lLlPm06WSKXZ2x/+dckGjibWzCtaK+H0aDON5vYD9fAwK8CP9G4P4ScKab V35d3MgccnZciRYO+mPQUEAxd3jvnYezDbOYfcjXXtimvdMcmplrkXd+zTMl8MJmxusz Xjrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792341943; x=1792946743; h=mime-version:content-transfer-encoding:content-type:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=5M7rmVBgtjjsU8nMwoFmp/4vWA288KLQHgZWjDMX64g=; b=vRY4qYZGeamaDea8SYM8hB5xVjYuIJ6ULbmGNatvb9b/iQy5Czh/pDaw+9iUeQTQpo mQmHIusCXKYZ27a9qxqRjeMY4beVqdF8IX5vu6Ns3UzmaOiCGUyZRD25dQEF8qeBUbEP C+Issp21q1KbkO7MlDRVPETE7ztrZ95Gsb+V43iP6vQ9U7z+IryUbO4rBKBSt3nMoWzG vOu7p4YuhjykGWOU7wpau0/o94YMMIt8M2QOu58t7qjb7cr6Owj03zEB6ENPTK05quRc hVSFIGZzi7KFfk96zZroLIjORFpW7r1iDBaZrdWQNyeV+YqtpsgSCHlbXo6V/+UBcmbi 56Gg== X-Forwarded-Encrypted: i=1; AKwUvBwuflu3MeWwDamXAvatrvp6CgydQFLiyJs3R/Z/5kVuJxyJACG1bhbaUo7wHNbNNYuOS+xA16+CvbRclSTm@lists.postgresql.org X-Gm-Message-State: AFq9FYLMthVsqcOz8vEW4RJcyh7gpdp+iSzwXG+GZ7wR6Fktlsci/SQ5 LpSXrOQvrO+IfVJXZGMiEvDHiZTsQR+0zTcATwmXF3k9cCWZnZuwOcIV X-Gm-Gg: AYBFou1Q9a24SGouOJw0MCotwS7vNlhpV5dSGijN4eWRvOAAksnfDzSvrOJ22PiFySX 0P2reXtB+/9FJ09+mX8PHFYffciflCA3D4OPF/4Kye1uFeZxCnPozchzbtDH99wDgBeLp+2mEXd g2X7rUMsOGjXSgWmQnqmiixhpy1eq1mJhQsnLm5sdHYoKi/Wsb1lLfkhskETGBZ9oQ7WW5hZhQz jKuf921040HztzAFd2Ja67sJp+KneSrwC4pk4I0663xi2t4jcxFoqFSnZl0yajWyniC7PPr7WAM AZBF7GsmBKT4qCqASZgTpGJbYcQGTbtdg0Wexnjux6+PcRI/xvkv9bvPKsZEGhrvEGuNYHCFSCu GLacjPOVlL22km50QSVxXG6SpYTsEgzR5NwV2YGkSOFAHyKTob8D8sEGWQnO7gjdUtP/KOnQXKE IPjt1A8RxDQr6IH8IlMZ1tC6qd9o4i0rRZo6DUD1JakAYOVpX6+rkNwfSYLpP2LEw7IxaioPcSR 0W7oK8A1EgGMT1ViVHAOG4/qPWkyAArbJKA0bsCXdv+4fLb7vQIwaZN4+8KMV/Mw10uf5y07bFE DrcVbHzZIfjnSSAB5BAH9gfSEQ== X-Received: by 2002:a05:7300:7aa1:b0:33e:6714:3945 with SMTP id 5a478bee46e88-361a0898c20mr12669504eec.2.1792341937761; Sun, 18 Oct 2026 09:45:37 -0700 (PDT) Received: from 192.168.1.109 ([2803:3c90:cee:ea00:5c3c:7e70:29e3:7a55]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-36082b8573dsm25317508eec.25.2026.10.18.09.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Oct 2026 09:45:37 -0700 (PDT) From: Manu To: shihao zhong Cc: Alexandre Felipe , Andres Freund , Tom Lane , Michael Paquier , Zsolt Parragi , pgsql-hackers@lists.postgresql.org Subject: Re: BUG #19686: Rolling back SET TABLESPACE Date: Sun, 18 Oct 2026 13:45:31 -0300 Message-ID: <179234193175.237803.1636724777877426621@gmail.com> In-Reply-To: References: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Shihao, > One correction. v7 copies the indexes in their own tablespace, so the > room is needed on the old volume, not the destination. You're right -- thanks for catching it. My earlier "destination tablespace" was wrong, and I measured it. v7 copies each index into the index's own table= space, so that is where the extra room is needed; the destination only has to fit the heap, the same as master. The extra is the size of the indexes, within about 32 kB: 6.45 MB for one index, 12.89 MB for two, 25.78 MB for four in my test. A single ALTER through the extended protocol then fails with ENOSPC on a nearly-full index volume where master succeeds; inside a transaction block v6 copies too, so that cost is v7's only for the single extended-protocol statement. This is the cost the deferred copy (my v4) avoided -- it copied nothing for an ALTER with no later write, 0 copies across the 15 cases I re-ran. Since the cost is back, I went back to the two objections that led me to drop it. Andres, on the old index being pinned: I measured it in 13 scenarios where the deferred copy runs with a buffer of the old index file still pinned, verified each time with pg_buffercache before the write. (A plain MVCC btree scan drops the leaf pin, so the outer scans are index-only or hash, which keep it, plus a nested loop, a BEFORE trigger, a scrollable cursor, a generic prepared plan, a partial index and writes under savepoints.) All 13 are correct after COMMIT and ROLLBACK; master fails every one on ROLLBACK. The oracle is index-vs-seq, by row md5 over 8 query shapes and index-only scans after VACUUM to surface stale entries, since amcheck's heapallindexed only checks heap->index. One v4 case does fail -- a REINDEX before a savepoint whose move is then rolled back -- but that is the savepoint gap v5 already closed, not a pin issue, so a deferred v8 would keep v5's per-subtransaction rule. This was btree and hash, one backend. On the other objection, the performance being harder to reason about, I have no number that settles it: the copy happens only when a later write makes it necessary, and the first such write pays for all the indexes, which is a trade-off to weigh rather than something I can measure away. For the back branches the deferred copy is a behavior change and, as Michael noted, not backpatchable, so there the eager copy (v7) is the fix regardless; the question is only 19 and master. So, given the space cost: is the deferred copy worth another look for 19, or should we take the eager copy everywhere? I'm happy to prepare a proper v8 of it if you'd like to see one, and otherwise v7 stands. regards, Manu