Re: SUBTRANS: Minimizing calls to SubTransSetParent() - Mailing list pgsql-hackers

From Japin Li
Subject Re: SUBTRANS: Minimizing calls to SubTransSetParent()
Date
Msg-id MEYP282MB1669E4CCD5CA5D7C02AB8FFFB6499@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Whole thread Raw
In response to Re: SUBTRANS: Minimizing calls to SubTransSetParent()  (Simon Riggs <simon.riggs@enterprisedb.com>)
Responses Re: SUBTRANS: Minimizing calls to SubTransSetParent()
List pgsql-hackers
On Thu, 15 Sep 2022 at 18:04, Simon Riggs <simon.riggs@enterprisedb.com> wrote:
> On Wed, 14 Sept 2022 at 15:21, Alvaro Herrera <alvherre@alvh.no-ip.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.

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.

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);
+        }

-- 
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.



pgsql-hackers by date:

Previous
From: Ranier Vilela
Date:
Subject: Re: Avoid use deprecated Windows Memory API
Next
From: Amit Kapila
Date:
Subject: Re: Perform streaming logical transactions by background workers and parallel apply