Re: Use proc instead of MyProc in ProcArrayGroupClearXid()/TransactionGroupUpdateXidStatus()

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: rajesh singarapu <rajesh(dot)rs0541(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Use proc instead of MyProc in ProcArrayGroupClearXid()/TransactionGroupUpdateXidStatus()
Date: 2022-11-08 06:26:13
Message-ID: CALj2ACX6g7vW1zxKZGSfxN3bt=nH5b-VWrkNdNs2q8Vtk+h-HQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 7, 2022 at 3:17 PM rajesh singarapu <rajesh(dot)rs0541(at)gmail(dot)com> wrote:
>
> Hi,
>
> In both TransactionGroupUpdateXidStatus and ProcArrayGroupClearXid
> global MyProc is used. for consistency, replaced with a function local variable.

if (nextproc != MyProc)
PGSemaphoreUnlock(nextproc->sem);

The intention of this wake up code in the two functions is to skip the
leader process from waking itself up. Only the leader gets to execute
this code and all the followers don't hit this code at all as they
return from the first loop in those functions.

All the callers of ProcArrayGroupClearXid() get MyProc as their proc
and pass it down. And using the passed down function parameter proc
makes the function look consistent.

And, in TransactionGroupUpdateXidStatus() proc is initialized with
MyProc and using it instead of MyProc in the wake up loop also makes
the code consistent.

While it does no harm with the existing way using MyProc, +1 for
replacing it with the local variable proc in both the functions for
consistency.

Another thing I noticed is an extra assertion in
ProcArrayGroupClearXid() Assert(TransactionIdIsValid(proc->xid));, the
caller already has the same assertion, I think we can also remove it.

--
Bharath Rupireddy
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2022-11-08 06:28:35 Re: Use proc instead of MyProc in ProcArrayGroupClearXid()/TransactionGroupUpdateXidStatus()
Previous Message Amit Langote 2022-11-08 06:22:32 Re: generic plans and "initial" pruning