]> granicus.if.org Git - postgresql/commit
Avoid "could not reattach" by providing space for concurrent allocation.
authorNoah Misch <noah@leadboat.com>
Tue, 9 Apr 2019 04:39:00 +0000 (21:39 -0700)
committerNoah Misch <noah@leadboat.com>
Tue, 9 Apr 2019 04:39:04 +0000 (21:39 -0700)
commit57ebbbb8f15acf3136f1417a462735d15af28623
tree3caab8a667378f3ce519522ef70515d50323a0a4
parent23791c41576a86f0536b314f78ccaa5ee689f80c
Avoid "could not reattach" by providing space for concurrent allocation.

We've long had reports of intermittent "could not reattach to shared
memory" errors on Windows.  Buildfarm member dory fails that way when
PGSharedMemoryReAttach() execution overlaps with creation of a thread
for the process's "default thread pool".  Fix that by providing a second
region to receive asynchronous allocations that would otherwise intrude
into UsedShmemSegAddr.  In pgwin32_ReserveSharedMemoryRegion(), stop
trying to free reservations landing at incorrect addresses; the caller's
next step has been to terminate the affected process.  Back-patch to 9.4
(all supported versions).

Reviewed by Tom Lane.  He also did much of the prerequisite research;
see commit bcbf2346d69f6006f126044864dd9383d50d87b4.

Discussion: https://postgr.es/m/20190402135442.GA1173872@rfd.leadboat.com
src/backend/port/win32_shmem.c
src/backend/postmaster/postmaster.c
src/include/storage/pg_shmem.h