Skip to content

Commit 4fd05bb

Browse files
committed
Fix deadlock in heap_compute_xid_horizon_for_tuples().
We can't call code that uses syscache while we hold buffer locks on a catalog relation. If passed such a relation, just fall back to the general effective_io_concurrency GUC rather than trying to look up the containing tablespace's IO concurrency setting. We might find a better way to control prefetching in follow-up work, but for now this is enough to avoid the deadlock introduced by commit 558a916. Reviewed-by: Andres Freund Diagnosed-by: Peter Geoghegan Discussion: https://postgr.es/m/CA%2BhUKGLCwPF0S4Mk7S8qw%2BDK0Bq65LueN9rofAA3HHSYikW-Zw%40mail.gmail.com Discussion: https://postgr.es/m/962831d8-c18d-180d-75fb-8b842e3a2742%40chrullrich.net
1 parent 12d46ac commit 4fd05bb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/backend/access/heap/heapam.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6976,8 +6976,15 @@ heap_compute_xid_horizon_for_tuples(Relation rel,
69766976
* more prefetching in this case, too. It may be that this formula is too
69776977
* simplistic, but at the moment there is no evidence of that or any idea
69786978
* about what would work better.
6979+
*
6980+
* Since the caller holds a buffer lock somewhere in rel, we'd better make
6981+
* sure that isn't a catalog relation before we call code that does
6982+
* syscache lookups, to avoid risk of deadlock.
69796983
*/
6980-
io_concurrency = get_tablespace_io_concurrency(rel->rd_rel->reltablespace);
6984+
if (IsCatalogRelation(rel))
6985+
io_concurrency = effective_io_concurrency;
6986+
else
6987+
io_concurrency = get_tablespace_io_concurrency(rel->rd_rel->reltablespace);
69816988
prefetch_distance = Min((io_concurrency) + 10, MAX_IO_CONCURRENCY);
69826989

69836990
/* Start prefetching. */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy