pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: Tomasz Szypowski <tomasz.szypowski@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@postgresql.org>
Subject: Re: could not fork autovacuum worker process: No error
Date: Mon, 3 Apr 2017 02:51:06 -0400
Message-ID: <20170403065106.GA2624300@tornado.leadboat.com> (raw)
In-Reply-To: <20170402220856.GA2601785@tornado.leadboat.com>
References: <CACmJi2JyDLMtxE3i_Krp=hrK4KKZ=D83s6eMw9q=HeM_srQdXg@mail.gmail.com>
	<9889.1485358425@sss.pgh.pa.us>
	<CACmJi2JvKUYy1EFSgfmmbik3uSt3XFJnyvzrh=u-Df_PtC9NUQ@mail.gmail.com>
	<14121.1485360296@sss.pgh.pa.us>
	<CACmJi2J6sF4p7g-nxa8SGN14vdtMiDwUZa7iThWBWKKs5SEtFw@mail.gmail.com>
	<20170401024138.GA2521221@tornado.leadboat.com>
	<CAB7nPqSY4qKi8YX1Yk3S8LLMn5WBijXCBgfv2VbC_H-dGfjO2g@mail.gmail.com>
	<27928.1491148737@sss.pgh.pa.us>
	<CACmJi2Kz-R2bG5GU_+Cb3NhNwN+9-bH_5fW+px4HXMF7+4sLJA@mail.gmail.com>
	<20170402220856.GA2601785@tornado.leadboat.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On Sun, Apr 02, 2017 at 06:08:56PM -0400, Noah Misch wrote:
> On Sun, Apr 02, 2017 at 07:51:59PM +0200, Tomasz Szypowski wrote:
> > I build PostgreSQL 32 bit on Windows with Microsoft Visual Studio 8.
> 
> That version number is ambiguous.  From the command prompt in which you build
> PostgreSQL, what is the output of these two commands?
> 
>   cl
>   systeminfo | findstr /B OS
> 
> If you build PostgreSQL on one system and run it on a different system, what
> is the output of "systeminfo | findstr /B OS" on the runtime system?

Also, could you run a test workload that reproduces the problem against a
postgres.exe built with the attached patch?  This will dump details of your
memory postgres.exe memory map to the log, hopefully giving a clue about the
source of the trouble.

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments:

