`pg_tblspc` missing after installation of latest version of OS X (Yosemite or El Capitan)
Solved... in part.
Apparently, Installing the latest versions of OS X (e.g. Yosemite or El Capitan) removes some directories in /usr/local/var/postgres
.
To fix this you simply recreate the missing directories:
mkdir -p /usr/local/var/postgres/pg_commit_ts
mkdir -p /usr/local/var/postgres/pg_dynshmem
mkdir -p /usr/local/var/postgres/pg_logical/mappings
mkdir -p /usr/local/var/postgres/pg_logical/snapshots
mkdir -p /usr/local/var/postgres/pg_replslot
mkdir -p /usr/local/var/postgres/pg_serial
mkdir -p /usr/local/var/postgres/pg_snapshots
mkdir -p /usr/local/var/postgres/pg_stat
mkdir -p /usr/local/var/postgres/pg_stat_tmp
mkdir -p /usr/local/var/postgres/pg_tblspc
mkdir -p /usr/local/var/postgres/pg_twophase
Or, more concisely (thanks to Nate):
mkdir -p /usr/local/var/postgres/{{pg_commit_ts,pg_dynshmem,pg_replslot,pg_serial,pg_snapshots,pg_stat,pg_stat_tmp,pg_tblspc,pg_twophase},pg_logical/{mappings,snapshots}}
Rerunning pg_ctl start -D /usr/local/var/postgres
now starts the server normally and, at least for me, without any data loss.
UPDATE
On my system, some of those directories are empty even when Postgres is running. Maybe, as part of some "cleaning" operation, Yosemite removes any empty directories? In any case, I went ahead and created a '.keep' file in each directory to prevent future deletion.
touch /usr/local/var/postgres/{{pg_commit_ts,pg_dynshmem,pg_replslot,pg_serial,pg_snapshots,pg_stat,pg_stat_tmp,pg_tblspc,pg_twophase},pg_logical/{mappings,snapshots}}/.keep
Note: Creating the .keep
file in those directories will create some noise in your logfile, but doesn't appear to negatively affect anything else.
Donavan's answer is spot on, I just wanted to add that as i did different things with the database (e.g. rake db:test
), it went looking for different directories that haven't been mentioned above and would choke when they weren't present, in my case pg_logical/mappings
, so you may want to setup a terminal running:
tail -f /usr/local/var/postgres/server.log
and watch it for missing folders while you go thru your typical database activities.
This is slightly off-topic but worth noting here as part of the PostgreSQL Yosemite recovery process. I had the same issue as above AND I had an issue with PostgreSQL "seemingly" running in the background so even after adding directories I couldn't restart. I tried using pg_ctl stop -m fast
to kill the PostgreSQL server but no luck. I also tried going after the process directly with kill PID
but as soon as I did that a PostgreSQL process re-appeared with a different PID.
The key ended up being a .plist
file that Homebrew had loaded... The fix for me ended up being:
launchctl unload /Users/me/Library/LaunchAgents/homebrew.mxcl.postgresql92.plist
After that I was able to start PostgreSQL normally.