RE: Assertion failure in SnapBuildInitialSnapshot() - Mailing list pgsql-hackers

From Hayato Kuroda (Fujitsu)
Subject RE: Assertion failure in SnapBuildInitialSnapshot()
Date
Msg-id TYAPR01MB58667EC946ADCDC04DD9D186F5CC9@TYAPR01MB5866.jpnprd01.prod.outlook.com
Whole thread Raw
In response to Re: Assertion failure in SnapBuildInitialSnapshot()  (Masahiko Sawada <sawada.mshk@gmail.com>)
Responses Re: Assertion failure in SnapBuildInitialSnapshot()  (Amit Kapila <amit.kapila16@gmail.com>)
List pgsql-hackers
Dear Sawada-san,

Thank you for making the patch! I'm still considering whether this approach is
correct, but I can put a comment to your patch anyway.

```
-    Assert(!already_locked || LWLockHeldByMe(ProcArrayLock));
-
-    if (!already_locked)
-        LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
+    Assert(LWLockHeldByMe(ProcArrayLock));
```

In this function, we regard that the ProcArrayLock has been already acquired as
exclusive mode and modify data. I think LWLockHeldByMeInMode() should be used
instead of LWLockHeldByMe().
I confirmed that there is only one caller that uses ReplicationSlotsComputeRequiredXmin(true)
and it acquires exclusive lock correctly, but it can avoid future bug.

Best Regards,
Hayato Kuroda
FUJITSU LIMITED


pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Time delayed LR (WAS Re: logical replication restrictions)
Next
From: Bharath Rupireddy
Date:
Subject: Re: Syncrep and improving latency due to WAL throttling