postgresql/src/backend
Tom Lane 6708e447ef Clean up shm_mq cleanup.
The logic around shm_mq_detach was a few bricks shy of a load, because
(contrary to the comments for shm_mq_attach) all it did was update the
shared shm_mq state.  That left us leaking a bit of process-local
memory, but much worse, the on_dsm_detach callback for shm_mq_detach
was still armed.  That means that whenever we ultimately detach from
the DSM segment, we'd run shm_mq_detach again for already-detached,
possibly long-dead queues.  This accidentally fails to fail today,
because we only ever re-use a shm_mq's memory for another shm_mq, and
multiple detach attempts on the last such shm_mq are fairly harmless.
But it's gonna bite us someday, so let's clean it up.

To do that, change shm_mq_detach's API so it takes a shm_mq_handle
not the underlying shm_mq.  This makes the callers simpler in most
cases anyway.  Also fix a few places in parallel.c that were just
pfree'ing the handle structs rather than doing proper cleanup.

Back-patch to v10 because of the risk that the revenant shm_mq_detach
callbacks would cause a live bug sometime.  Since this is an API
change, it's too late to do it in 9.6.  (We could make a variant
patch that preserves API, but I'm not excited enough to do that.)

Discussion: https://postgr.es/m/8670.1504192177@sss.pgh.pa.us
2017-08-31 15:10:24 -04:00
..
access Clean up shm_mq cleanup. 2017-08-31 15:10:24 -04:00
bootstrap Change tupledesc->attrs[n] to TupleDescAttr(tupledesc, n). 2017-08-20 11:19:07 -07:00
catalog Change tupledesc->attrs[n] to TupleDescAttr(tupledesc, n). 2017-08-20 11:19:07 -07:00
commands Propagate sort instrumentation from workers back to leader. 2017-08-29 13:26:33 -04:00
executor Clean up shm_mq cleanup. 2017-08-31 15:10:24 -04:00
foreign Abstract logic to allow for multiple kinds of child rels. 2017-04-03 22:41:31 -04:00
lib Consolidate the function pointer types used by dshash.c. 2017-08-24 17:01:36 -07:00
libpq Clean up shm_mq cleanup. 2017-08-31 15:10:24 -04:00
main Change pg_ctl to detect server-ready by watching status in postmaster.pid. 2017-06-28 17:31:32 -04:00
nodes Force rescanning of parallel-aware scan nodes below a Gather[Merge]. 2017-08-30 09:29:55 -04:00
optimizer Force rescanning of parallel-aware scan nodes below a Gather[Merge]. 2017-08-30 09:29:55 -04:00
parser Improve plural handling in error message 2017-08-23 13:56:59 -04:00
po Translation updates 2017-08-07 13:55:34 -04:00
port Change pg_ctl to detect server-ready by watching status in postmaster.pid. 2017-06-28 17:31:32 -04:00
postmaster Simplify autovacuum work-item implementation 2017-08-15 18:14:07 -03:00
regex Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
replication Change tupledesc->attrs[n] to TupleDescAttr(tupledesc, n). 2017-08-20 11:19:07 -07:00
rewrite Change tupledesc->attrs[n] to TupleDescAttr(tupledesc, n). 2017-08-20 11:19:07 -07:00
snowball Initial pgindent run with pg_bsd_indent version 2.0. 2017-06-21 14:39:04 -04:00
statistics Remove obsolete comments about functional dependencies 2017-07-26 11:40:39 -04:00
storage Clean up shm_mq cleanup. 2017-08-31 15:10:24 -04:00
tcop Remove uses of "slave" in replication contexts 2017-08-10 22:55:41 -04:00
tsearch Improve make_tsvector() to handle empty input, and simplify its callers. 2017-07-18 13:13:47 -04:00
utils Propagate sort instrumentation from workers back to leader. 2017-08-29 13:26:33 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Add ICU_CFLAGS to global CPPFLAGS 2017-06-12 15:57:22 -04:00
Makefile Inject $(ICU_LIBS) regardless of platform. 2017-08-20 21:22:18 -07:00
nls.mk Translation updates 2017-05-15 12:19:54 -04:00