anusharanganathan / data2paper

Rails helper application to submit data papers from repositories to publishers
7 stars 1 forks source link

Puma & Sqlite3 - ActiveRecord::ConnectionTimeoutError #25

Open anusharanganathan opened 6 years ago

anusharanganathan commented 6 years ago

could not obtain a connection from the pool within 5.000 seconds (waited 5.000 seconds); all pooled connections were in use

This error appears on startup. Started in the new year.

puma-activerecorderror.pdf

anusharanganathan commented 6 years ago

To bypass this error, I have stopped using puma for development. commit acf7751f2068a9bf0ea8417f073c816a66a278e2

  1. Stop puma

    sudo systemctl stop puma.socket
  2. Modify Gemfile to use puma only for production

    group :production do
      # Use Puma as the app server
      gem 'puma', '~> 3.7'
    end
  3. Bundle install only development gems

    bundle install --without production

    Reference: https://stackoverflow.com/questions/36647206/prevent-puma-from-running-in-locally-ruby-on-rails

  4. Run rails server in screen

    cd ~/data2paper
    screen -r
    bundle exec rails s -b 127.0.0.1
  5. Create a new site data2paper-3000 in nginx and use that instead of the current data2paper site

    sudo rm /etc/nginx/sites-enabled/data2paper
    sudo cp docs/data2paper-3000 sudo cp /etc/nginx/sites-available/data2paper /etc/nginx/sites-available/
    sudo ln -s /etc/nginx/sites-available/data2paper-3000 /etc/nginx/sites-enabled/data2paper-3000
    sudo systemctl restart nginx
anusharanganathan commented 6 years ago

I get the same error with postgres too 🙍

martyn-w commented 6 years ago

My suspicion is that this is some artefact of a single-threaded process (such as SQLite), or possibly a database pool configuration issue. I have not observed this error when running Puma and Postgres in the dockerised branch (refactor)