Re: minor fix in CancelVirtualTransaction - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: minor fix in CancelVirtualTransaction
Date
Msg-id c80a4866-00fc-b012-9b77-80c3e7e69be8@2ndquadrant.com
Whole thread Raw
In response to Re: minor fix in CancelVirtualTransaction  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: minor fix in CancelVirtualTransaction  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers
On 06/12/2018 21:37, Alvaro Herrera wrote:
> When scanning the list of virtual transactions looking for one
> particular vxid, we cancel the transaction *and* break out of the loop
> only if both backendId and localTransactionId matches us.  The canceling
> part is okay, but limiting the break to that case is pointless: if we
> found the correct backendId, there cannot be any other entry with the
> same backendId.  Rework the loop so that we break out of it if backendId
> matches even if the localTransactionId part doesn't.

Your reasoning seems correct to me.

Maybe add a code comment along the lines of "once we have found the
right ... we don't need to check the remaining ...".

Or, you can make this even more clear by comparing the backendId
directly with the proc entry:

if (vxid.backendId == proc->backendId)
{
    if (vxid.localTransactionId == proc->lxid)
    {

    }
    break;
}

Then the logic your are trying to achieve would be obvious.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: [PATCH] Pass COPT and PROFILE to CXXFLAGS as well
Next
From: Peter Eisentraut
Date:
Subject: Re: Feature: triggers on materialized views