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 1nJbX6-0003xV-4o for pgsql-committers@arkaria.postgresql.org; Mon, 14 Feb 2022 13:36:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nJbX4-0008GC-Ia for pgsql-committers@arkaria.postgresql.org; Mon, 14 Feb 2022 13:36:46 +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 1nJbX3-0008G3-Mp for pgsql-committers@lists.postgresql.org; Mon, 14 Feb 2022 13:36:46 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nJbWz-0001hO-Fu for pgsql-committers@lists.postgresql.org; Mon, 14 Feb 2022 13:36:45 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id F147B3201F1D; Mon, 14 Feb 2022 08:36:37 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 14 Feb 2022 08:36:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=6CpTYzZrNmwhzn30TuYuW0mC6Hom1LVdCmEd2oR6M5Q=; b=iwcKHKQG Zc3bsPcXHzjigiWW3KdQSd4TTfAvFhIaues6+FAp1UUU7HxvRfwa/qf9r6T2R+zS ZiOayo8SRG2WcnLSrbGfhSg3cEnR2rcA7Y+5adt1lx+7cZxaiKGwlM6mMIAsJoS0 NJXHAfwtwH3lJXbE82nUYHgiCDqsUm1u/pGSp8nYzzmkzu//fSbd1itpiafqTeSf SogBA6OxM/Esme2bKjYXY1MEyoe9SZlgd8rPVCZyMGI0gBnpcTuge5/OVhmoLCLr N/2YEsvpjS/7CBQ6+EDEnwfKWdwOS49HrNnpg8OyG6V0K4UtH3iNvd/7v6XhkwSu mfvraqEfYjvT2Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrjedvgdehtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkgggtugfgjgesmhekreertddtjeenucfhrhhomheptehlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqne cuggftrfgrthhtvghrnheptedvhfetueeukeefhfefudegfffhhefhvdelffelteekgeeg fefhgfegkeejtddunecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomhenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgv rhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 14 Feb 2022 08:36:36 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 128E72A08E0; Mon, 14 Feb 2022 10:36:34 -0300 (-03) Date: Mon, 14 Feb 2022 10:36:34 -0300 From: Alvaro Herrera To: Tomas Vondra Cc: Tomas Vondra , pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Fix skip-empty-xacts with sequences in test_decoding Message-ID: <202202141336.xv35beswc6ec@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="vkvc2wo7v3n5dl7q" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3dd2a8ed-f757-5c22-7a0a-91b0b4f11174@enterprisedb.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --vkvc2wo7v3n5dl7q Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2022-Feb-13, Tomas Vondra wrote: > >> Fixing the tests however uncovered a bug in the code, because sequence > >> callbacks did not handle skip-empty-xacts properly. For trasactional > >> increments we need to check/update the xact_wrote_changes flag, and emit > >> the BEGIN if it's the first change in the transaction. > > > > Hmm. Perhaps there should be a separate test script that runs various > > things under skip-empty-xacts=0 and somehow protected against ancillary > > activities (maybe a TAP test using autovacuum=0), just so that this new > > code is covered ... > > I'm not sure what exactly would be the benefit? Yeah, it's pointless. I propose the attached comment additions instead. -- Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/ --vkvc2wo7v3n5dl7q Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="comments.patch" diff --git a/contrib/test_decoding/test_decoding.c b/contrib/test_decoding/test_decoding.c index ea22649e41..c7a87f5fe5 100644 --- a/contrib/test_decoding/test_decoding.c +++ b/contrib/test_decoding/test_decoding.c @@ -322,6 +322,10 @@ pg_decode_begin_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn) txndata->xact_wrote_changes = false; txn->output_plugin_private = txndata; + /* + * If asked to skip empty transactions, we'll emit BEGIN at the point where + * the first operation is received for this transaction. + */ if (data->skip_empty_xacts) return; @@ -378,6 +382,10 @@ pg_decode_begin_prepare_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn) txndata->xact_wrote_changes = false; txn->output_plugin_private = txndata; + /* + * If asked to skip empty transactions, we'll emit BEGIN at the point where + * the first operation is received for this transaction. + */ if (data->skip_empty_xacts) return; @@ -392,6 +400,10 @@ pg_decode_prepare_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, TestDecodingData *data = ctx->output_plugin_private; TestDecodingTxnData *txndata = txn->output_plugin_private; + /* + * If asked to skip empty transactions, we'll emit PREPARE at the point + * where the first operation is received for this transaction. + */ if (data->skip_empty_xacts && !txndata->xact_wrote_changes) return; --vkvc2wo7v3n5dl7q--