#1213 ✓resolved
Xavier Shay

dm-rails doesn't work with dm-transactions

Reported by Xavier Shay | March 6th, 2010 @ 04:48 PM | in 1.0.0

the BenchmarkingAdapter proxy object confuses dm-transactions.

Root of the problem is that the first entrance into the transaction is at the Proxy level, but dm-transactions mixes in code to PostgresAdapter that uses the same vars set up with the proxy. Since proxy != adapter, the @adapters hash set up with the proxy as the key can't find the actual adapter, so raises.

This would be a problem for any nested adapters, so I think this is a bug in dm-transactions.

I don't have a good solution to this yet, but you can work around by commenting out the section in db-rails that sets up the BenchmarkingAdapter.

Comments and changes to this ticket

  • Xavier Shay

    Xavier Shay March 6th, 2010 @ 04:51 PM

    To replicate, in a rails 3 + postgres project console:

      YourModel.transaction { YourModel.first }

    Another way to work around is to explicitly create a transaction and use that:

  • Daniel Neighman

    Daniel Neighman March 6th, 2010 @ 05:21 PM

    This is also an issue in the migrations. When you trie to run a migrartion it will raise an error because it can find the SQL inner constant on the Benchmark adapter.

  • Daniel Neighman
  • Martin Gamsjaeger (snusnu)

    Martin Gamsjaeger (snusnu) March 8th, 2010 @ 11:33 AM

    • Milestone set to 1.0.0
    • State changed from “unconfirmed” to “confirmed”
  • Xavier Shay

    Xavier Shay March 8th, 2010 @ 09:47 PM

    Here is an incomplete solution using a mixin. Not sure how to wire up the initializer - see the README.

  • Marcin Kulik

    Marcin Kulik March 12th, 2010 @ 10:40 AM

    Xavier, your fix fixed one issue but then something else broken: undefined method reset_runtime' for #<DataMapper::Adapters::MysqlAdapter:0xb6aff788>

  • Xavier Shay

    Xavier Shay March 12th, 2010 @ 04:19 PM

    See the README, you need to add the initializer to your project. I don't have enough gem-fu to do this automatically yet.

  • Martin Gamsjaeger (snusnu)

    Martin Gamsjaeger (snusnu) March 25th, 2010 @ 09:12 AM

    • Assigned user set to “Martin Gamsjaeger (snusnu)”
  • Martin Gamsjaeger (snusnu)

    Martin Gamsjaeger (snusnu) March 30th, 2010 @ 09:15 AM

    • State changed from “confirmed” to “accepted”
  • Martin Gamsjaeger (snusnu)

    Martin Gamsjaeger (snusnu) March 30th, 2010 @ 09:57 AM

    • State changed from “accepted” to “resolved”

    This should be fixed in http://github.com/datamapper/dm-rails/commit/a0eb1fd1fbf09c222a7772...

    Marking this resolved for now, please reopen if there are still problems!

  • Kevin Watt

    Kevin Watt July 18th, 2010 @ 01:22 PM

    • Milestone order changed from “0” to “0”

    I'm now getting this with rspec tests:

    1) TopicsController GET index assigns all boards as @boards

    Failure/Error: get :index
    undefined method `reset_runtime' for #<DataMapper::Adapters::MysqlAdapter:0x104160ad0>
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/dm-rails-1.0.0/lib/dm-rails/railties/controller_runtime.rb:18:in `cleanup_view_runtime'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/instrumentation.rb:38:in `render'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/implicit_render.rb:5:in `send_action'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/actionpack-3.0.0.beta4/lib/abstract_controller/base.rb:145:in `process_action'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/rendering.rb:11:in `process_action'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/actionpack-3.0.0.beta4/lib/abstract_controller/callbacks.rb:18:in `process_action'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb:468:in `_run__599332899__process_action__199225275__callbacks'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb:408:in `send'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb:408:in `_run_process_action_callbacks'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb:88:in `send'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb:88:in `run_callbacks'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/actionpack-3.0.0.beta4/lib/abstract_controller/callbacks.rb:17:in `process_action'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.0.beta4/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.0.beta4/lib/active_support/notifications.rb:48:in `__send__'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/activesupport-3.0.0.beta4/lib/active_support/notifications.rb:48:in `instrument'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/instrumentation.rb:28:in `process_action'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/rescue.rb:8:in `process_action'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/actionpack-3.0.0.beta4/lib/abstract_controller/base.rb:114:in `process'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/actionpack-3.0.0.beta4/lib/abstract_controller/rendering.rb:40:in `process'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/testing.rb:12:in `process_with_new_base_test'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/actionpack-3.0.0.beta4/lib/action_controller/test_case.rb:392:in `process'
    # /Users/inspire/.rvm/gems/ree-1.8.7-2010.02/gems/actionpack-3.0.0.beta4/lib/action_controller/test_case.rb:330:in `get'
    # ./spec/controllers/topics_controller_spec.rb:47

    Any tips? It happens both with and without using the database_cleaner start/clean steps. It only seems to happen with the first rspec test, strange.

    describe "GET index" do

    it "assigns all boards as @boards" do
      get :index
      # lazy loading will screw this up?
      assigns(:boards).should == Board.all 


Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Referenced by