Rails multi_db与事务 [英] Rails multi_db with transaction
问题描述
我最近在我的rails 2.3.10应用程序上安装了multi_db gem,以便使用MySql主/从复制。
自安装gem以来,我在我的代码中使用事务,例如:
MyModel.connection.transaction do
...一些代码...
end
我得到一个异常: 关于如何在事务中使用multi_db的任何想法? 编辑: 返回以下异常(大多数情况下): 但是如果我运行: NoMethodError未定义方法'assert_valid_keys'为true:TrueClass $
iv'e发现了一些有趣的事情,因为我已经安装了multi_db
MyModel.connection.transaction do
test = 1 + 2
end
NoMethodError未定义的方法'assert_valid_keys'为true:TrueClass
MyModel.connection.transaction({})do
test = 1 + 2
end
一切运行顺利。
我的肠道填充告诉我,multi_db(基于受虐狂宝石)并没有玩好与其他宝石即时通讯使用(也许是:deadlock_retry或AR扩展)。
有什么想法吗?$ / b $ b
multi_db与ActiveRecord 2.3.10不完全兼容。它使用不同的参数来调用连接上的
事务
方法,这是可接受的(请参阅呼叫站点)。 您不得不使用交易,降级Rails,修复multi_db(请做!),或者完全删除那个gem。
你可以看到这里在一月份的ActiveRecord :: ConnectionAdapters :: DatabaseStatements中,参数 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.: I get an exception: any ideas on how to use multi_db with transactions? EDIT:
iv'e found something interesting, ever since i've installed multi_db return the following exception (in most cases): but if i run: 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? multi_db is not entirely compatible with ActiveRecord 2.3.10. It's calling the You'll have to either not use transactions, downgrade Rails, fix multi_db (please do!), or just remove that gem entirely. You can see here where the parameters to 这篇关于Rails multi_db与事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!MyModel.connection.transaction do
...some code...
end
NoMethodError undefined method 'assert_valid_keys' for true:TrueClass
MyModel.connection.transaction do
test = 1+2
end
NoMethodError undefined method 'assert_valid_keys' for true:TrueClass
MyModel.connection.transaction({}) do
test = 1+2
end
transaction
method on the connection with different arguments than are acceptable (see the call site here).transaction
changed in ActiveRecord::ConnectionAdapters::DatabaseStatements, back in January 2009 (before Rails 2.3.0 was released).