Try to get some info about Windows can't-reattach-to-shared-memory errors.
Add some debug printouts focused on the idea that MapViewOfFileEx might be rounding its virtual memory allocation up more than we expect (and, in particular, more than VirtualAllocEx does). Once we've seen what this reports in one of the failures on buildfarm members dory or jacana, we might revert this ... or perhaps just decrease the log level. Discussion: https://postgr.es/m/25495.1524517820@sss.pgh.pa.us
This commit is contained in:
parent
2e83e6bd74
commit
63ca350ef9
@ -191,6 +191,7 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port,
|
|||||||
SIZE_T largePageSize = 0;
|
SIZE_T largePageSize = 0;
|
||||||
Size orig_size = size;
|
Size orig_size = size;
|
||||||
DWORD flProtect = PAGE_READWRITE;
|
DWORD flProtect = PAGE_READWRITE;
|
||||||
|
MEMORY_BASIC_INFORMATION info;
|
||||||
|
|
||||||
/* Room for a header? */
|
/* Room for a header? */
|
||||||
Assert(size > MAXALIGN(sizeof(PGShmemHeader)));
|
Assert(size > MAXALIGN(sizeof(PGShmemHeader)));
|
||||||
@ -359,6 +360,14 @@ retry:
|
|||||||
/* Register on-exit routine to delete the new segment */
|
/* Register on-exit routine to delete the new segment */
|
||||||
on_shmem_exit(pgwin32_SharedMemoryDelete, PointerGetDatum(hmap2));
|
on_shmem_exit(pgwin32_SharedMemoryDelete, PointerGetDatum(hmap2));
|
||||||
|
|
||||||
|
/* Log information about the segment's virtual memory use */
|
||||||
|
if (VirtualQuery(memAddress, &info, sizeof(info)) != 0)
|
||||||
|
elog(LOG, "mapped shared memory segment at %p, requested size %zu, mapped size %zu",
|
||||||
|
memAddress, size, info.RegionSize);
|
||||||
|
else
|
||||||
|
elog(LOG, "VirtualQuery(%p) failed: error code %lu",
|
||||||
|
memAddress, GetLastError());
|
||||||
|
|
||||||
*shim = hdr;
|
*shim = hdr;
|
||||||
return hdr;
|
return hdr;
|
||||||
}
|
}
|
||||||
@ -392,8 +401,21 @@ PGSharedMemoryReAttach(void)
|
|||||||
|
|
||||||
hdr = (PGShmemHeader *) MapViewOfFileEx(UsedShmemSegID, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0, UsedShmemSegAddr);
|
hdr = (PGShmemHeader *) MapViewOfFileEx(UsedShmemSegID, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0, UsedShmemSegAddr);
|
||||||
if (!hdr)
|
if (!hdr)
|
||||||
|
{
|
||||||
|
DWORD maperr = GetLastError();
|
||||||
|
MEMORY_BASIC_INFORMATION info;
|
||||||
|
|
||||||
|
if (VirtualQuery(UsedShmemSegAddr, &info, sizeof(info)) != 0)
|
||||||
|
elog(LOG, "VirtualQuery(%p) reports region of size %zu, base %p, has state 0x%lx",
|
||||||
|
UsedShmemSegAddr, info.RegionSize,
|
||||||
|
info.AllocationBase, info.State);
|
||||||
|
else
|
||||||
|
elog(LOG, "VirtualQuery(%p) failed: error code %lu",
|
||||||
|
UsedShmemSegAddr, GetLastError());
|
||||||
|
|
||||||
elog(FATAL, "could not reattach to shared memory (key=%p, addr=%p): error code %lu",
|
elog(FATAL, "could not reattach to shared memory (key=%p, addr=%p): error code %lu",
|
||||||
UsedShmemSegID, UsedShmemSegAddr, GetLastError());
|
UsedShmemSegID, UsedShmemSegAddr, maperr);
|
||||||
|
}
|
||||||
if (hdr != origUsedShmemSegAddr)
|
if (hdr != origUsedShmemSegAddr)
|
||||||
elog(FATAL, "reattaching to shared memory returned unexpected address (got %p, expected %p)",
|
elog(FATAL, "reattaching to shared memory returned unexpected address (got %p, expected %p)",
|
||||||
hdr, origUsedShmemSegAddr);
|
hdr, origUsedShmemSegAddr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user