From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: On Windows, ensure shared memory handle gets closed if not being |
Date: | 2015-10-13 15:21:59 |
Message-ID: | E1Zm1Op-0003hc-5Z@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/869f693a36556e9872c4369820ce8289451619f0
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(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2015-10-13 19:35:34 | pgsql: Improve INSERT .. ON CONFLICT error message. |
Previous Message | Andrew Dunstan | 2015-10-13 13:17:14 | Re: [COMMITTERS] pgsql: Cause TestLib.pm to define $windows_os in all branches. |