pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aditya Gollamudi <adigollamudi@gmail.com>
To: Ashutosh Sharma <ashu.coek88@gmail.com>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Cc: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Cc: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: michael@paquier.xyz
Cc: bertranddrouvot.pg@gmail.com
Cc: andres@anarazel.de
Cc: shveta.malik@gmail.com
Cc: pgsql-hackers@postgresql.org
Subject: Re: Report bytes and transactions actually sent downtream
Date: Wed, 19 Aug 2026 23:01:04 -0400
Message-ID: <802ced07-1530-4cb3-9bf3-215fe61308ee@gmail.com> (raw)
In-Reply-To: <CAE9k0PnWMWM7PgcWRwNitcpEDhOnmku2iyrnTDDGbwZ-cL_-4A@mail.gmail.com>
References: <CAExHW5uCYoessP7TtCZiPBjXz4JOAkW0nZ5SAEiGLMzSY_hkDA@mail.gmail.com>
	<20260615.151943.2105002076083694041.horikyota.ntt@gmail.com>
	<CAE9k0Png8jDd-UHLy8c1Vi55RkH5p=fyo7eWu+Dp-0KRqXakFw@mail.gmail.com>
	<20260615.180401.1834123951330189307.horikyota.ntt@gmail.com>
	<CAA4eK1L48XxBgE12Byp6tAq631PikciBFYSkGD8G4O++=C1=OA@mail.gmail.com>
	<CAExHW5tXc+PNw1vmFj3h=XaNTSABr=8hNRsp+00Oo7shBwPt3A@mail.gmail.com>
	<CAD21AoC+JoYKBAgTXR4fDWeL71cRDOvx-JmCOVQhWhCHG6r34w@mail.gmail.com>
	<CAA4eK1KVQfQtdYKocfsxB1njEQGx4fhMX4N0bjmozG7Sx_V8Sw@mail.gmail.com>
	<CAE9k0PkFYru=y9MLGWGgXQH1Ba7=aouBOMxdaMaDBnOK=N-9_g@mail.gmail.com>
	<CAD21AoBaP60vGeGoW5Twizf6NKsDD_G4JD2gUHFgX0CywiaM3g@mail.gmail.com>
	<CAE9k0PnBLCA0ZrzanQVyQCRnfk3rRZqctejCC3Cp9ZnhjMiyvQ@mail.gmail.com>
	<CAE9k0P=jOU_C++2gtWwnRuDt8hZ3puAmSOnU3XLdNZyoqSr0wg@mail.gmail.com>
	<CAD21AoCJ5rT+-4hg0PmssdxHsFTR+KFitfrrfbZwopgqDqQgLA@mail.gmail.com>
	<CAE9k0PnWMWM7PgcWRwNitcpEDhOnmku2iyrnTDDGbwZ-cL_-4A@mail.gmail.com>

On 7/3/26 1:44 AM, Ashutosh Sharma wrote:

> Thank you for your review comments.
>
> I have swapped the patch order - please see attached.
>
> In the refactoring patch, I also ensured that reorderbuffer.h does not
> depend on pgstat.h. To make that possible, I introduced a shared
> header, src/include/replication/replslot_stats.h, where
> PgStat_ReplSlotStats is defined. Both pgstat.h and reorderbuffer.h
> include that header. Hope that helps!
>
> --
> With Regards,
> Ashutosh Sharma.

Hi Ashutosh!

Thanks for the updated patches. I reviewed the latest two as
part of the July patch review workshop:

First, I wasn't able to cleanly apply the refactoring patch against the
current tree. It could be an issue on my end, but it may need to be
checked again.

Secondly, this was mentioned earlier in the thread and handled for
the SQL API path but I believe an excess 25 bytes is still being
counted by output_bytes in the WALsender path because of an
unaccounted for header.

In WalSndPrepareWrite(), we call pq_sendbyte() and pq_sendint64()
twice in order to send some header data. In order to be consistent
with the renaming to "output_bytes" I think that should not
be included. One way this could be fixed is through an offset that
simply accounts for this header data, and subtracts it from output_bytes:

