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 1xBWGo-00000003F60-1wdh for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Sep 2026 11:45:14 +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 1xBWGn-0000000EKH6-1uwi for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Sep 2026 11:45:13 +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.98.2) (envelope-from ) id 1xBWGn-0000000EKGv-0gTl for pgsql-hackers@lists.postgresql.org; Tue, 29 Sep 2026 11:45:13 +0000 Received: from mail-ua2-x0e.google.com ([2a00:1450:4864:39::e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xBWGl-00000001rVA-0uEv for pgsql-hackers@lists.postgresql.org; Tue, 29 Sep 2026 11:45:11 +0000 Received: by mail-ua2-x0e.google.com with SMTP id a1e0cc1a2514c-9857729429aso75705241.1 for ; Tue, 29 Sep 2026 04:45:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790682310; x=1791287110; 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=mWiK7MSEGbX20RYg8RRO9fA9gwkcmFxBcc3/OwllbyY=; b=fIC28q/2jYOjlYaTow9nhkCg0wWyc/Kl+5685XpiDDXX2GjXLhUv3gU/Nj3wSB7jOf 1NIpOBVkCxORnLg2JTOYjEUuCXw1L5geFsOs4CsF72h9kFXQ9KLEkZaGAShbl8wtIeeK 4JE0ByUTEEj1k/ZurYDpHOlLYJ/P8PGRcuCHR07mqVLpo+L+Dw7PqDEx0gr5kW+GpMau D8s0bTnXlPh+xqvm46CeYB48cXTOs0eRAOVriU0IgpqtzFegQ85lLs3/wmOAUnHQCo5Q XD0kTrBr2nTH5Z0Of7Nwxkj06pajWPVQwBep0ZsnqtV9kzGHd5fc1SEQK4vRNRvsnl/I 2EAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790682310; x=1791287110; 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=mWiK7MSEGbX20RYg8RRO9fA9gwkcmFxBcc3/OwllbyY=; b=C7K6Hue05iQT/QfMnH/2pitM+0IxXCEUrb7c2Tndhns+eEZjJg+R/dAsAGKZpkijeN ICKYZrTbegS2g2bWnf4a6lDBXyt5yJ3cby7XWKnWKCW/ptm/0ZHn+aSlw+e3HalD3/KW +zPXXlIotVv69pdxE8jWHb1dIfAnIHDe9mVK1SnX227b7SXDwzf4qmv9i/zZOTg1syWD pRwTRhpVMfMjpN7vpajFTc6tpC5/wUmYdW5FQSdcIJOEBFfyMT5TQeQ9QYA1HG0Sm6eh oEGtj8EBGCm4QqYZ8UcEh1bRl2Ku7xS5CKw7/dXwfOPi0pLYz8EBEW0fwCka3iwumkAL sJow== X-Gm-Message-State: AFq9FYLo0PxxaVBrwaUBUDAxe0pnHivEGw644nqRc+t93354/x1Xjnqr fNqHbgTkpOsrKgD9SF7SNOb1A9NQHyxRsrkAUae6Cuzwd4LZjZ06S4ZF X-Gm-Gg: AYBFou0VVsSk6nwGLaBNi6VfXEFCluT0VcCNsqXeeszNGNgl/vpK1f3adKto5rLzLsQ ZNa0aOdxiBZ8JEqVG+MboZlNb0D+40/9T/5fxN2LFKo2nuzFKax68qL+4A0Ibe1sPhHrz1AYGwg snObrE1+wzMy9B/XAzLkFT43rlKrKe+hMAYOdJrU2hyTY6huHBL/hrNbPRtrAPR/04unPsZ6QB2 py8m0DAMPD05SzQ5fknl9r3+rMMRYqUSq4m+n4L+TWzx/OMjzsbjwaGimtqd3L7xvqRV5VKvdZS 2MoffBLUpJ41MYuNeLGzKss9OFicW+aNcB5rpFI/0vNozkhj7ejzhPSYVzgRClko1+f0Szy8dcn ptLuaqAqo9/rxLYFWr9rPxWE3aSO4K+3zmiilSh9YqgREJQYw4/I6tHZ2pQ9VsyiCaxMj1C5ESr Y4uYsc+H/sLkwJ1plKq7EScF9RvYdMMBnbvd4hwsmV5uzdPeeCIM/x5+PK44J7DkXbZ2bVT3Lzz vpCiICuEJ1gOkdlQzUyicnRSbqG1bJemsReuoUu+vRzsl13uxBnI+MfK5i0IeTV3hrRieGXw6qF mQy2dOgsV6vAx6HWWiZqn2wHrA== X-Received: by 2002:a05:6102:8517:20b0:7b3:b35c:368 with SMTP id ada2fe7eead31-7b3b35c221dmr1016013137.0.1790682310295; Tue, 29 Sep 2026 04:45:10 -0700 (PDT) Received: from 192.168.1.109 ([2803:3c90:cee:ea00:5c3c:7e70:29e3:7a55]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-7b39b9ae253sm13006029137.8.2026.09.29.04.45.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2026 04:45:09 -0700 (PDT) From: Manu To: Alexandre Felipe Cc: pgsql-hackers@lists.postgresql.org Subject: Re: BUG #19686: Rolling back SET TABLESPACE Date: Tue, 29 Sep 2026 08:45:06 -0300 Message-ID: <179068230696.82006.12914137377671511798@gmail.com> In-Reply-To: References: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Al, I built v2 on master (82d31451606) with --enable-cassert and checked the two cases, plus your question. v2 fixes both. The double SET TABLESPACE now lands right: a table moved to ts and then back to pg_default in one transaction ends in pg_default, where v1 left it in ts. The original recipe is still fixed: the rollback + INSERT btree case does not trap and bt_index_check reports nothing, against master where it fails the _bt_posting_valid assertion. One build problem: v2-0002 does not compile with --enable-cassert. deferred_tablespace_move_compare_relid() reads its cells with lfirst_node(PendingTablespaceMove, ...), but PendingTablespaceMove is a plain struct, not a Node, so T_PendingTablespaceMove is undeclared. Without assertions castNode() is a plain cast, so the build passes, which is why it slips through, but the cassert buildfarm animals would fail on it. PreCommit_on_commit_actions() walks on_commits with a plain (OnCommitItem *) lfirst() cast; the same here builds under cassert. > I just noticed that if someone check the pg_tablespaces inside the > transaction they will get unexpected results. (Is that something we > need to fix?) I can reproduce it. With v2, inside the transaction pg_class.reltablespace for an indexed table still reads the old tablespace until commit, since the whole move is deferred. On master SET TABLESPACE updates the catalog at execution time, so a query in the same transaction sees the new tablespace right away. So v2 does change that observable behavior. Whether it is worth fixing is your call. The one thing I'd note is that the alternative, showing the pending tablespace in the catalog within the transaction, would leave reltablespace pointing at a tablespace the file has not reached until commit, so it isn't only a matter of moving the catalog update earlier. I'll leave the design to you; I mainly wanted to confirm the behavior is real and that it differs from master. Regards, Manu