Re: Report bytes and transactions actually sent downtream - Mailing list pgsql-hackers

From shveta malik
Subject Re: Report bytes and transactions actually sent downtream
Date
Msg-id CAJpy0uDruaT7euWk5UjJjXtrbyPr5AtBKN78GLaBjSaU3jV4yA@mail.gmail.com
Whole thread Raw
In response to Re: Report bytes and transactions actually sent downtream  (shveta malik <shveta.malik@gmail.com>)
List pgsql-hackers
Few comments:

1)
pgoutput_truncate:

if (nrelids > 0)
{
OutputPluginPrepareWrite(ctx, true);
logicalrep_write_truncate(ctx->out,
  xid,
  nrelids,
  relids,
  change->data.truncate.cascade,
  change->data.truncate.restart_seqs);
OutputPluginWrite(ctx, true);
}
+ else
+ ctx->stats->filteredBytes += ReorderBufferChangeSize(change);
+

It seems that filteredBytes are only counted for TRUNCATE when nrelids
is 0. Can nrelids only be 0 or same as nrelations?

The below code makes me think that nrelids can be any number between 0
and nrelations, depending on which relations are publishable and which
supports publishing TRUNCATE. If that’s true, shouldn’t we count
filteredBytes in each such skipped case?

if (!is_publishable_relation(relation))
continue;

relentry = get_rel_sync_entry(data, relation);

if (!relentry->pubactions.pubtruncate)
continue;


2)
+ int64 filteredBytes; /* amount of data from reoder buffer that was

reoder --> reorder

3)
One small nitpick:

+ /*
+ * If output plugin has chosen to maintain its stats, update the amount of
+ * data sent downstream.
+ */
+ if (ctx->stats)
+ ctx->stats->sentBytes += ctx->out->len + sizeof(XLogRecPtr) +
sizeof(TransactionId);

The way sentBytes is updated here feels a bit unnatural; we’re adding
the lengths for values[2], then [0], and then [1]. Would it be cleaner
to introduce a len[3] array similar to the existing values[3] and
nulls[3] arrays? We could initialize len[i] alongside values[i], and
later just sum up all three elements when updating
ctx->stats->sentBytes. It would be easier to understand as well.

thanks
Shveta



pgsql-hackers by date:

Previous
From: Aleksander Alekseev
Date:
Subject: Re: Add uuid_to_base32hex() and base32hex_to_uuid() built-in functions
Next
From: shveta malik
Date:
Subject: Re: POC: enable logical decoding when wal_level = 'replica' without a server restart