Re: collect_corrupt_items_vacuum.patch
Alexander Korotkov <aekorotkov@gmail.com>
From: Alexander Korotkov <aekorotkov@gmail.com>
To: Noah Misch <noah@leadboat.com>
Cc: Dmitry Koval <d.koval@postgrespro.ru>, pgsql-hackers@lists.postgresql.org
Date: 2024-07-02T21:31:48Z
Lists: pgsql-hackers
Attachments
- v1-0002-Optimize-memory-access-in-GetRunningTransactionDa.patch (application/octet-stream) patch v1-0002
- v1-0001-Fix-typo-in-GetRunningTransactionData.patch (application/octet-stream) patch v1-0001
On Mon, Jul 1, 2024 at 2:18 AM Noah Misch <noah@leadboat.com> wrote:
> On Tue, Mar 12, 2024 at 02:10:59PM +0200, Alexander Korotkov wrote:
> > I'm going to push this if no objections.
>
> 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.
------
Regards,
Alexander Korotkov
Supabase
Commits
-
Fix GetStrictOldestNonRemovableTransactionId() on standby
- e2ed7e32271a 18.0 landed
-
Fix typo in GetRunningTransactionData()
- 619f76cce11d 17.0 landed
- 6c1af5482e69 18.0 landed
-
Optimize memory access in GetRunningTransactionData()
- 6897f0ec0245 18.0 landed
-
Fix false reports in pg_visibility
- e85662df44ff 17.0 landed
-
Fix indentation
- 4d0cf0b05def 17.0 cited