Postgresql wont restart. Can I clear shared memmory segments without rebooting?
Hi
I have a remote server running debian etch,
that has only 1G of ram, (that i cannot easily add ram to), that runs
a large postgresql 7.4 database and it occasionally runs out of enough shared memory. The database is static
and I no longer add data to it. The machine sits on the network and is just for serving up data.
When it runs out of memory, the postgresl database shuts down and the postgresql server will not restart.
I get a message about not enough shared memory when I try to restart postgresql.
While this is happening, when I ran top I saw that the swap space was utilized extensively while the was
some free regular memory (i dont have the output to show).
However i did run and saved the output of the program
vmstat and got this data
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 0 1951552 208876 28340 42528 14 11 13 11 10 13 2 1 59 39
Now ordinarily when I run the server, (the postgresql crashing happens about once every 3 or 4 weeks)
and I typically reboot the machine and all is fine.
In ordinary use there is no problem, I typically have the following output from top.
Now what I usually do is simply reboot the machine and everything is fine.
While I can continue to do this, but it goes against the grain. Is there some system command to free the
shared memory so that postgresql will start again without rebooting?
The only significant application that runs on the machine is essentially this postgresql database...
Rebooting is so 'windows(c)'...
Mitchell
--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
01-05-2010, 07:39 AM
Stan Hoeppner
Postgresql wont restart. Can I clear shared memmory segments without rebooting?
Mitchell Laks put forth on 1/5/2010 1:34 AM:
> While I can continue to do this, but it goes against the grain. Is there some system command to free the
> shared memory so that postgresql will start again without rebooting?
Try these:
To free pagecache:
# echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
# echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches
--
Stan
--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
01-05-2010, 02:36 PM
"Boyd Stephen Smith Jr."
Postgresql wont restart. Can I clear shared memmory segments without rebooting?
In <20100105073412.GA5626@earthlink.net>, Mitchell Laks wrote:
>I have a remote server running debian etch,
>that has only 1G of ram, (that i cannot easily add ram to), that runs
>a large postgresql 7.4 database and it occasionally runs out of enough
> shared memory. The database is static and I no longer add data to it. The
> machine sits on the network and is just for serving up data.
>
>When it runs out of memory, the postgresl database shuts down and the
> postgresql server will not restart. I get a message about not enough shared
> memory when I try to restart postgresql.
>
>Now what I usually do is simply reboot the machine and everything is fine.
>
>While I can continue to do this, but it goes against the grain. Is there
> some system command to free the shared memory so that postgresql will
> start again without rebooting?
These commands should help:
ipcmk (1) - create various ipc resources
ipcrm (1) - remove a message queue, semaphore set or shared memory id
ipcs (1) - provide information on ipc facilities
They are from the util-linux package.
--
Boyd Stephen Smith Jr. ,= ,-_-. =.
bss@iguanasuicide.net ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/ \_/
01-06-2010, 06:27 AM
Mitchell Laks
Postgresql wont restart. Can I clear shared memmory segments without rebooting?
On 02:39 Tue 05 Jan , Stan Hoeppner wrote:
> Try these:
>
> To free pagecache:
>
> # echo 1 > /proc/sys/vm/drop_caches
>
> To free dentries and inodes:
>
> # echo 2 > /proc/sys/vm/drop_caches
>
> To free pagecache, dentries and inodes:
>
> echo 3 > /proc/sys/vm/drop_caches
this was very helpful. Exactly what I was looking for. I was able to read more about this
and hopefully next time it happens, I will understand how to proceed.
I was able to look this info about pagecache and shared memory up and learn about it!
Thank you very much!
Mitchell
--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
01-06-2010, 06:30 AM
Kun Niu
Postgresql wont restart. Can I clear shared memmory segments without rebooting?
Before you execute "echo 3 > /proc/sys/vm/drop_caches", you'd better run
"sync" first.
Mitchell Laks write:
On 02:39 Tue 05 Jan , Stan Hoeppner wrote:
Try these:
To free pagecache:
# echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
# echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches
this was very helpful. Exactly what I was looking for. I was able to read more about this
and hopefully next time it happens, I will understand how to proceed.
I was able to look this info about pagecache and shared memory up and learn about it!
Thank you very much!
Mitchell
--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
01-06-2010, 06:31 AM
Mitchell Laks
Postgresql wont restart. Can I clear shared memmory segments without rebooting?
On 09:36 Tue 05 Jan , Boyd Stephen Smith Jr. wrote:
>
> These commands should help:
> ipcmk (1) - create various ipc resources
> ipcrm (1) - remove a message queue, semaphore set or shared memory id
> ipcs (1) - provide information on ipc facilities
>
> They are from the util-linux package.
Dear Stephen,
Your help and that of Stan Hoeppner were amazing! I was able to look it all up in google
once I used your ipcs and ipcrm in my search. The best sites included
http://markmail.org/search/?q=postgresql+ipcrm
which gave lots of hits that gave information on why postgresql wasnt starting again and
how to proceed.
You guys are amazing!!!
Thanks again!
Mitchell
--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
01-06-2010, 06:45 AM
Mitchell Laks
Postgresql wont restart. Can I clear shared memmory segments without rebooting?
On 15:30 Wed 06 Jan , Kun Niu wrote:
> Before you execute "echo 3 > /proc/sys/vm/drop_caches", you'd better
> run "sync" first.
Thank you, a good point.
I was mostly interested as a matter of knowledge, as I did not go into linux to
become a 'cargo culter' and reboot without knowing what it did. Rebooting will close
everything safely as well as free the unfreed shared memory segments.
I wanted to know for knowledge sake... !
On the other hand,
ipcs
look for postgresql owned shared memory
and
ipcrm -s <ID> of those
would seem to be ok as long as no postgresql process is goind on in the background.
After reading about the different ways of doing this, which include rebooting, at the
postgresql mailing list, I would likely proceed in order of choice
1. reboot
or else if I am feeling really bold and adventurous, and have everything backed up nicely,
2. ipcs, then ipcrm -s <ID>
Thank you again!
Mitchell Laks
--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
01-06-2010, 12:09 PM
Stan Hoeppner
Postgresql wont restart. Can I clear shared memmory segments without rebooting?
Mitchell Laks put forth on 1/6/2010 1:27 AM:
> On 02:39 Tue 05 Jan , Stan Hoeppner wrote:
>> Try these:
>>
>> To free pagecache:
>>
>> # echo 1 > /proc/sys/vm/drop_caches
>>
>> To free dentries and inodes:
>>
>> # echo 2 > /proc/sys/vm/drop_caches
>>
>> To free pagecache, dentries and inodes:
>>
>> echo 3 > /proc/sys/vm/drop_caches
>
> this was very helpful. Exactly what I was looking for. I was able to read more about this
> and hopefully next time it happens, I will understand how to proceed.
> I was able to look this info about pagecache and shared memory up and learn about it!
You're welcome. The big question though is why this is happening in the first
place. Your top output showed 750MB+ in the cache on a system with 1GB ram.
That's 3/4 of your system memory occupied by cached disk file pages, which is
quite normal for Linux. At the time postgre could have had at most 250MB
allocated to it.
When postgre asks the kernel for more memory, the kernel should automatically
flush some pages out of the cache and reallocate those memory pages to satisfy
postgre's request for more memory. You should _never_ have to do this manually
with those hacks I provided. The Linux kernel should always do this automatically.
I fear something is quite wrong with your system, either with your kernel or
with postgre.
--
Stan
--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
01-06-2010, 07:12 PM
Tony Nelson
Postgresql wont restart. Can I clear shared memmory segments without rebooting?
On 10-01-06 08:09:00, Stan Hoeppner wrote:
...
> ... The big question though is why this is happening in the first
> place. Your top output showed 750MB+ in the cache on a system with
> 1GB ram. That's 3/4 of your system memory occupied by cached disk
> file pages, which is quite normal for Linux. At the time postgre
> could have had at most 250MB allocated to it.
He stated that his system is running out of shared memory. It's
probably using up all the segments. See Boyd's reply.
...
> I fear something is quite wrong with your system, either with your
> kernel or with postgre.
It's probably postgresql leaking segments for some reason, either a bug
or a config / usage problem.