Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading to Rails 4.2: transactional callbacks deprecation warning fires due to the file require order #867

Closed
Envek opened this issue Dec 18, 2014 · 11 comments

Comments

@Envek
Copy link
Contributor

Envek commented Dec 18, 2014

I'm trying to upgrade my app to upcoming Rails 4.2 (RC 3) and according to official upgrading manual I've placed next string to config/application.rb:

config.active_record.raise_in_transactional_callbacks = true

But I still getting next output immediately after rails server:

DEPRECATION WARNING: Currently, Active Record suppresses errors raised within `after_rollback`/`after_commit` callbacks and only print them to the logs. In the next version, these errors will no longer be suppressed. Instead, the errors will propagate normally just like in other Active Record callbacks.

You can opt into the new behavior and remove this warning by setting:

  config.active_record.raise_in_transactional_callbacks = true

 (called from block in <module:Base> at /Users/anovikov/.rvm/gems/ruby-2.1.5-gost/bundler/gems/thinking-sphinx-43110fdcf9e8/lib/thinking_sphinx/active_record/base.rb:8)
=> Booting WEBrick
=> Rails 4.2.0.rc3 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2014-12-18 12:44:53] INFO  WEBrick 1.3.1
[2014-12-18 12:44:53] INFO  ruby 2.1.5 (2014-11-13) [x86_64-darwin14.0]
[2014-12-18 12:44:53] INFO  WEBrick::HTTPServer#start: pid=72022 port=3000

After some playing with puts in config/application.rb I've encountered that thinking_sphinx's file /lib/thinking_sphinx/active_record/base.rb is getting required before the most part of my app's config/application.rb is executed.

At this point I've using code from today's develop branch of thinking sphinx. I've tried to roll back to published version 3.1.2 and then I've get this warning issued somewhere from bundler: ~/.rvm/gems/ruby-2.1.5-gost@global/gems/bundler-1.7.6/lib/bundler/runtime.rb:76. I've played with puts more and encountered that it's issued while requiring gem better_errors, but it seems unrelated to Active Record at all. Weird.

If I remove thinking sphinx from Gemfile at all, warning will disappear.

Any ideas how to solve this?

See rails/rails#18084 (comment) for details.

@pat
Copy link
Owner

pat commented Dec 18, 2014

I've just generated a test project with Rails 4.2.0.rc3, added thinking-sphinx, mysql2 and better_errors to the Gemfile, and I'm not seeing any warnings. That setting is in config/application.rb... but this is a fresh new app, not one upgraded from Rails 4.1.x.

I've tried with both develop and 3.1.2 release of thinking-sphinx, and both rails server and rails console. Any thoughts on how else I could get this warning to appear?

@zhouguangming
Copy link

Same issue with rails 4.2.0 and thinking-sphinx 3.1.2

image

Above image will solve the issue, but no grace.

@pat
Copy link
Owner

pat commented Dec 23, 2014

@zhouguangming which file is that? Is this an app you've upgraded, or a fresh new Rails 4.2 app?

@zhouguangming
Copy link

@pat upgrade from Rails 4.1, it's config/application.rb.

@zhouguangming
Copy link

@pat @Envek Finally, I found it's not thinking-sphix's issue

@Envek
Copy link
Contributor Author

Envek commented Dec 23, 2014

@zhouguangming please tell us what the issue is and how to fix it.

pat added a commit that referenced this issue Dec 23, 2014
This resolves the insistent warning about errors in transactions, covered in #867.
@pat
Copy link
Owner

pat commented Dec 23, 2014

Just pushed a fix for the warning not disappearing into the develop branch. You can use it with the following in your Gemfile:

gem 'thinking-sphinx', '~> 3.1.2',
  :git    => 'git://github.com/pat/thinking-sphinx.git',
  :branch => 'develop',
  :ref    => '87928c9298'

@Envek
Copy link
Contributor Author

Envek commented Dec 23, 2014

Yes, that fixes the issue, @pat thanks a lot!

@mauro-ni
Copy link

Hi @pat,
do you have a schedule for rails 4.2 support? When will this fix be applied to a stable version of TS?
Many thanks,
Mauro

@pat
Copy link
Owner

pat commented Jan 21, 2015

Just published TS v3.1.3, which includes the Rails 4.2 patches.

@mauro-ni
Copy link

Great!
Thank you @pat!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants