mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
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 bcbf2346d6.
Discussion: https://postgr.es/m/20190402135442.GA1173872@rfd.leadboat.com
This commit is contained in:
@@ -484,6 +484,7 @@ typedef struct
|
||||
#ifndef WIN32
|
||||
unsigned long UsedShmemSegID;
|
||||
#else
|
||||
void *ShmemProtectiveRegion;
|
||||
HANDLE UsedShmemSegID;
|
||||
#endif
|
||||
void *UsedShmemSegAddr;
|
||||
@@ -6041,6 +6042,9 @@ save_backend_variables(BackendParameters *param, Port *port,
|
||||
param->MyCancelKey = MyCancelKey;
|
||||
param->MyPMChildSlot = MyPMChildSlot;
|
||||
|
||||
#ifdef WIN32
|
||||
param->ShmemProtectiveRegion = ShmemProtectiveRegion;
|
||||
#endif
|
||||
param->UsedShmemSegID = UsedShmemSegID;
|
||||
param->UsedShmemSegAddr = UsedShmemSegAddr;
|
||||
|
||||
@@ -6274,6 +6278,9 @@ restore_backend_variables(BackendParameters *param, Port *port)
|
||||
MyCancelKey = param->MyCancelKey;
|
||||
MyPMChildSlot = param->MyPMChildSlot;
|
||||
|
||||
#ifdef WIN32
|
||||
ShmemProtectiveRegion = param->ShmemProtectiveRegion;
|
||||
#endif
|
||||
UsedShmemSegID = param->UsedShmemSegID;
|
||||
UsedShmemSegAddr = param->UsedShmemSegAddr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user