On Mon, Jun 2, 2025 at 3:40 PM Peter Geoghegan <p...@bowt.ie> wrote:
>
> On Mon, Jun 2, 2025 at 3:30 PM Melanie Plageman
> <melanieplage...@gmail.com> wrote:
>
> > But, for cases when a few tuples are frozen on the page, it seems like it 
> > could
> > be worth it?
>
> In general, I don't expect that we're all that likely to freeze some
> tuples on the page, without being able to subsequently mark the whole
> page as all-frozen in the VM. Obviously it happens more often when
> VACUUM FREEZE is used -- though that works best as an argument against
> VACUUM FREEZE.
>
> A scheme like the one you're thinking of might be worth the
> implementation effort if it ended up being simpler. As you pointed
> out, we're already doing almost the same thing for pruning. Now that
> pruning and freezing both happen in the same place, it might make
> sense to do it just to make things more consistent.

Yes, I would only be interested in such a thing if it improved code
clarity too. I imagine that a few less queries canceled on the standby
couldn't be worth additional code complexity in this sensitive area
that, as is evidenced by my starting this thread, is already difficult
to understand.

Perhaps I could keep track of the newest modified xid or some such
thing that is the newer of the newest removed xmax and newest frozen
xmin.

I actually started looking at this code again because I am writing a
patch set to update the VM in the same critical section and WAL record
as where we now prune and freeze. As part of this, I have  to figure
out the right snapshot conflict horizon to use for the combined WAL
record.

I think, however, that I can't avoid keeping a separate counter for
the horizon for the VM record. Pruning and freezing horizon is the
newest "modified" (pruned or frozen) tuple xid, whereas the VM record
needs the newest live committed tuple's xmin <= OldestXmin. So,
perhaps maintaining multiple counters is unavoidable.

So, I wasn't actually planning (originally) to write a patch to try
and change the horizon to make it older in more cases when it's
correct. I'm trying to figure out the most straightforward code to
calculate the combined snapshot conflict horizon for a prune/freeze/vm
update record.

Anyway, thanks for taking the time to answer these questions and
discuss. I've found that when working this stuff out on my own, I
sometimes end up going in circles.

- Melanie


Reply via email to