mirror of
https://github.com/postgres/postgres.git
synced 2025-07-09 22:41:56 +03:00
Get more info about Windows can't-reattach-to-shared-memory errors.
Commit 63ca350ef
neglected to probe the state of things *before*
the VirtualFree call, which now looks like it might be interesting.
Discussion: https://postgr.es/m/25495.1524517820@sss.pgh.pa.us
This commit is contained in:
@ -388,10 +388,18 @@ PGSharedMemoryReAttach(void)
|
|||||||
{
|
{
|
||||||
PGShmemHeader *hdr;
|
PGShmemHeader *hdr;
|
||||||
void *origUsedShmemSegAddr = UsedShmemSegAddr;
|
void *origUsedShmemSegAddr = UsedShmemSegAddr;
|
||||||
|
MEMORY_BASIC_INFORMATION previnfo;
|
||||||
|
DWORD queryerr;
|
||||||
|
|
||||||
Assert(UsedShmemSegAddr != NULL);
|
Assert(UsedShmemSegAddr != NULL);
|
||||||
Assert(IsUnderPostmaster);
|
Assert(IsUnderPostmaster);
|
||||||
|
|
||||||
|
/* Preliminary probe of region we intend to release */
|
||||||
|
if (VirtualQuery(UsedShmemSegAddr, &previnfo, sizeof(previnfo)) != 0)
|
||||||
|
queryerr = 0;
|
||||||
|
else
|
||||||
|
queryerr = GetLastError();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Release memory region reservation that was made by the postmaster
|
* Release memory region reservation that was made by the postmaster
|
||||||
*/
|
*/
|
||||||
@ -405,12 +413,20 @@ PGSharedMemoryReAttach(void)
|
|||||||
DWORD maperr = GetLastError();
|
DWORD maperr = GetLastError();
|
||||||
MEMORY_BASIC_INFORMATION info;
|
MEMORY_BASIC_INFORMATION info;
|
||||||
|
|
||||||
|
if (queryerr == 0)
|
||||||
|
elog(LOG, "VirtualQuery(%p) before free reports region of size %zu, base %p, has state 0x%lx",
|
||||||
|
UsedShmemSegAddr, previnfo.RegionSize,
|
||||||
|
previnfo.AllocationBase, previnfo.State);
|
||||||
|
else
|
||||||
|
elog(LOG, "VirtualQuery(%p) before free failed: error code %lu",
|
||||||
|
UsedShmemSegAddr, queryerr);
|
||||||
|
|
||||||
if (VirtualQuery(UsedShmemSegAddr, &info, sizeof(info)) != 0)
|
if (VirtualQuery(UsedShmemSegAddr, &info, sizeof(info)) != 0)
|
||||||
elog(LOG, "VirtualQuery(%p) reports region of size %zu, base %p, has state 0x%lx",
|
elog(LOG, "VirtualQuery(%p) after free reports region of size %zu, base %p, has state 0x%lx",
|
||||||
UsedShmemSegAddr, info.RegionSize,
|
UsedShmemSegAddr, info.RegionSize,
|
||||||
info.AllocationBase, info.State);
|
info.AllocationBase, info.State);
|
||||||
else
|
else
|
||||||
elog(LOG, "VirtualQuery(%p) failed: error code %lu",
|
elog(LOG, "VirtualQuery(%p) after free failed: error code %lu",
|
||||||
UsedShmemSegAddr, GetLastError());
|
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",
|
||||||
|
Reference in New Issue
Block a user