Content-Length: 292467 | pFad | https://github.com/postgrespro/postgres/commit/23078689a9921968ac0873b017be6e7f772f10bc

E0 Does it help to wait before reattaching? · postgrespro/postgres@2307868 · GitHub
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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/postgrespro/postgres/commit/23078689a9921968ac0873b017be6e7f772f10bc

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy