bdurand / seamless_database_pool

Add support for master/slave database clusters in ActiveRecord to improve performance.
http://rdoc.info/projects/bdurand/seamless_database_pool
MIT License
224 stars 58 forks source link

Failover not working with 1 master and 1 slave #4

Closed thoughtshop closed 12 years ago

thoughtshop commented 12 years ago

I was hoping to use seamless_database_pool for a system with one master and one slave, and have all read requests go to the master if the slave goes down. Is that how the failover system works? Or does the failover feature require at least 2 slaves in the read_pool?

bdurand commented 12 years ago

It should work fine in your setup. Note that by default the master is included in the slave pool. If you don't want it in the slave pool you need to give it a pool weight of zero.

On Apr 25, 2012, at 6:54 PM, Trevor Johnston wrote:

I was hoping to use seamless_database_pool for a system with one master and one slave, and have all read requests go to the master if the slave goes down. Is that how the failover system works? Or does the failover feature require at least 2 slaves in the read_pool?


Reply to this email directly or view it on GitHub: https://github.com/bdurand/seamless_database_pool/issues/4

thoughtshop commented 12 years ago

Thanks for the reply. This error occurs if I stop mysql on the slave: NameError (uninitialized constant ActiveRecord::ConnectionAdapters::SeamlessDatabasePoolAdapter::Mysql):

My database config is as follows:

production:
  adapter: seamless_database_pool
  database: p
  username: u
  password: pass
  pool_adapter: mysql2
  port: 3306
  master:
    host: master_ip
    pool_weight: 1
  read_pool:
    - host: slave_ip
      pool_weight: 1

If I change the slave pool_weight to 2, the error is only thrown on every 2nd request.

thoughtshop commented 12 years ago

My apologies. I didn't realize I was using a forked version of SDP. All is well with your version.

suryapandian commented 9 years ago

pool weight 0- means only write.. pool weight 2- means read and write pool weight 1- does it mean only read??? and I found this on stack overflow: http://stackoverflow.com/questions/27269110/rails-db-replica-always-reading-from-master-db

I too have the same issue, all of my requests are going to the slave itself.. Any idea how to make it work right???