pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Tomas Vondra <tomas.vondra@enterprisedb.com>
Cc: Tomas Vondra <tomas.vondra@postgresql.org>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix skip-empty-xacts with sequences in test_decoding
Date: Mon, 14 Feb 2022 10:36:34 -0300
Message-ID: <202202141336.xv35beswc6ec@alvherre.pgsql> (raw)
In-Reply-To: <3dd2a8ed-f757-5c22-7a0a-91b0b4f11174@enterprisedb.com>

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/

Attachments:

comments.patch (text/x-diff, 1.4K) download 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;

view thread (6+ messages)  latest in thread

Message-ID: <202202141336.xv35beswc6ec@alvherre.pgsql>
Permalink:  ../202202141336.xv35beswc6ec@alvherre.pgsql/
Also on:    postgresql.org/message-id/202202141336.xv35beswc6ec@alvherre.pgsql

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: alvherre@alvh.no-ip.org, tomas.vondra@enterprisedb.com, tomas.vondra@postgresql.org
  Subject: Re: pgsql: Fix skip-empty-xacts with sequences in test_decoding
  In-Reply-To: <202202141336.xv35beswc6ec@alvherre.pgsql>
  References: <3dd2a8ed-f757-5c22-7a0a-91b0b4f11174@enterprisedb.com> <202202141336.xv35beswc6ec@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox