Re: SUBTRANS: Minimizing calls to SubTransSetParent()

From: Simon Riggs <simon(dot)riggs(at)enterprisedb(dot)com>
To: Japin Li <japinli(at)hotmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: SUBTRANS: Minimizing calls to SubTransSetParent()
Date: 2022-09-16 12:20:20
Message-ID: CANbhV-FWbmxXtVfGyec961jKO4JA3OiY4dc5Y348T5GEd5qK+g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 15 Sept 2022 at 12:36, Japin Li <japinli(at)hotmail(dot)com> wrote:
>
>
> On Thu, 15 Sep 2022 at 18:04, Simon Riggs <simon(dot)riggs(at)enterprisedb(dot)com> wrote:
> > On Wed, 14 Sept 2022 at 15:21, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
> >>
> >> On 2022-Aug-30, Simon Riggs wrote:
> >>
> >> > 001_new_isolation_tests_for_subxids.v3.patch
> >> > Adds new test cases to master without adding any new code, specifically
> >> > addressing the two areas of code that are not tested by existing tests.
> >> > This gives us a baseline from which we can do test driven development.
> >> > I'm hoping this can be reviewed and committed fairly smoothly.
> >>
> >> I gave this a quick run to confirm the claimed increase of coverage. It
> >> checks out, so pushed.
> >
> > Thank you.
> >
> > So now we just have the main part of the patch, reattached here for
> > the auto patch tester's benefit.
>
> Hi Simon,
>
> Thanks for the updated patch, here are some comments.

Thanks for your comments.

> There is a typo, s/SubTransGetTopMostTransaction/SubTransGetTopmostTransaction/g.
>
> + * call SubTransGetTopMostTransaction() if that xact overflowed;
>
>
> Is there a punctuation mark missing on the following first line?
>
> + * 2. When IsolationIsSerializable() we sometimes need to access topxid
> + * This occurs only when SERIALIZABLE is requested by app user.
>
>
> When we use function name in comments, some places we use parentheses,
> but others do not use it. Why? I think, we should keep them consistent,
> at least in the same commit.
>
> + * 3. When TransactionIdSetTreeStatus will use a status of SUB_COMMITTED,
> + * which then requires us to consult subtrans to find parent, which
> + * is needed to avoid race condition. In this case we ask Clog/Xact
> + * module if TransactionIdsAreOnSameXactPage(). Since we start a new
> + * clog page every 32000 xids, this is usually <<1% of subxids.

I've reworded those comments, hoping to address all of your above points.

> Maybe we declaration a topxid to avoid calling GetTopTransactionId()
> twice when we should set subtrans parent?
>
> + TransactionId subxid = XidFromFullTransactionId(s->fullTransactionId);
> + TransactionId topxid = GetTopTransactionId();
> ...
> + if (MyProc->subxidStatus.overflowed ||
> + IsolationIsSerializable() ||
> + !TransactionIdsAreOnSameXactPage(topxid, subxid))
> + {
> ...
> + SubTransSetParent(subxid, topxid);
> + }

Seems a minor point, but I've done this anyway.

Thanks for the review.

v10 attached

--
Simon Riggs http://www.EnterpriseDB.com/

Attachment Content-Type Size
002_minimize_calls_to_SubTransSetParent.v10.patch application/octet-stream 20.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2022-09-16 12:33:23 Pruning never visible changes
Previous Message Simon Riggs 2022-09-16 12:13:51 Error for WITH options on partitioned tables