mirror of
https://github.com/postgres/postgres.git
synced 2025-11-18 02:02:55 +03:00
Fix inplace update buffer self-deadlock.
A CacheInvalidateHeapTuple* callee might call
CatalogCacheInitializeCache(), which needs a relcache entry. Acquiring
a valid relcache entry might scan pg_class. Hence, to prevent
undetected LWLock self-deadlock, CacheInvalidateHeapTuple* callers must
not hold BUFFER_LOCK_EXCLUSIVE on buffers of pg_class. Move the
CacheInvalidateHeapTupleInplace() before the BUFFER_LOCK_EXCLUSIVE. No
back-patch, since I've reverted commit
243e9b40f1 from non-master branches.
Reported by Alexander Lakhin. Reviewed by Alexander Lakhin.
Discussion: https://postgr.es/m/10ec0bc3-5933-1189-6bb8-5dec4114558e@gmail.com
This commit is contained in:
12
src/backend/utils/cache/inval.c
vendored
12
src/backend/utils/cache/inval.c
vendored
@@ -1201,6 +1201,18 @@ AtInplace_Inval(void)
|
||||
inplaceInvalInfo = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* ForgetInplace_Inval
|
||||
* Alternative to PreInplace_Inval()+AtInplace_Inval(): discard queued-up
|
||||
* invalidations. This lets inplace update enumerate invalidations
|
||||
* optimistically, before locking the buffer.
|
||||
*/
|
||||
void
|
||||
ForgetInplace_Inval(void)
|
||||
{
|
||||
inplaceInvalInfo = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* AtEOSubXact_Inval
|
||||
* Process queued-up invalidation messages at end of subtransaction.
|
||||
|
||||
Reference in New Issue
Block a user