Skip to content

Instantly share code, notes, and snippets.

@rduplain

rduplain/gist:4946399

Last active Dec 13, 2015
Embed
What would you like to do?
Prevent stop/restart of postgresql on Debian/Ubuntu. Do so carefully while watching updates, and restart manually.
#!/bin/sh
# /usr/sbin/policy-rc.d
# Do not stop/restart postgresql. --rduplain 2013-02-13
# http://askubuntu.com/a/254307/113086
if [ "$1" = "postgresql" ]; then
# Forbid stop/restart, or any init action for that matter.
# 101 - action forbidden by policy
exit 101
fi
@polobo

This comment has been minimized.

Copy link

@polobo polobo commented Feb 18, 2015

So what happens if you forget to remove policy-rc.d and the server reboots? Does the PostgreSQL fail to come back up?

Is there any issue (does it happen and does it matter) if the upgrade replaces files underneath a running server.

Why doesn't the upgrade routine handle this itself already?

@webervin

This comment has been minimized.

Copy link

@webervin webervin commented May 1, 2015

@polobo:
for first part of your question: there is second argument "action", you can add second check, so 101 is returned only for "stop" and "restart", while "start" and "reload" will continue to work, so you can keep policy on server forever.

Second and third questions are more tricky:
http://www.postgresql.org/docs/devel/static/upgrading.html states: To update between compatible versions, you simply replace the executables while the server is down and restart the server. The data directory remains unchanged — minor upgrades are that simple.

so currently upgrade routine follows documentation (keeping data safe). Maybe in future, there will be "better" upgrade procedure, doing something similar to nginx (http://nginx.org/en/docs/control.html#upgrade), which probably will be issue with memory / resident set / caches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.