pgsql: On Windows, ensure shared memory handle gets closed if not being

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: On Windows, ensure shared memory handle gets closed if not being
Дата
Msg-id E1Zm1Op-0003hp-6Z@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
On Windows, ensure shared memory handle gets closed if not being used.

Postmaster child processes that aren't supposed to be attached to shared
memory were not bothering to close the shared memory mapping handle they
inherit from the postmaster process.  That's mostly harmless, since the
handle vanishes anyway when the child process exits -- but the syslogger
process, if used, doesn't get killed and restarted during recovery from a
backend crash.  That meant that Windows doesn't see the shared memory
mapping as becoming free, so it doesn't delete it and the postmaster is
unable to create a new one, resulting in failure to recover from crashes
whenever logging_collector is turned on.

Per report from Dmitry Vasilyev.  It's a bit astonishing that we'd not
figured this out long ago, since it's been broken from the very beginnings
of out native Windows support; probably some previously-unexplained trouble
reports trace to this.

A secondary problem is that on Cygwin (perhaps only in older versions?),
exec() may not detach from the shared memory segment after all, in which
case these child processes did remain attached to shared memory, posing
the risk of an unexpected shared memory clobber if they went off the rails
somehow.  That may be a long-gone bug, but we can deal with it now if it's
still live, by detaching within the infrastructure introduced here to deal
with closing the handle.

Back-patch to all supported branches.

Tom Lane and Amit Kapila

Branch
------
REL9_1_STABLE

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

Modified Files
--------------
src/backend/port/sysv_shmem.c       |   53 ++++++++++++++++++----
src/backend/port/win32_shmem.c      |   82 ++++++++++++++++++++++++++++-------
src/backend/postmaster/postmaster.c |    5 ++-
src/include/storage/pg_shmem.h      |    1 +
4 files changed, 116 insertions(+), 25 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: On Windows, ensure shared memory handle gets closed if not being
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: On Windows, ensure shared memory handle gets closed if not being