w32-memory-map-v1.patch (text/plain, 4.1K) download diff --git a/src/backend/Makefile b/src/backend/Makefile index 7a0bbb2..498bdc9 100644 --- a/src/backend/Makefile +++ b/src/backend/Makefile @@ -80,7 +80,7 @@ libpostgres.a: postgres ; endif # cygwin ifeq ($(PORTNAME), win32) -LIBS += -lsecur32 +LIBS += -lsecur32 -lpsapi postgres: $(OBJS) $(WIN32RES) $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) -Wl,--stack=$(WIN32_STACK_RLIMIT) -Wl,--export-all-symbols -Wl,--out-implib=libpostgres.a $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LIBS) -o $@$(X) diff --git a/src/backend/port/win32_shmem.c b/src/backend/port/win32_shmem.c index 31489fc..1e35278 100644 --- a/src/backend/port/win32_shmem.c +++ b/src/backend/port/win32_shmem.c @@ -17,12 +17,85 @@ #include "storage/ipc.h" #include "storage/pg_shmem.h" +#include <psapi.h> + HANDLE UsedShmemSegID = INVALID_HANDLE_VALUE; void *UsedShmemSegAddr = NULL; static Size UsedShmemSegSize = 0; static void pgwin32_SharedMemoryDelete(int status, Datum shmId); +static void +dumpdlls(HANDLE *proc) +{ + HMODULE dll[512]; + DWORD size_used = 1; + int i; + + if (!EnumProcessModules(proc, dll, sizeof(dll), &size_used)) + { + elog(LOG, "EnumProcessModules failed: %lu", GetLastError()); + return; + } + if (size_used == 0) + elog(LOG, "EnumProcessModules: no modules"); + + for (i = 0; i < size_used / sizeof(*dll); i++) + { + char name[MAXPGPATH]; + + if (!GetModuleFileNameEx(proc, dll[i], name, sizeof(name))) + sprintf(name, "GetModuleFileNameEx failed: %lu", GetLastError()); + elog(LOG, "0x%p %s", dll[i], name); + } +} + +static const char * +mi_type(DWORD code) +{ + switch (code) { + case MEM_IMAGE: return "img"; + case MEM_MAPPED: return "map"; + case MEM_PRIVATE: return "prv"; + } + return "???"; +} + +static const char * +mi_state(DWORD code) +{ + switch (code) { + case MEM_COMMIT: return "commit"; + case MEM_FREE: return "free "; + case MEM_RESERVE: return "reserv"; + } + return "???"; +} + +static void +dumpmem(const char *reason, HANDLE *proc) +{ + char *addr = 0; + MEMORY_BASIC_INFORMATION mi; + + elog(LOG, "%s memory map", reason); + do { + if (0 == VirtualQueryEx(proc, addr, &mi, sizeof(mi))) + { + if (GetLastError() == ERROR_INVALID_PARAMETER) + break; + elog(LOG, "VirtualQueryEx failed: %lu", GetLastError()); + return; + } + elog(LOG, "0x%p+0x%p %s (alloc 0x%p) %s", + mi.BaseAddress, (void *) mi.RegionSize, + mi_type(mi.Type), mi.AllocationBase, mi_state(mi.State)); + addr += mi.RegionSize; + } while (addr > 0); + + dumpdlls(proc); +} + /* * Generate shared memory segment name. Expand the data directory, to generate * an identifier unique for this data directory. Then replace all backslashes @@ -276,6 +349,8 @@ PGSharedMemoryReAttach(void) Assert(UsedShmemSegAddr != NULL); Assert(IsUnderPostmaster); + dumpmem("before reattach", GetCurrentProcess()); + /* * Release memory region reservation that was made by the postmaster */ @@ -408,6 +483,7 @@ pgwin32_ReserveSharedMemoryRegion(HANDLE hChild) address = VirtualAllocEx(hChild, UsedShmemSegAddr, UsedShmemSegSize, MEM_RESERVE, PAGE_READWRITE); + dumpmem("after reserve", hChild); if (address == NULL) { /* Don't use FATAL since we're running in the postmaster */ diff --git a/src/makefiles/Makefile.win32 b/src/makefiles/Makefile.win32 index 7abbd01..678371d 100644 --- a/src/makefiles/Makefile.win32 +++ b/src/makefiles/Makefile.win32 @@ -1,5 +1,7 @@ # src/makefiles/Makefile.win32 +override CPPFLAGS+= -DPSAPI_VERSION=1 + ifdef PGXS BE_DLLLIBS= -L$(libdir) -lpostgres override CPPFLAGS+= -I$(includedir_server)/port/win32 diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 12f73f3..4c39f33 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -172,8 +172,10 @@ sub mkvcbuild 'repl_gram.y', 'syncrep_scanner.l', 'syncrep_gram.y'); $postgres->AddDefine('BUILDING_DLL'); + $postgres->AddDefine('PSAPI_VERSION=1'); $postgres->AddLibrary('secur32.lib'); $postgres->AddLibrary('ws2_32.lib'); + $postgres->AddLibrary('psapi.lib'); $postgres->AddLibrary('wldap32.lib') if ($solution->{options}->{ldap}); $postgres->FullExportDLL('postgres.lib');

view thread (16+ messages)  latest in thread

Message-ID: <20170403065106.GA2624300@tornado.leadboat.com>
Permalink:  ../20170403065106.GA2624300@tornado.leadboat.com/
Also on:    postgresql.org/message-id/20170403065106.GA2624300@tornado.leadboat.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noah@leadboat.com, tomasz.szypowski@gmail.com, tgl@sss.pgh.pa.us, michael.paquier@gmail.com
  Subject: Re: could not fork autovacuum worker process: No error
  In-Reply-To: <20170403065106.GA2624300@tornado.leadboat.com>
  References: <CACmJi2JyDLMtxE3i_Krp=hrK4KKZ=D83s6eMw9q=HeM_srQdXg@mail.gmail.com> <9889.1485358425@sss.pgh.pa.us> <CACmJi2JvKUYy1EFSgfmmbik3uSt3XFJnyvzrh=u-Df_PtC9NUQ@mail.gmail.com> <14121.1485360296@sss.pgh.pa.us> <CACmJi2J6sF4p7g-nxa8SGN14vdtMiDwUZa7iThWBWKKs5SEtFw@mail.gmail.com> <20170401024138.GA2521221@tornado.leadboat.com> <CAB7nPqSY4qKi8YX1Yk3S8LLMn5WBijXCBgfv2VbC_H-dGfjO2g@mail.gmail.com> <27928.1491148737@sss.pgh.pa.us> <CACmJi2Kz-R2bG5GU_+Cb3NhNwN+9-bH_5fW+px4HXMF7+4sLJA@mail.gmail.com> <20170402220856.GA2601785@tornado.leadboat.com> <20170403065106.GA2624300@tornado.leadboat.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox