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

autocorrect hangs for fetchers.rb in Ruby cassandra driver #2735

Closed
stamhankar999 opened this issue Jan 28, 2016 · 7 comments
Closed

autocorrect hangs for fetchers.rb in Ruby cassandra driver #2735

stamhankar999 opened this issue Jan 28, 2016 · 7 comments
Assignees
Labels

Comments

@stamhankar999
Copy link

rubocop -a -d cluster/schema/fetchers.rb
For /Users/sandeeptamhankar/ruby-driver/lib/cassandra: configuration from /Users/sandeeptamhankar/ruby-driver/.rubocop.yml
Inheriting configuration from /Users/sandeeptamhankar/ruby-driver/.rubocop_todo.yml
Default configuration from /Users/sandeeptamhankar/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/rubocop-0.36.0/config/default.yml
Inheriting configuration from /Users/sandeeptamhankar/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/rubocop-0.36.0/config/enabled.yml
Inheriting configuration from /Users/sandeeptamhankar/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/rubocop-0.36.0/config/disabled.yml
Inspecting 1 file
Scanning /Users/sandeeptamhankar/ruby-driver/lib/cassandra/cluster/schema/fetchers.rb

CPU is pegged, so I suspect a tight loop. Clone the ruby-driver repo (https://github.com/datastax/ruby-driver.git) and try this and you should see the same behavior. NOTE: without auto-correct, rubocop does terminate.

@alexdowad
Copy link
Contributor

RC's autocorrect is incredibly slow in some cases. I am working on speeding it up.

Let's see how it works for you after that.

@stamhankar999
Copy link
Author

Well, just to be clear, the autocorrect was working through several of my files and then it got stuck on fetchers.rb for many minutes. To narrow things down, I reverted client.rb (which is about 900+ lines of code) and ran rubocop on just that file with auto-correct, and it finished in about 15 seconds. Do the same with fetchers.rb (which is about 1100+ lines), and it sits for minutes before I abort it.

So I don't think this is just a performance issue. Now, fetchers.rb is a fairly complex file, so it may be slower because of that, but orders of magnitude slower sounds very suspicious.

@jonas054
Copy link
Collaborator

jonas054 commented Feb 5, 2016

When I run auto-correction on that file I get the following error after about 90 seconds:

/home/jonas/.rvm/gems/ruby-2.3.0/gems/rubocop-0.36.0/lib/rubocop/runner.rb:184:in `check_for_infinite_loop': Infinite loop detected in /home/jonas/dev/ruby-driver/lib/cassandra/cluster/schema/fetchers.rb. (RuboCop::Runner::InfiniteCorrectionLoop)
    from /home/jonas/.rvm/gems/ruby-2.3.0/gems/rubocop-0.36.0/lib/rubocop/runner.rb:159:in `block in do_inspection_loop'
    from /home/jonas/.rvm/gems/ruby-2.3.0/gems/rubocop-0.36.0/lib/rubocop/runner.rb:158:in `loop'
    from /home/jonas/.rvm/gems/ruby-2.3.0/gems/rubocop-0.36.0/lib/rubocop/runner.rb:158:in `do_inspection_loop'
    from /home/jonas/.rvm/gems/ruby-2.3.0/gems/rubocop-0.36.0/lib/rubocop/runner.rb:87:in `process_file'
    from /home/jonas/.rvm/gems/ruby-2.3.0/gems/rubocop-0.36.0/lib/rubocop/runner.rb:59:in `block in inspect_files'
    from /home/jonas/.rvm/gems/ruby-2.3.0/gems/rubocop-0.36.0/lib/rubocop/runner.rb:57:in `each'
    from /home/jonas/.rvm/gems/ruby-2.3.0/gems/rubocop-0.36.0/lib/rubocop/runner.rb:57:in `inspect_files'
    from /home/jonas/.rvm/gems/ruby-2.3.0/gems/rubocop-0.36.0/lib/rubocop/runner.rb:35:in `run'
    from /home/jonas/.rvm/gems/ruby-2.3.0/gems/rubocop-0.36.0/lib/rubocop/cli.rb:30:in `run'
    from /home/jonas/.rvm/gems/ruby-2.3.0/gems/rubocop-0.36.0/bin/rubocop:14:in `block in <top (required)>'
    from /home/jonas/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/benchmark.rb:308:in `realtime'
    from /home/jonas/.rvm/gems/ruby-2.3.0/gems/rubocop-0.36.0/bin/rubocop:13:in `<top (required)>'
    from /home/jonas/.rvm/gems/ruby-2.3.0/bin/rubocop:23:in `load'
    from /home/jonas/.rvm/gems/ruby-2.3.0/bin/rubocop:23:in `<main>'
    from /home/jonas/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
    from /home/jonas/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'

I can try to find the cause of the problem soon.

@jonas054 jonas054 self-assigned this Feb 5, 2016
@jonas054 jonas054 added the bug label Feb 5, 2016
@jonas054
Copy link
Collaborator

jonas054 commented Feb 5, 2016

I've narrowed it down to

def f
  X.map do |(a,
             b)|
  end
end

It also causes an infinite auto-correction loop.

@alexdowad
Copy link
Contributor

It looks like MultilineBlockLayout and BlockEndNewline are fighting.

@alexdowad
Copy link
Contributor

I've got a fix.

@alexdowad
Copy link
Contributor

I don't have time to write specs right now, but I'll push first.

@bbatsov bbatsov closed this as completed in f952e1a Feb 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants