Code Monkey home page Code Monkey logo

multi_db's People

Contributors

aduffeck avatar kensodev avatar loren avatar lukeludwig avatar mindreframer avatar promisedlandt avatar schoefmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

multi_db's Issues

Any way to do writes on multiple databases?

I have a multi-master setup with MariaDB Galera.

multi_db works great when I'm distributing reads to multiple masters when I just declare them as slaves.

Can multi-db support multiple masters so I can write on multi-master replicated cluster?

Infinite loop in observer_extensions.rb when using observers and Passenger

Just upgraded multi_db and started running into this infinite loop with our Observers when run via Passenger:

SystemStackError (stack level too deep):
multi_db (0.3.1) lib/multi_db/active_record_extensions.rb:48:in connection' multi_db (0.3.1) lib/multi_db/observer_extensions.rb:10:inupdate_without_masterdb'
multi_db (0.3.1) lib/multi_db/observer_extensions.rb:11:in update_without_masterdb' multi_db (0.3.1) lib/multi_db/connection_proxy.rb:123:inwith_master'
multi_db (0.3.1) lib/multi_db/observer_extensions.rb:10:in update_without_masterdb' multi_db (0.3.1) lib/multi_db/observer_extensions.rb:11:inupdate_without_masterdb'
multi_db (0.3.1) lib/multi_db/connection_proxy.rb:123:in with_master' multi_db (0.3.1) lib/multi_db/observer_extensions.rb:10:inupdate_without_masterdb'
multi_db (0.3.1) lib/multi_db/observer_extensions.rb:11:in update_without_masterdb' multi_db (0.3.1) lib/multi_db/connection_proxy.rb:123:inwith_master'
...
lots of this
...
multi_db (0.3.1) lib/multi_db/observer_extensions.rb:11:in update_without_masterdb' multi_db (0.3.1) lib/multi_db/connection_proxy.rb:123:inwith_master'
multi_db (0.3.1) lib/multi_db/observer_extensions.rb:10:in update_without_masterdb' multi_db (0.3.1) lib/multi_db/observer_extensions.rb:11:inupdate_without_masterdb'
multi_db (0.3.1) lib/multi_db/connection_proxy.rb:123:in with_master' multi_db (0.3.1) lib/multi_db/observer_extensions.rb:10:inupdate_without_masterdb'
multi_db (0.3.1) lib/multi_db/observer_extensions.rb:11:in update' multi_db (0.3.1) lib/multi_db/connection_proxy.rb:123:inwith_master'
multi_db (0.3.1) lib/multi_db/observer_extensions.rb:10:in update' activerecord (3.2.6) lib/active_record/observer.rb:114:in_notify_author_observer_for_after_save'
activesupport (3.2.6) lib/active_support/callbacks.rb:405:in _run__1711496803__save__4__callbacks' activesupport (3.2.6) lib/active_support/callbacks.rb:405:insend'

If I take away the Passenger extension (which has been working fine for over a year now) the issue goes away, but then so does multi_db. Possibly relevant is that we're in the process of upgrading Rails from 3.0 to 3.2, so multi_db isn't the only new code in the mix.

Is there something special we need to be taking into account now when using Observers with Passenger?

multi_db with transactions

I've recently installed the multi_db gem on my rails 2.3.10 app in order to use a MySql master/slave replication.

since installing the gem, every time I use transactions in my code , e.g.:

MyModel.connection.transaction do

...some code...

end

I get an exception: NoMethodError undefined method 'assert_valid_keys' for true:TrueClass

any ideas on how to use multi_db with transactions?

Conflict with asf-soap-adapter (SalesForce)

Hello,

I found a conflict between multi_db and asf-soap-adapter which is a gem to use the SalesForce API.
The problem is that asf-soap-adapter use the db.yml file to setup an adapter, like this :

salesforce-default-realm:
adapter: activesalesforce
url: https://www.salesforce.com
username: XXX
password: XXX
api_version: 20.0

Then the usage is like that : Salesforce::Lead.new

But when using multi_db, it seems multi_db try to handle the connection and don't let let asf-soap-adapter do it...
If someone have an idea of how to fix this it would be appreciated.

Regards.

Gemcutter support

Now that gems are no longer built on github, would be nice to see this gem added to gemcutter.org

Has anyone used MultiDb with Ruby 1.9.2?

We've been using MultiDb for a long time with Ruby 1.8.6 and Rails 2.3.2. We're currently upgrading to Rails 2.3.11 and Ruby 1.9.2, and we're seeing some kind of horrible error out of the gem:

ArgumentError (wrong number of arguments (1 for 0)):
/usr/lib/ruby/gems/1.9.1/gems/schoefmax-tlattr_accessors-0.0.3/lib/tlattr_accessors.rb:55:in block in current=' app/models/user_setting.rb:2:inclass:UserSetting'
app/models/user_setting.rb:1:in `<top (required)>'

Has anyone else seen these errors? Or has anyone run successfully with ruby 1.9.2?

multi_db on Heroku

Hi,

I don't know how to make multi_db work with Heroku since Heroku doesn't use database.yml.

Do you have any plan to make it work with Heroku?

Thanks,

ActiveRecord::Base.connection_proxy.with_master do not work

I try use this code below in my controller

around_filter(:only => [:create,:update]) { |c,a| ActiveRecord::Base.connection_proxy.with_master { a.call } }

and receive this error:
NoMethodError (undefined method `conection_proxy' for ActiveRecord::Base:Class):

I need change conection of 2 actions in my controller for read just at master. How I do?

0.3.0 breaks rails 2.3

I think commit 863e29b1ff7cdb7e283d Breaks rails 2.3 compatibility.

I'm using rails 2.3.8 and multidb 0.3.0 from rubygems.org

Here my application console init log :

```undefined methodcolumns' for class MultiDb::ConnectionProxy'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/aliasing.rb:33:in`alias_method'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/aliasing.rb:33:in `alias_method_chain'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/query_cache.rb:7:in`included'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/query_cache.rb:6:in `class_eval'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/query_cache.rb:6:in`included'
/home/sabre/.gem/ruby/1.8/gems/multi_db-0.3.0/lib/multi_db/connection_proxy.rb:5:in `include'
/home/sabre/.gem/ruby/1.8/gems/multi_db-0.3.0/lib/multi_db/connection_proxy.rb:5
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in`gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:158:in`require'
/home/sabre/.gem/ruby/1.8/gems/multi_db-0.3.0/lib/multi_db.rb:6
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'

Using multi_db with establish_connection

Can multi_db support the following scenario?

In this example multi_db works just fine for the user model. However, multi_db either ignores or overrides the establish_connection call made in the Team model that is trying to use a connection to a different database. This results in a MySQL error similar to "Mysql::Error: Table 'production.teams' doesn't exist" because teams is not defined in the database named 'production' but rather in the database named 'third_party_db'.

# initiliazers/connection_proxy.rb

MultiDb::ConnectionProxy.setup!

# app/models/user.rb
class User < ActiveRecord::Base
  # typical user model
end

# app/models/team.rb
class Team < ThirdPartyDataProvider  
end

# app/models/third_party_data_provider.rb
class ThirdPartyDataProvider < ActiveRecord::Base
  establish_connection "third_party_db"
end

# config/database.yml
production:
  adapter: mysql
  database: production
  username: root
  password:
  host: 127.0.0.1

production_slave:
  adapter: mysql
  database: production
  username: root
  password:
  host: 127.0.0.2

third_party_db:
  adapter: mysql
  database: third_party
  username: root
  password: 
  host: 127.0.0.1

Reads on Master

I'm using MultiDB on a Master and 2 Slaves, and I still see quite a bit of "select" reads happening on the Master... ie: "select * from xxxxxx".

In the README, I see that this might not be the correct behaviour?
"It sends everything except "select โ€ฆ" queries to the master, instead of sending only specific things to the master and anything "else" to the slave. "

If not, let me know and I'll definitely start looking at the issue. Thanks!

NoMethodError undefined method 'assert_valid_keys' for true:TrueClass

iv'e found something interesting, ever since i've installed multi_db

MyModel.connection.transaction do
test = 1+2
end
return the following exception (in most cases): NoMethodError undefined method 'assert_valid_keys' for true:TrueClass

but if i run:

MyModel.connection.transaction({}) do
test = 1+2
end
everything runs smoothly.

my gut filling tells me that multi_db (which is based on masochism gem) doesnt "play nice" with one of the other gems im using ( maybe: deadlock_retry or ar-extensions).

any ideas?

using multi_db with rails 2.3.8 and ruby 1.8.7

Hello,

is it possible to use multi_db with rails 2.3.8 and ruby 1.8.7, ive installed the gem and it installed new version of activemodel/activesupport which messed a few things in my app, any ideas?

CGI::Session::ActiveRecordStore::Session using slave anyways

I have an issue with a Rails 2.3.2 app in which I'm employing the ActiveRecord session store and multi_db seems to be letting it split anyways. I even tried explicitly excluding it with:

MultiDb::ConnectionProxy.master_models = ['CGI::Session::ActiveRecordStore::Session']

To no avail, sessions keep splitting and I get the somewhat expected erratic behavior.

Any suggestions as to how I might get a better view of what is happening?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.