Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restarting postgres

Tags:

postgresql

Is there any danger running /etc/init.d/postgresql restart?? We just had an incident where some relations "disappeared" and I ran the said command. Just got bollocked by the sysadmin, however he did not justify why this was a bad thing to do. I did put the webapp in maintenance mode so there wasn't any transactions/ queries going on at the time.


Thanks guys... So in short it wont damage anything but it could loose lots of valuable diagnostic info.

like image 828
Simon Avatar asked Sep 01 '10 17:09

Simon


People also ask

Is it safe to restart postgres?

No, there is no danger of restarting postgres using the init.


2 Answers

No, there is no danger of restarting postgres using the init.d method.

However, to restart it because something weird happened is not a good idea, because it limits severely the amount of information you can collect to find the root cause and limits opportunities to fix it.

Also in all the years I have been involved with postgresql, I never encountered a situation in which a restart "fixed" the problem. The immediate 'incident' might be resolved but if there's a problem, it will still be there.

like image 73
Peter Tillemans Avatar answered Sep 17 '22 17:09

Peter Tillemans


The only way relations would disappear on a restart of Postgres, would be if they were temp tables or created relations within an open transaction. When the db restarts it would close all connections and thus all temp tables would be dropped and open transactions would be rolled back. But anything that was committed would be safe from a restart.

like image 37
localfilmmaker Avatar answered Sep 20 '22 17:09

localfilmmaker