postgresql/src/include/storage
Tomas Vondra 5601f9fb97 Track unowned relations in doubly-linked list
Relations dropped in a single transaction are tracked in a list of
unowned relations.  With large number of dropped relations this resulted
in poor performance at the end of a transaction, when the relations are
removed from the singly linked list one by one.

Commit b4166911 attempted to address this issue (particularly when it
happens during recovery) by removing the relations in a reverse order,
resulting in O(1) lookups in the list of unowned relations.  This did
not work reliably, though, and it was possible to trigger the O(N^2)
behavior in various ways.

Instead of trying to remove the relations in a specific order with
respect to the linked list, which seems rather fragile, switch to a
regular doubly linked.  That allows us to remove relations cheaply no
matter where in the list they are.

As b4166911 was a bugfix, backpatched to all supported versions, do the
same thing here.

Reviewed-by: Alvaro Herrera
Discussion: https://www.postgresql.org/message-id/flat/80c27103-99e4-1d0c-642c-d9f3b94aaa0a%402ndquadrant.com
Backpatch-through: 9.4
2019-03-27 03:19:33 +01:00
..
.gitignore When trace_lwlocks is used, identify individual lwlocks by name. 2015-09-11 14:01:39 -04:00
backendid.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
block.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
buf.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
buf_internals.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
buffile.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
bufmgr.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
bufpage.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
checksum.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
checksum_impl.h Make checksum_impl.h safe to compile with -fstrict-aliasing. 2018-08-31 12:26:47 -04:00
condition_variable.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
copydir.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
dsm.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
dsm_impl.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
fd.h PANIC on fsync() failure. 2018-11-19 13:40:57 +13:00
freespace.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
fsm_internals.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
indexfsm.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
ipc.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
item.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
itemid.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
itemptr.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
large_object.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
latch.h Fix misc typos, mostly in comments. 2018-07-18 16:18:27 +03:00
lmgr.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
lock.h Fix longstanding recursion hazard in sinval message processing. 2018-09-07 18:04:56 -04:00
lockdefs.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
lwlock.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
off.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
pg_sema.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
pg_shmem.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
pmsignal.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
predicate.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
predicate_internals.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
proc.h Mark assorted variables PGDLLIMPORT. 2017-12-05 09:24:05 -05:00
procarray.h Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
proclist.h Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
proclist_types.h Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
procsignal.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
reinit.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
relfilenode.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
s_lock.h Add support for Motorola 88K to s_lock.h. 2017-11-20 17:57:46 -05:00
shm_mq.h Clean up shm_mq cleanup. 2017-08-31 15:10:24 -04:00
shm_toc.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
shmem.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
sinval.h Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
sinvaladt.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
smgr.h Track unowned relations in doubly-linked list 2019-03-27 03:19:33 +01:00
spin.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
standby.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
standbydefs.h Fix bugs in vacuum of shared rels, by keeping their relcache entries current. 2018-06-12 11:13:21 -07:00