makara icon indicating copy to clipboard operation
makara copied to clipboard

Makara on heroku

Open arjan0307 opened this issue 9 years ago • 10 comments

Recently I successfully created a Makara master-slave configuration that works on Heroku. This was not trivial, because of the way Heroku deals with DATABASE_URLS and database.yml files. Apart from that I found a lot of others who were dealing with the same issue, but without a solution.

Therefore I want to write a guide on how to set-up Makara on Heroku. Do you have any suggestions as to where this guide should live (WIKI, somewhere in the Readme)? I suppose I could just write a blog post about it, but it's probably more useful if all documentation regarding this gem lives somewhat on the same spot.

Please let me know whether you think such a guide should exist and where it should live.

arjan0307 avatar Feb 13 '17 16:02 arjan0307

Seems like any guide in any place (even on this issue) would help bring exposure when searching.

(I ended up here from a google search "makara on heroku")

netuoso avatar Mar 09 '17 16:03 netuoso

I think a wiki page would be great, I find it more readable than a Readme. Besides, I'm really interested in that kind of configuration (I'm trying to do it right now). Please let me know if you made it. :-)

francois-tilkee avatar Apr 12 '17 10:04 francois-tilkee

I had the same problem, and my solution was in the readme. Important: Do NOT use ENV['DATABASE_URL'], as it inteferes with the the database configuration initialization and may cause Makara not to complete the configuration. For the moment, it is easier to use a different ENV variable than to hook into the database initialization in all the supported Rails. I rename my DATABASE_URL in DATABASE_MASTER_URL, and I use DATABASE_MASTER_URL in the database.yml file. Enjoy

jo-tilkee avatar May 03 '17 15:05 jo-tilkee

@arjan0307 I'm looking forward to read your guide, I'm having trouble to run makara on heroku (not mentioning migrations without a DATABASE_URL environment variable...)

francois-tilkee avatar May 04 '17 09:05 francois-tilkee

@francois-tilkee I created a gist with an example of a database.yml and .profile file that I used to get it to work.

https://gist.github.com/arjan0307/e1a2a810604b5ba8fdf49782f60e5363

You can specify a different URL than DATABASE_URL on heroku, as you can see in the gist.

You may need to recreate your databases on Heroku so that they have the correct urls (MASTER_URL and SLAVE_URL). You can do this by running: heroku addons:create heroku-postgresql:<PLANNAME> --as MASTER

arjan0307 avatar May 04 '17 09:05 arjan0307

Thanks for sharing !

francois-tilkee avatar May 04 '17 12:05 francois-tilkee

Hi @arjan0307 --- will you add a new heroku.md file and a link from the readme with what you guys are finding successful in that environment?

bleonard avatar May 04 '17 16:05 bleonard

I'm also getting stuck here. Heroku seems to be overwritting the adapter I've chosen. It's using postgresql instead of postgresql_makara.

@arjan0307 does your workaround take care of that?

Edit: I was able to solve it using the configuration suggested here: https://github.com/ankane/distribute_reads#how-to-use.

jwg2s avatar Jun 06 '17 05:06 jwg2s

Have anyone successfully set up makara with PG Bouncher buildpack on heroku? I can only get pgbouncher to work on my read slaves, and not the master, as I run into these errors. [Makara] No connections are available in the master pool

henrikholm89 avatar Sep 21 '17 09:09 henrikholm89

@henrikholm89 did you solve that one?

I'm encountering same issue without pgbouncer. I just get 500's when doing POSTS and I got the same error.

GMorisot avatar Jul 07 '23 18:07 GMorisot