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

Commitbcbf234

Browse files
committed
Remove investigative code for can't-reattach-to-shared-memory errors.
Revert commits2307868,73042b8,ce07aff,f7df804,6ba0cc4,eb16011,68e7e97,63ca350. We still have a problem here, butsomebody who's actually a Windows developer will need to spend timeon it.Discussion:https://postgr.es/m/25495.1524517820@sss.pgh.pa.us
1 parentfa94fa6 commitbcbf234

File tree

1 file changed

+1
-97
lines changed

1 file changed

+1
-97
lines changed

‎src/backend/port/win32_shmem.c

Lines changed: 1 addition & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
*/
1313
#include"postgres.h"
1414

15-
#include"lib/stringinfo.h"
1615
#include"miscadmin.h"
1716
#include"storage/dsm.h"
1817
#include"storage/ipc.h"
@@ -25,65 +24,6 @@ static Size UsedShmemSegSize = 0;
2524
staticboolEnableLockPagesPrivilege(intelevel);
2625
staticvoidpgwin32_SharedMemoryDelete(intstatus,DatumshmId);
2726

28-
staticconstchar*
29-
mi_type(DWORDcode)
30-
{
31-
switch (code)
32-
{
33-
caseMEM_IMAGE:
34-
return"img";
35-
caseMEM_MAPPED:
36-
return"map";
37-
caseMEM_PRIVATE:
38-
return"prv";
39-
}
40-
return"???";
41-
}
42-
43-
staticconstchar*
44-
mi_state(DWORDcode)
45-
{
46-
switch (code)
47-
{
48-
caseMEM_COMMIT:
49-
return"commit";
50-
caseMEM_FREE:
51-
return"free ";
52-
caseMEM_RESERVE:
53-
return"reserv";
54-
}
55-
return"???";
56-
}
57-
58-
/*
59-
* Append memory dump to buf. To avoid affecting the memory map mid-run,
60-
* buf should be preallocated to be bigger than needed.
61-
*/
62-
staticvoid
63-
dumpmem(StringInfobuf,constchar*reason)
64-
{
65-
char*addr=0;
66-
MEMORY_BASIC_INFORMATIONmi;
67-
68-
appendStringInfo(buf,"%s memory map:\n",reason);
69-
do
70-
{
71-
memset(&mi,0,sizeof(mi));
72-
if (!VirtualQuery(addr,&mi,sizeof(mi)))
73-
{
74-
if (GetLastError()==ERROR_INVALID_PARAMETER)
75-
break;
76-
appendStringInfo(buf,"VirtualQuery failed: %lu\n",GetLastError());
77-
break;
78-
}
79-
appendStringInfo(buf,"0x%p+0x%p %s (alloc 0x%p) %s\n",
80-
mi.BaseAddress, (void*)mi.RegionSize,
81-
mi_type(mi.Type),mi.AllocationBase,
82-
mi_state(mi.State));
83-
addr+=mi.RegionSize;
84-
}while (addr>0);
85-
}
86-
8727
/*
8828
* Generate shared memory segment name. Expand the data directory, to generate
8929
* an identifier unique for this data directory. Then replace all backslashes
@@ -251,7 +191,6 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port,
251191
SIZE_TlargePageSize=0;
252192
Sizeorig_size=size;
253193
DWORDflProtect=PAGE_READWRITE;
254-
MEMORY_BASIC_INFORMATIONinfo;
255194

256195
/* Room for a header? */
257196
Assert(size>MAXALIGN(sizeof(PGShmemHeader)));
@@ -420,14 +359,6 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port,
420359
/* Register on-exit routine to delete the new segment */
421360
on_shmem_exit(pgwin32_SharedMemoryDelete,PointerGetDatum(hmap2));
422361

423-
/* Log information about the segment's virtual memory use */
424-
if (VirtualQuery(memAddress,&info,sizeof(info))!=0)
425-
elog(LOG,"mapped shared memory segment at %p, requested size 0x%zx, mapped size 0x%zx",
426-
memAddress,size,info.RegionSize);
427-
else
428-
elog(LOG,"VirtualQuery(%p) failed: error code %lu",
429-
memAddress,GetLastError());
430-
431362
*shim=hdr;
432363
returnhdr;
433364
}
@@ -448,55 +379,28 @@ PGSharedMemoryReAttach(void)
448379
{
449380
PGShmemHeader*hdr;
450381
void*origUsedShmemSegAddr=UsedShmemSegAddr;
451-
StringInfoDatabuf;
452382

453383
Assert(UsedShmemSegAddr!=NULL);
454384
Assert(IsUnderPostmaster);
455385

456-
/* Ensure buf is big enough that it won't grow mid-operation */
457-
initStringInfo(&buf);
458-
enlargeStringInfo(&buf,128*1024);
459-
/* ... and let's just be sure all that space is committed */
460-
memset(buf.data,0,buf.maxlen);
461-
462-
/* Test: see if this lets the process address space quiesce */
463-
pg_usleep(1000000L);
464-
465-
dumpmem(&buf,"before VirtualFree");
466-
467386
/*
468387
* Release memory region reservation that was made by the postmaster
469388
*/
470389
if (VirtualFree(UsedShmemSegAddr,0,MEM_RELEASE)==0)
471390
elog(FATAL,"failed to release reserved memory region (addr=%p): error code %lu",
472391
UsedShmemSegAddr,GetLastError());
473392

474-
dumpmem(&buf,"after VirtualFree");
475-
476393
hdr= (PGShmemHeader*)MapViewOfFileEx(UsedShmemSegID,FILE_MAP_READ |FILE_MAP_WRITE,0,0,0,UsedShmemSegAddr);
477394
if (!hdr)
478-
{
479-
DWORDmaperr=GetLastError();
480-
481-
dumpmem(&buf,"after failed MapViewOfFileEx");
482-
elog(LOG,"%s",buf.data);
483-
484395
elog(FATAL,"could not reattach to shared memory (key=%p, addr=%p): error code %lu",
485-
UsedShmemSegID,UsedShmemSegAddr,maperr);
486-
}
487-
488-
dumpmem(&buf,"after MapViewOfFileEx");
489-
elog(LOG,"%s",buf.data);
490-
396+
UsedShmemSegID,UsedShmemSegAddr,GetLastError());
491397
if (hdr!=origUsedShmemSegAddr)
492398
elog(FATAL,"reattaching to shared memory returned unexpected address (got %p, expected %p)",
493399
hdr,origUsedShmemSegAddr);
494400
if (hdr->magic!=PGShmemMagic)
495401
elog(FATAL,"reattaching to shared memory returned non-PostgreSQL memory");
496402
dsm_set_control_handle(hdr->dsm_control);
497403

498-
pfree(buf.data);
499-
500404
UsedShmemSegAddr=hdr;/* probably redundant */
501405
}
502406

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp