Re: shared memory after server kill - Mailing list pgsql-novice

From Oliver Fromme
Subject Re: shared memory after server kill
Date
Msg-id 200408051106.i75B69lO088473@lurza.secnetix.de
Whole thread Raw
In response to shared memory after server kill  (Sean Davis <sdavis2@mail.nih.gov>)
Responses Re: shared memory after server kill
List pgsql-novice
Sean Davis wrote:
 > I am using macosx, pg 7.4.3.  I had a server running and working.  I
 > tried to bring the server down with 'pg_ctl stop', which failed (server
 > running on localhost).  I then (timidly) killed the postmaster process.
 >
 > When I tried to bring the server back up, I got an error similar to:
 >
 >   FATAL:  could not create shared memory segment: Cannot allocate memory
 > DETAIL:  Failed system call was shmget(key=1, size=1081344, 03600).
 > [...]
 > I have 4 Gb of memory, with approximately 2.6 Gb available (via top)
 > and a vast swap.  What is going on?

When you kill the postmaster process forcibly, it doesn't
release the shared memory segments that it had allocated.

Use the "ipcs" command to list all currently allocated
shared memory segments, and use "ipcrm" to remove them.
I've once written a small shell script which basically
does it (I've only tested it on FreeBSD, but Mac OS X
should be similar enough):

#!/bin/sh -
ipcs | awk '($1=="m"){print $2}' | xargs -n 1 -t ipcrm -m

Of course, you can also solve the problem the Windows way
(i.e. reboot).  ;-)

Best regards
   Oliver

--
Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

With Perl you can manipulate text, interact with programs, talk over
networks, drive Web pages, perform arbitrary precision arithmetic,
and write programs that look like Snoopy swearing.

pgsql-novice by date:

Previous
From: Sean Davis
Date:
Subject: Re: shared memory after server kill
Next
From: Tom Lane
Date:
Subject: Re: shared memory after server kill