Re: SUBTRANS: Minimizing calls to SubTransSetParent()

From: Japin Li <japinli(at)hotmail(dot)com>
To: Simon Riggs <simon(dot)riggs(at)enterprisedb(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-15 11:36:40
Message-ID: MEYP282MB1669E4CCD5CA5D7C02AB8FFFB6499@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


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.

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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2022-09-15 11:39:45 Re: Perform streaming logical transactions by background workers and parallel apply
Previous Message Ranier Vilela 2022-09-15 11:26:34 Re: Avoid use deprecated Windows Memory API