ts:rebuild/ts:stop/ts:start not working on heroku

Gaetan's Avatar

Gaetan

Jun 20, 2022 @ 03:42 AM

Hi there,

I am trying to run ts:rebuild after updating some indexes. I get the following error on heroku:

heroku run -s performance-m -a app bundle exec rake ts:rebuild
....
rake aborted!
NoMethodError: undefined method pid' for #<FlyingSphinx::Controller:0x00007fcd0a04a9a0>
/app/vendor/bundle/ruby/2.6.0/gems/thinking-sphinx-3.4.2/lib/thinking_sphinx/commands/stop.rb:8:incall'
/app/vendor/bundle/ruby/2.6.0/gems/thinking-sphinx-3.4.2/lib/thinking_sphinx/commands/base.rb:9:in call_with_handling'
/app/vendor/bundle/ruby/2.6.0/gems/thinking-sphinx-3.4.2/lib/thinking_sphinx/commands/base.rb:5:incall'
/app/vendor/bundle/ruby/2.6.0/gems/thinking-sphinx-3.4.2/lib/thinking_sphinx/interfaces/daemon.rb:25:in stop'
/app/vendor/bundle/ruby/2.6.0/gems/thinking-sphinx-3.4.2/lib/thinking_sphinx/tasks.rb:70:inblock (2 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.6.0/gems/bugsnag-5.5.0/lib/bugsnag/rake.rb:12:in execute_with_bugsnag&#39;
/app/vendor/bundle/ruby/2.6.0/gems/rake-13.0.3/exe/rake:27:in<top (required)>'
/app/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:74:in load&#39;
/app/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:74:inkernel_load'
/app/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:28:in run&#39;
/app/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli.rb:463:inexec'
/app/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/command.rb:27:in run&#39;
/app/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:ininvoke_command'
/app/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor.rb:387:in dispatch&#39;
/app/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli.rb:27:indispatch'
/app/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/base.rb:466:in start&#39;
/app/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli.rb:18:instart'
/app/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/exe/bundle:30:in block in &lt;top (required)&gt;&#39;
/app/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/friendly_errors.rb:124:inwith_friendly_errors'
/app/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/exe/bundle:22:in &lt;top (required)&gt;&#39;
/app/bin/bundle:3:inload'
/app/bin/bundle:3:in `<main>'
Tasks: TOP => ts:rebuild => ts:stop
(See full trace by running task with --trace)

Version :

# Sphinx
gem 'flying-sphinx',   '~> 1.3'
gem 'mysql2',          '~> 0.5.3'
gem 'thinking-sphinx', '~> 3.4'

Looking at the code I can see this line :
searchd.pid_file = log_root.join("#{environment}.sphinx.pid").to_s in lib/thinking_sphinx/configuration.rb

It looks like thinking-sphinx is trying to find the pid file in log/production.sphinx.pid , which doesn't exist on the heroku dyno.

I am not sure what to do here ?? do I need to run the rake task in a specific dyno ??

  1. Support Staff 1 Posted by Pat Allan on Jun 20, 2022 @ 03:51 AM

    Pat Allan's Avatar

    Hi Gaetan

    Because you're using old versions of both the thinking-sphinx and flying-sphinx gems, you can't use the standard ts: rake tasks. Instead, you'll need to use the legacy fs: equivalents. For example: heroku run -s performance-m -a app bundle exec rake fs:rebuild.

    Certainly, upgrading the gems is recommended (and there is documentation specifically for moving thinking-sphinx from v3 to v4, and v4 to v5), but I understand that's perhaps not a priority for you! For what it's worth: upgrading thinking-sphinx to v4 should allow you to use the latest flying-sphinx release and the standard ts: rake tasks.

    Kind regards,

    Pat

  2. 2 Posted by Gaetan on Jun 20, 2022 @ 05:10 AM

    Gaetan's Avatar

    Thanks for the speedy response Pat!

    I believe fs:regenerate is what I am after.

    Upgrading is definitely in the pipeline, you know one day :)

Reply to this discussion

Internal reply

        No formatting (switch to Markdown)

          You can attach files up to 10MB

            If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

              Keyboard shortcuts

              Generic

              ? Show this help
              ESC Blurs the current field

              Comment Form

              r Focus the comment reply box
              ^ + ↩ Submit the comment

              You can use Command ⌘ instead of Control ^ on Mac