Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit63ca350

Browse files
committed
Try to get some info about Windows can't-reattach-to-shared-memory errors.
Add some debug printouts focused on the idea that MapViewOfFileEx mightbe 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 buildfarmmembers dory or jacana, we might revert this ... or perhaps justdecrease the log level.Discussion:https://postgr.es/m/25495.1524517820@sss.pgh.pa.us
1 parent2e83e6b commit63ca350

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

‎src/backend/port/win32_shmem.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port,
191191
SIZE_TlargePageSize=0;
192192
Sizeorig_size=size;
193193
DWORDflProtect=PAGE_READWRITE;
194+
MEMORY_BASIC_INFORMATIONinfo;
194195

195196
/* Room for a header? */
196197
Assert(size>MAXALIGN(sizeof(PGShmemHeader)));
@@ -359,6 +360,14 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port,
359360
/* Register on-exit routine to delete the new segment */
360361
on_shmem_exit(pgwin32_SharedMemoryDelete,PointerGetDatum(hmap2));
361362

363+
/* Log information about the segment's virtual memory use */
364+
if (VirtualQuery(memAddress,&info,sizeof(info))!=0)
365+
elog(LOG,"mapped shared memory segment at %p, requested size %zu, mapped size %zu",
366+
memAddress,size,info.RegionSize);
367+
else
368+
elog(LOG,"VirtualQuery(%p) failed: error code %lu",
369+
memAddress,GetLastError());
370+
362371
*shim=hdr;
363372
returnhdr;
364373
}
@@ -392,8 +401,21 @@ PGSharedMemoryReAttach(void)
392401

393402
hdr= (PGShmemHeader*)MapViewOfFileEx(UsedShmemSegID,FILE_MAP_READ |FILE_MAP_WRITE,0,0,0,UsedShmemSegAddr);
394403
if (!hdr)
404+
{
405+
DWORDmaperr=GetLastError();
406+
MEMORY_BASIC_INFORMATIONinfo;
407+
408+
if (VirtualQuery(UsedShmemSegAddr,&info,sizeof(info))!=0)
409+
elog(LOG,"VirtualQuery(%p) reports region of size %zu, base %p, has state 0x%lx",
410+
UsedShmemSegAddr,info.RegionSize,
411+
info.AllocationBase,info.State);
412+
else
413+
elog(LOG,"VirtualQuery(%p) failed: error code %lu",
414+
UsedShmemSegAddr,GetLastError());
415+
395416
elog(FATAL,"could not reattach to shared memory (key=%p, addr=%p): error code %lu",
396-
UsedShmemSegID,UsedShmemSegAddr,GetLastError());
417+
UsedShmemSegID,UsedShmemSegAddr,maperr);
418+
}
397419
if (hdr!=origUsedShmemSegAddr)
398420
elog(FATAL,"reattaching to shared memory returned unexpected address (got %p, expected %p)",
399421
hdr,origUsedShmemSegAddr);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp