Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nJMlQ-0005Jx-Qj for pgsql-bugs@arkaria.postgresql.org; Sun, 13 Feb 2022 21:50:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nJMlP-0007Pr-K9 for pgsql-bugs@arkaria.postgresql.org; Sun, 13 Feb 2022 21:50:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nJMlP-0007Pi-Bh for pgsql-bugs@lists.postgresql.org; Sun, 13 Feb 2022 21:50:35 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nJMlN-0002dd-3l for pgsql-bugs@lists.postgresql.org; Sun, 13 Feb 2022 21:50:35 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 21DLoTlG2733420; Sun, 13 Feb 2022 16:50:29 -0500 From: Tom Lane To: Masahiko Sawada cc: Dmitry Koval , Dilip Kumar , andrewbille@gmail.com, PostgreSQL mailing lists Subject: Re: BUG #17385: "RESET transaction_isolation" inside serializable transaction causes Assert at the transaction end In-reply-to: References: <17385-9ee529fb091f0ce5@postgresql.org> <6e31c4ef-de9a-960b-1a21-e3b6ff0fa9c2@postgrespro.ru> Comments: In-reply-to Masahiko Sawada message dated "Mon, 07 Feb 2022 11:41:26 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2733418.1644789029.1@sss.pgh.pa.us> Date: Sun, 13 Feb 2022 16:50:29 -0500 Message-ID: <2733419.1644789029@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Masahiko Sawada writes: > On Mon, Feb 7, 2022 at 6:21 AM Dmitry Koval wrote: > + if (source != PGC_S_DEFAULT) > + { > + /* Release newextra as we use reset_extra */ > + if (newextra) > + free(newextra); > + > + newextra = conf->reset_extra; > + source = conf->gen.reset_source; > + context = conf->gen.reset_scontext; > + } > I think it's better to check if "!extra_field_used(&conf->gen, > newextra)" before freeing newextra because otherwise, it's possible > that we free reset_extra. I've updated an updated patch, please check > it. I feel this is still pretty confused about what to do with reset_extra. If we go this way, there's very little reason to have reset_extra at all, so maybe we should get rid of it and save the associated bookkeeping logic. AFAICS the only remaining place that would be using reset_extra is ResetAllOptions(), which could also be made to compute the new extra value using the check_hook instead of relying on having it already. But the mention of ResetAllOptions brings up a bigger intellectual inconsistency: why hasn't the patch touched that already? Surely, resetting a variable via RESET ALL is just as much of a risk as resetting it explicitly. Now, if you try to break it by doing "BEGIN set-some-xact-property; SELECT 1; RESET ALL", there's no crash. That's because the transaction state GUCs are marked GUC_NO_RESET_ALL, so that ResetAllOptions doesn't actually do anything to them. But that makes me wonder if we need to reconsider the relationship of that flag to what we're doing here. It seems like a GUC might have an old value that we couldn't necessarily RESET to, without also wanting to exempt it from RESET ALL. However, if it isn't exempt, yet the check_hook fails, what shall we do then? Is throwing an error the best thing, or should we silently leave the variable alone? I think a lot of people would be unhappy if RESET ALL / DISCARD ALL had failure conditions of this sort. Should we document that GUCs having state-dependent restrictions on their values had better be marked GUC_NO_RESET_ALL? If so, can we enforce that? So it seems like we still have some definitional issues to sort out. regards, tom lane