pgsql: Reorder actions in ProcArrayApplyRecoveryInfo()
Reorder actions in ProcArrayApplyRecoveryInfo()
Since 5a1dfde8334b, 2PC filenames use FullTransactionId. Thus, it needs to
convert TransactionId to FullTransactionId in StandbyTransactionIdIsPrepared()
using TransamVariables->nextXid. However, ProcArrayApplyRecoveryInfo()
first releases locks with usage StandbyTransactionIdIsPrepared(), then advances
TransamVariables->nextXid. This sequence of actions could cause errors.
This commit makes ProcArrayApplyRecoveryInfo() advance
TransamVariables->nextXid before releasing locks.
Reported-by: Thomas Munro, Michael Paquier
Discussion: /messages/by-id/CA+hUKGLj_ve1_pNAnxwYU9rDcv7GOhsYXJt7jMKSA=5-6ss-Cw@mail.gmail.com
Discussion: /messages/by-id/Zadp9f4E1MYvMJqe@paquier.xyz
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/c64086b79dbad19e4ee0af8d19e835111aa87bd5
Modified Files
--------------
src/backend/storage/ipc/procarray.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
Alexander Korotkov <akorotkov@postgresql.org> writes:
Reorder actions in ProcArrayApplyRecoveryInfo()
I'm seeing this warning since this commit:
procarray.c: In function 'ProcArrayApplyRecoveryInfo':
procarray.c:1172:17: warning: declaration of 'xid' shadows a previous local [-Wshadow=compatible-local]
TransactionId xid = running->xids[i];
^~~
procarray.c:1056:16: note: shadowed declaration is here
TransactionId xid;
^~~
regards, tom lane
On Fri, Jan 19, 2024 at 6:08 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Alexander Korotkov <akorotkov@postgresql.org> writes:
Reorder actions in ProcArrayApplyRecoveryInfo()
I'm seeing this warning since this commit:
procarray.c: In function 'ProcArrayApplyRecoveryInfo':
procarray.c:1172:17: warning: declaration of 'xid' shadows a previous local [-Wshadow=compatible-local]
TransactionId xid = running->xids[i];
^~~
procarray.c:1056:16: note: shadowed declaration is here
TransactionId xid;
^~~
Thank you for reporting. Must be fixed in 448a3331d9.
------
Regards,
Alexander Korotkov