Postgres Quitting on my Server
doug at artsman.com
Wed Jan 11 14:32:17 UTC 2023
it sounds like you are trying to deal with, delete old versions of postgres. if thats the case..
in /Library/LaunchDaemons are a bunch of plists that are typically used for starting services under launchctl
the psotgres ones I’ve seen have two variants starting at version 13 of postgres where EDB removed ‘com.edb.launchd’ from the front of the plist and now simply name them like postgresql-13.plist
My current installer is postges 14, so I have this in my packages startup install script to look to do a pre-emptive unload of the service from launchd. its like killing something out of cron — except, apple no longer uses cron.
after I’ve made sure the Daemon is unloaded for the versions I don’t want, I delete the plist so that it cannot be loaded to start again.
# shut down postgres if we can and wait for complete. Unloading the plist seems to do it
sudo launchctl unload /Library/LaunchDaemons/com.edb.launchd.postgresql-9.plist
sudo launchctl unload /Library/LaunchDaemons/com.edb.launchd.postgresql-10.plist
sudo launchctl unload /Library/LaunchDaemons/com.edb.launchd.postgresql-11.plist
sudo launchctl unload /Library/LaunchDaemons/com.edb.launchd.postgresql-12.plist
sudo launchctl unload /Library/LaunchDaemons/postgresql-13.plist
sudo launchctl unload /Library/LaunchDaemons/postgresql-14.plist
# remove old versions of plists - since they are unloaded and installer will not install if /bin directories for older versions exist
sudo rm -f /Library/LaunchDaemons/com.edb.launchd.postgresql-9.plist
sudo rm -f /Library/LaunchDaemons/com.edb.launchd.postgresql-10.plist
sudo rm -f /Library/LaunchDaemons/com.edb.launchd.postgresql-11.plist
sudo rm -f /Library/LaunchDaemons/com.edb.launchd.postgresql-12.plist
sudo rm -f /Library/LaunchDaemons/postgresql-13.plist
Finally, go into /Library/Postgres and look for the versions you have.
ideally, you should only have one version (unless you really want to support multiple versions running at the same time, which, by the way, is completely fine as long as you listen on a different port for each version)
if you only intend on using postgres 13, then delete the other folders in that directory
sudo rm -rf 12 (for postgres 12 as an example)
or, if you don’t care and want to go to postgres 15 with a fresh install, which is probably a good idea since I can’t realistically see what you have in your machine setup…. Then
1) use pg_dump to save the databases in your version 13 database server when you can get to it.
2) use launchctl to unload all version of postgres up to 14
3) delete all postgres plists out of /Library/LaunchDaemons per the naming conventions I mention at the top
4) delete all folders out of the /Library/PostgreSQL folder
5) install the version of postgres you want to install and configure it.
6) pg_restore up any databases you want to restore.
again, I can’t tell from your description what your world looks like or the trail of how you got it to be where you are currently sitting. Your statements indicate that you may have (or had) multiple versions.
removing everything in the right manner and starting over is probably the safest bet.
you can look in system logs to find out if launchd is trying to start old version or non existant version of software — since you’ll see messages to that effect.
Arts Management Systems Ltd.
mailto:doug at artsman.com
Phone (403) 650-1978
> On Jan 10, 2023, at 12:08 PM, Das Goravani <goravanis at gmail.com> wrote:
> I have a Mac server, Catalina, Postgres 13x
> This installation of Postgres is somehow quitting after a couple hours of running fine.
> It is half-launched after it quits, it is disabled.
> When it is in this quit state, I have a few times issued the command to Run again. But it says it IS running. Yet it is non responsive to connections. It is as if it quit. I then issue the command to quit postgres, and it quits fully. Then I can relaunch it successfully.
> So it gets disabled after a couple of hours. Exactly equal to as if it quit.
> This has been sitting on my server this way for months. I posted about this before but didn’t make progress.
> I feel now that I should perhaps install the latest upgrade, mainly to reinstall in hopes it then doesn’t "quit".
> Do you have any input on the problem?
> If not, do you have any advice about how to upgrade Postgres?
> I saw before on here that Doug talked about how to upgrade Postgres so I thought it may have some quirks. In fact I don’t know how to make it "go" to the right version after installation of update. I think that is the issue.
> I plan on using the EDB installers I think they’re called.
> Can you tell me how to look at tasks that are planned on the Mac Server? Where are regular tasks located? I mean by this where it might be recorded that Postgres should quit after a certain amount of time. I figure there might be such a thing, accessible through Terminal.. like "Cron Jobs" similar. Any ideas on places that might have something recorded there that is affecting Postgres?
> Perhaps a hacker or virus put in a command that disables Postgres after some time.
> I know that normally Postgres stays running just fine, very reliable. This is true on my other Linux server. In fact I can’t find any support for this on the web, which is a testament to how well Postgres continues to run on a normal basis.
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
More information about the omnisdev-en