pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: Alexander Korotkov <aekorotkov@gmail.com>
Cc: Dmitry Koval <d.koval@postgrespro.ru>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: collect_corrupt_items_vacuum.patch
Date: Tue, 2 Jul 2024 15:59:49 -0700
Message-ID: <20240702225949.ed.nmisch@google.com> (raw)
In-Reply-To: <CAPpHfdvVAgQO_J7FJ4Q3O1okxjD1f7Z5sg=bCTo=Xxg=tR5GZQ@mail.gmail.com>
References: <8e6bd629-fa69-371c-966d-aaf071aafeb8@gmail.com>
	<CAPpHfdt8Rj_LtG8aWKNzeRejutrN-zt6fKQGuXYyAE7-zNVHbg@mail.gmail.com>
	<918b9dc0-9af0-a62a-19cc-cb858b163299@gmail.com>
	<dc247df2-34ee-4d19-8294-86d1f391b57f@postgrespro.ru>
	<CAPpHfdt635ay8KpZ_drMRHSFs=a17RYEh3uqx2BnW-p8S6oMQQ@mail.gmail.com>
	<ed7d3fd8-a5c4-400f-be31-4a8da8f0780e@postgrespro.ru>
	<CAPpHfdviiR1oG9Y7O4i1d8cY2gj8o1g-zM+Y8pR+Y=LVNvcqXw@mail.gmail.com>
	<CAPpHfdvN1wsFsPkA8O_DuY3=cOWw0F9nBPi4biyC1+juYQpqdw@mail.gmail.com>
	<20240630231816.bf.nmisch@google.com>
	<CAPpHfdvVAgQO_J7FJ4Q3O1okxjD1f7Z5sg=bCTo=Xxg=tR5GZQ@mail.gmail.com>

On Wed, Jul 03, 2024 at 12:31:48AM +0300, Alexander Korotkov wrote:
> On Mon, Jul 1, 2024 at 2:18 AM Noah Misch <noah@leadboat.com> wrote:
> > Commit e85662d wrote:
> > > --- a/src/backend/storage/ipc/procarray.c
> > > +++ b/src/backend/storage/ipc/procarray.c
> >
> > > @@ -2740,6 +2741,8 @@ GetRunningTransactionData(void)
> > >        */
> > >       for (index = 0; index < arrayP->numProcs; index++)
> > >       {
> > > +             int                     pgprocno = arrayP->pgprocnos[index];
> > > +             PGPROC     *proc = &allProcs[pgprocno];
> > >               TransactionId xid;
> > >
> > >               /* Fetch xid just once - see GetNewTransactionId */
> > > @@ -2760,6 +2763,13 @@ GetRunningTransactionData(void)
> > >               if (TransactionIdPrecedes(xid, oldestRunningXid))
> > >                       oldestRunningXid = xid;
> > >
> > > +             /*
> > > +              * Also, update the oldest running xid within the current database.
> > > +              */
> > > +             if (proc->databaseId == MyDatabaseId &&
> > > +                     TransactionIdPrecedes(xid, oldestRunningXid))
> > > +                     oldestDatabaseRunningXid = xid;
> >
> > Shouldn't that be s/oldestRunningXid/oldestDatabaseRunningXid/?
> 
> Thank you for catching this.
> 
> > While this isn't a hot path, I likely would test TransactionIdPrecedes()
> > before fetching pgprocno and PGPROC, to reduce wasted cache misses.
> 
> And thanks for suggestion.
> 
> The patchset is attached.  0001 implements
> s/oldestRunningXid/oldestDatabaseRunningXid/.  0002 implements cache
> misses optimization.
> 
> If no objection, I'll backpatch 0001 and apply 0002 to the head.

Looks fine.  I'd drop the comment update as saying the obvious, but keeping it
is okay.





view thread (27+ messages)  latest in thread

Message-ID: <20240702225949.ed.nmisch@google.com>
Permalink:  ../20240702225949.ed.nmisch@google.com/
Also on:    postgresql.org/message-id/20240702225949.ed.nmisch@google.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: noah@leadboat.com, aekorotkov@gmail.com, d.koval@postgrespro.ru
  Subject: Re: collect_corrupt_items_vacuum.patch
  In-Reply-To: <20240702225949.ed.nmisch@google.com>
  References: <8e6bd629-fa69-371c-966d-aaf071aafeb8@gmail.com> <CAPpHfdt8Rj_LtG8aWKNzeRejutrN-zt6fKQGuXYyAE7-zNVHbg@mail.gmail.com> <918b9dc0-9af0-a62a-19cc-cb858b163299@gmail.com> <dc247df2-34ee-4d19-8294-86d1f391b57f@postgrespro.ru> <CAPpHfdt635ay8KpZ_drMRHSFs=a17RYEh3uqx2BnW-p8S6oMQQ@mail.gmail.com> <ed7d3fd8-a5c4-400f-be31-4a8da8f0780e@postgrespro.ru> <CAPpHfdviiR1oG9Y7O4i1d8cY2gj8o1g-zM+Y8pR+Y=LVNvcqXw@mail.gmail.com> <CAPpHfdvN1wsFsPkA8O_DuY3=cOWw0F9nBPi4biyC1+juYQpqdw@mail.gmail.com> <20240630231816.bf.nmisch@google.com> <CAPpHfdvVAgQO_J7FJ4Q3O1okxjD1f7Z5sg=bCTo=Xxg=tR5GZQ@mail.gmail.com> <20240702225949.ed.nmisch@google.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