/* OutputPluginPrepareWrite */
ctx->prepare_write(ctx, ctx->write_location, ctx->write_xid, last_write);
ctx->prepared_write_offset = ctx->out->len;

/* OutputPluginWrite */
ctx->reorder->stats.output_bytes += ctx->out->len - 
ctx->prepared_write_offset;

Finally, I wonder if the test coverage is sufficient. We only
assert that output_bytes is > 0 and that it is equal to 0 after a reset
happens. Should we also check that it is equal to the expected
number of bytes for the output_plugin?

 From what I can tell, in the SQL API path, we know the data comes
from the buffer contents. So maybe additional verification
could do something along the lines of:


length output plugin produced data == output_bytes delta

I'm fairly new to patch reviews and the postgres community
so I'm curious what your thoughts are!


Is the new code I suggested to remove the 25 bytes and potentially
more tests worth it?

Best,
Adi Gollamudi







view thread (123+ messages)  latest in thread

Message-ID: <802ced07-1530-4cb3-9bf3-215fe61308ee@gmail.com>
Permalink:  ../802ced07-1530-4cb3-9bf3-215fe61308ee@gmail.com/
Also on:    postgresql.org/message-id/802ced07-1530-4cb3-9bf3-215fe61308ee@gmail.com

 · 

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-hackers@postgresql.org
  Cc: adigollamudi@gmail.com, ashu.coek88@gmail.com, sawada.mshk@gmail.com, amit.kapila16@gmail.com, ashutosh.bapat.oss@gmail.com, horikyota.ntt@gmail.com, michael@paquier.xyz, bertranddrouvot.pg@gmail.com, andres@anarazel.de, shveta.malik@gmail.com
  Subject: Re: Report bytes and transactions actually sent downtream
  In-Reply-To: <802ced07-1530-4cb3-9bf3-215fe61308ee@gmail.com>
  References: <CAExHW5uCYoessP7TtCZiPBjXz4JOAkW0nZ5SAEiGLMzSY_hkDA@mail.gmail.com> <CAE9k0Png8jDd-UHLy8c1Vi55RkH5p=fyo7eWu+Dp-0KRqXakFw@mail.gmail.com> <20260615.180401.1834123951330189307.horikyota.ntt@gmail.com> <CAA4eK1L48XxBgE12Byp6tAq631PikciBFYSkGD8G4O++=C1=OA@mail.gmail.com> <CAExHW5tXc+PNw1vmFj3h=XaNTSABr=8hNRsp+00Oo7shBwPt3A@mail.gmail.com> <CAD21AoC+JoYKBAgTXR4fDWeL71cRDOvx-JmCOVQhWhCHG6r34w@mail.gmail.com> <CAA4eK1KVQfQtdYKocfsxB1njEQGx4fhMX4N0bjmozG7Sx_V8Sw@mail.gmail.com> <CAE9k0PkFYru=y9MLGWGgXQH1Ba7=aouBOMxdaMaDBnOK=N-9_g@mail.gmail.com> <CAD21AoBaP60vGeGoW5Twizf6NKsDD_G4JD2gUHFgX0CywiaM3g@mail.gmail.com> <CAE9k0PnBLCA0ZrzanQVyQCRnfk3rRZqctejCC3Cp9ZnhjMiyvQ@mail.gmail.com> <CAE9k0P=jOU_C++2gtWwnRuDt8hZ3puAmSOnU3XLdNZyoqSr0wg@mail.gmail.com> <CAD21AoCJ5rT+-4hg0PmssdxHsFTR+KFitfrrfbZwopgqDqQgLA@mail.gmail.com> <CAE9k0PnWMWM7PgcWRwNitcpEDhOnmku2iyrnTDDGbwZ-cL_-4A@mail.gmail.com> <802ced07-1530-4cb3-9bf3-215fe61308ee@gmail.com>

* 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