Multi-PostgreSQL based on http header value - Ruby on Rails

Discussion in 'Ruby' started by maiden71, Jun 15, 2015.

  1. maiden71


    Jun 15, 2015
    Likes Received:
    Hi everybody !

    We are currenlty working on a project with multiple openstreetmap postgresql databases installed and one api instance, i added a X-Venue header for requests to route to a specified correctly installed database.

    I've updated ApplicationController to connect to the specified database, it works but when i connect to a non existing database, it returns database not found even if the database is correct on future calls

    Here is the code :

    I'm not sure how rails works with pgsql, when the first connection occurs, and if establish_connection() is the good way, it seems that some connection polling somewhere keeps latest bad connection.

    If i restart the server (bundle exec rails server) it works again
    Is it because Rails doesn't close connections by default ?

    Any help on that ?

    (original issue was posted on openstreetmap/openstreetmap-website#980 but it's a rails issue in fact)
    maiden71, Jun 15, 2015
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.