Skip to content

Commit 2307868

Browse files
committed
Does it help to wait before reattaching?
Revert the map/unmap dance I tried in commit 73042b8; that helps not at all. Instead, speculate that the unwanted allocation is being done on another thread, and thus timing variations explain the apparent unpredictability. Temporarily add a 1-second sleep before the VirtualFree call, in hopes that any such other threads will quiesce and not jog our elbow. This is obviously not a desirable long-term fix, but as a means of investigation it seems useful. Discussion: https://postgr.es/m/25495.1524517820@sss.pgh.pa.us
1 parent 73042b8 commit 2307868

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

src/backend/port/win32_shmem.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -456,22 +456,11 @@ PGSharedMemoryReAttach(void)
456456
/* Ensure buf is big enough that it won't grow mid-operation */
457457
initStringInfo(&buf);
458458
enlargeStringInfo(&buf, 128 * 1024);
459+
/* ... and let's just be sure all that space is committed */
460+
memset(buf.data, 0, buf.maxlen);
459461

460-
dumpmem(&buf, "beginning PGSharedMemoryReAttach");
461-
462-
hdr = (PGShmemHeader *) MapViewOfFileEx(UsedShmemSegID, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0, NULL);
463-
if (hdr)
464-
{
465-
if (!UnmapViewOfFile(hdr))
466-
elog(LOG, "could not unmap temporary view of shared memory: error code %lu",
467-
GetLastError());
468-
}
469-
else
470-
{
471-
/* This isn't fatal, just unpromising ... */
472-
elog(LOG, "could not attach to shared memory (key=%p) at any address: error code %lu",
473-
UsedShmemSegID, GetLastError());
474-
}
462+
/* Test: see if this lets the process address space quiesce */
463+
pg_usleep(1000000L);
475464

476465
dumpmem(&buf, "before VirtualFree");
477466

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy