mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Relax lock level for setting PGPROC->statusFlags
We don't actually need a lock to set PGPROC->statusFlags itself; what we do need is a shared lock on either XidGenLock or ProcArrayLock in order to ensure MyProc->pgxactoff keeps still while we modify the mirror array in ProcGlobal->statusFlags. Some places were using an exclusive lock for that, which is excessive. Relax those to use shared lock only. procarray.c has a couple of places with somewhat brittle assumptions about PGPROC changes: ProcArrayEndTransaction uses only shared lock, so it's permissible to change MyProc only. On the other hand, ProcArrayEndTransactionInternal also changes other procs, so it must hold exclusive lock. Add asserts to ensure those assumptions continue to hold. Author: Álvaro Herrera <alvherre@alvh.no-ip.org> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/20201117155501.GA13805@alvherre.pgsql
This commit is contained in:
@@ -623,7 +623,7 @@ FindLockCycleRecurseMember(PGPROC *checkProc,
|
||||
* because that flag is set at process start and never
|
||||
* reset. There is logic elsewhere to avoid canceling an
|
||||
* autovacuum that is working to prevent XID wraparound
|
||||
* problems (which needs to read a different vacuumFlag
|
||||
* problems (which needs to read a different statusFlags
|
||||
* bit), but we don't do that here to avoid grabbing
|
||||
* ProcArrayLock.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user