pgsql: Clean up handling of anonymous mmap'd shared-memory segment.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Clean up handling of anonymous mmap'd shared-memory segment.
Дата
Msg-id E1bukIg-0004Sh-9h@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Clean up handling of anonymous mmap'd shared-memory segment.

Fix detaching of the mmap'd segment to have its own on_shmem_exit callback,
rather than piggybacking on the one for detaching from the SysV segment.
That was confusing, and given the distance between the two attach calls,
it was trouble waiting to happen.

Make the detaching calls idempotent by clearing AnonymousShmem to show
we've already unmapped.  I spent quite a bit of time yesterday trying
to find a path that would allow the munmap()'s to be done twice, and
while I did not succeed, it seems silly that there's even a question.

Make the #ifdef logic less confusing by separating "do we want to use
anonymous shmem" from EXEC_BACKEND.  Even though there's no current
scenario where those conditions are different, it is not helpful for
different places in the same file to be testing EXEC_BACKEND for what
are fundamentally different reasons.

Don't do on_exit_reset() in StartBackgroundWorker().  At best that's
useless (InitPostmasterChild would have done it already) and at worst
it could zap some callback that's unrelated to shared memory.

Improve comments, and simplify the huge_pages enablement logic slightly.

Back-patch to 9.4 where hugepage support was introduced.
Arguably this should go into 9.3 as well, but the code looks
significantly different there, and I doubt it's worth the
trouble of adapting the patch given I can't show a live bug.

Branch
------
REL9_5_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/b1b56b653c036cfb64e162d498b4d0ae79e6b10d

Modified Files
--------------
src/backend/port/sysv_shmem.c     | 127 ++++++++++++++++++++++++--------------
src/backend/postmaster/bgworker.c |   1 -
2 files changed, 82 insertions(+), 46 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Clean up handling of anonymous mmap'd shared-memory segment.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Clean up handling of anonymous mmap'd shared-memory segment.