aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-04-27 21:59:58 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-04-27 21:59:58 -0400
commit63ca350ef9f58d48ac89fd3c68416e319cac0a39 (patch)
treefa300d6be047362c9cdeb2cb4c2c3ba796cf56d7 /src
parent2e83e6bd74ee8d4d119edf8272406f23e6c546cf (diff)
downloadpostgresql-63ca350ef9f58d48ac89fd3c68416e319cac0a39.tar.gz
postgresql-63ca350ef9f58d48ac89fd3c68416e319cac0a39.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/backend/port/win32_shmem.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/backend/port/win32_shmem.c b/src/backend/port/win32_shmem.c
index f8ca52e1afe..d431e0d0362 100644
--- a/src/backend/port/win32_shmem.c
+++ b/src/backend/port/win32_shmem.c
@@ -191,6 +191,7 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port,
SIZE_T largePageSize = 0;
Size orig_size = size;
DWORD flProtect = PAGE_READWRITE;
+ MEMORY_BASIC_INFORMATION info;
/* Room for a header? */
Assert(size > MAXALIGN(sizeof(PGShmemHeader)));
@@ -359,6 +360,14 @@ retry:
/* Register on-exit routine to delete the new segment */
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;
return hdr;
}
@@ -392,8 +401,21 @@ PGSharedMemoryReAttach(void)
hdr = (PGShmemHeader *) MapViewOfFileEx(UsedShmemSegID, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0, UsedShmemSegAddr);
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",
- UsedShmemSegID, UsedShmemSegAddr, GetLastError());
+ UsedShmemSegID, UsedShmemSegAddr, maperr);
+ }
if (hdr != origUsedShmemSegAddr)
elog(FATAL, "reattaching to shared memory returned unexpected address (got %p, expected %p)",
hdr, origUsedShmemSegAddr);