Postgresql – do to monitor “out of shared memory” issues

pgadminpostgresqlrails

I'm new to database administration and I would really like some advice on what tools I could use or what I could do to monitor "out of shared memory" issues.

I've been seeing these "out of shared memory" messages when I've been running rspec which runs tests for my application. I've also seen messages in the browser when I run my rails app that I "might need to increase max_locks_per_transaction."

I think it would be better to find out exactly what is going on first either on the driver level or the PostgreSQL level.

My specs are:

PostgreSQL 9.4.5 on x86_64-apple-darwin15.0.0, compiled by Apple LLVM version 7.0.0 (clang-700.1.76), 64-bit

I have a Macbook Pro running OSX El Capitan 10.11.5

I'm using the gem pg version 0.18.4 in my Ruby-on-Rails application.

Best Answer

To monitor postgres logs you can navigate to cd "/usr/local/var/postgres" where you will find the server.log file.

If you want to watch the log in action you can pass the following command into the terminal tail -f server.log

Run your application in the background and if there is an issue occurring in postgres the server.log will catch it.

In my case, I ran RSpec in the background as that's where I saw the original "out of shared memory" message occur. The postgres log picked it up when it happen.