| From: | Melanie Plageman <melanieplageman(at)gmail(dot)com> |
|---|---|
| To: | Andres Freund <andres(at)anarazel(dot)de> |
| Cc: | Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Noah Misch <noah(at)leadboat(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
| Subject: | Re: Buffer locking is special (hints, checksums, AIO writes) |
| Date: | 2025-11-25 21:23:04 |
| Message-ID: | CAAKRu_apB8+6dDaDBE+tPv8H8rmta3JHomTKFh7VEZK-LYga1g@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, Nov 25, 2025 at 3:46 PM Andres Freund <andres(at)anarazel(dot)de> wrote:
>
>
> > > > I presume you didn't do this because HeapTupleSatisifiesMVCC() for
> > > > SNAPSHOT_MVCC calls the non-batch version (and, of course,
> > > > HeapTupleSatisifiesVisibility() is the much more common case).
> > > >
> > > > if (TransactionIdIsValid(xid))
> > > > {
> > > > if (BufferIsPermanent(buffer))
> > > > {
> > > > /* NB: xid must be known committed here! */
> > > > XLogRecPtr commitLSN = TransactionIdGetCommitLSN(xid);
> > > >
> > > > if (XLogNeedsFlush(commitLSN) &&
> > > > BufferGetLSNAtomic(buffer) < commitLSN)
> > > > {
> > > > /* not flushed and no LSN interlock, so don't
> > > > set hint */
> > > > return; false;
> > > > }
> > > > }
> > > > }
> > > >
> > > > Separately, I was thinking, should we assert here about having the
> > > > right lock type?
> > >
> > > Not sure I get what assert of what locktype where?
> >
> > In SetHintBitsExt() that we have share-exclusive or above.
>
> We *don't* necessarily hold that though, it'll just be acquired by
> BufferBeginSetHintBits(). Or do you mean in the SHB_ENABLED case?
Yea, in the enabled case. Also, can't we skip the whole
if (TransactionIdIsValid(xid))
{
if (BufferIsPermanent(buffer))
{
/* NB: xid must be known committed here! */
XLogRecPtr commitLSN = TransactionIdGetCommitLSN(xid);
if (XLogNeedsFlush(commitLSN) &&
BufferGetLSNAtomic(buffer) < commitLSN)
{
/* not flushed and no LSN interlock, so don't set hint */
return;
}
}
}
part if state is SHB_DISABLED?
- Melanie
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Melanie Plageman | 2025-11-25 21:43:58 | Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access) |
| Previous Message | Nathan Bossart | 2025-11-25 21:16:00 | Re: pgsql: Teach DSM registry to ERROR if attaching to an uninitialized ent |