postgresql/src/backend/port
Tom Lane 869f693a36 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
2015-10-13 11:21:33 -04:00
..
aix Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
darwin pgindent run for 9.4 2014-05-06 12:12:18 -04:00
dynloader Update copyright for 2015 2015-01-06 11:43:47 -05:00
hpux Redefine Datum as uintptr_t, instead of unsigned long. 2009-12-31 19:41:37 +00:00
tas Update copyright for 2015 2015-01-06 11:43:47 -05:00
win32 Update copyright for 2015 2015-01-06 11:43:47 -05:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
Makefile Add a basic atomic ops API abstracting away platform/architecture details. 2014-09-25 23:49:05 +02:00
atomics.c Rely on inline functions even if that causes warnings in older compilers. 2015-08-05 18:19:52 +02:00
posix_sema.c Remove the option to service interrupts during PGSemaphoreLock(). 2015-02-03 23:25:00 +01:00
sysv_sema.c Remove the option to service interrupts during PGSemaphoreLock(). 2015-02-03 23:25:00 +01:00
sysv_shmem.c On Windows, ensure shared memory handle gets closed if not being used. 2015-10-13 11:21:33 -04:00
unix_latch.c Make WaitLatchOrSocket's timeout detection more robust. 2015-07-18 11:47:13 -04:00
win32_latch.c Make WaitLatchOrSocket's timeout detection more robust. 2015-07-18 11:47:13 -04:00
win32_sema.c pgindent run for 9.5 2015-05-23 21:35:49 -04:00
win32_shmem.c On Windows, ensure shared memory handle gets closed if not being used. 2015-10-13 11:21:33 -04:00