Issue about memory order on ARM

From: 盏一 <w(at)hidva(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Issue about memory order on ARM
Date: 2019-12-01 07:31:55
Message-ID: tencent_0A67458526FCC13F055424A0@qq.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The code in GetSnapshotData() that read the `xid` field of&nbsp; PGXACT struct has a dependency on code in GetNewTransactionId() that write `MyPgXact-&gt;xid`. It means that the store of xid should happen before the load of it. In C11, we can use [Release-Acquire ordering](https://en.cppreference.com/w/c/atomic/memory_order#Release-Acquire_ordering) to achieve it. But now, there is no special operation to do it(, and the [volatile](https://en.cppreference.com/w/c/language/volatile) keyword should not play any role in this situation).

So it means that when a backend A returns from GetNewTransactionId(), the newval of `MyPgXact-&gt;xid` maybe just in CPU store buffer, or CPU cache line, so the newval is not yet visible to backend B that calling GetSnapshotData(). So the assumption that 'all top-level XIDs <= latestCompletedXid are either present in the ProcArray, or not running anymore' may not be safe.&nbsp;

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sergei Kornilov 2019-12-01 10:06:42 Re: [HACKERS] Block level parallel vacuum
Previous Message Amit Kapila 2019-12-01 05:16:17 Re: [HACKERS] Block level parallel vacuum