0

have a cron job that calls

cd /Users/me/rails/current && bundle exec rake ts:rebuild >> /Users/me/log/sphinx_index.log

the task calls up the proper release. Runs through all the indices, runs through all the scores, the declares 'Started successfully (pid 53801).'

Run a search and instead get the unfortunate message:

undefined method `constantize' for 0:Fixnum

manually entering into the app's directory and launching rake ts:rebuild (both with and without bundle exec), returns the app to its happy state.

The only difference I see is that the manual task returns:

WARNING: 'require 'rake/rdoctask'' is deprecated.  Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead.
    at /Users/me/rails/shared/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/rdoctask.rb
DEPRECATION WARNING: Rake tasks in vendor/plugins/criteriaquery/tasks are deprecated. Use lib/tasks instead. (called from /Users/me/rails/shared/bundle/ruby/1.8/gems/rails-2.3.10/lib/tasks/rails.rb:10)

whereas the log file makes no mention of this.

Attempts at setting cron jobs for other apps, under rails3 have also failed but not investigated seriously, given the unresolved issue at hand.

Full stack trace follows:

/Users/its/rails/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.5.0/lib/thinking_sphinx/search.rb:982:in class_from_crc' /Users/its/rails/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.5.0/lib/thinking_sphinx/search.rb:961:ininstances_from_matches' /Users/its/rails/shared/bundle/ruby/1.8/gems/activesupport-2.3.10/lib/active_support/ordered_hash.rb:115:in each' /Users/its/rails/shared/bundle/ruby/1.8/gems/activesupport-2.3.10/lib/active_support/ordered_hash.rb:115:ineach' /Users/its/rails/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.5.0/lib/thinking_sphinx/search.rb:959:in instances_from_matches' /Users/its/rails/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.5.0/lib/thinking_sphinx/search.rb:465:incompose_results' /Users/its/rails/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.5.0/lib/thinking_sphinx/search.rb:442:in populate' /Users/its/rails/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.5.0/lib/thinking_sphinx/search.rb:603:incall' /Users/its/rails/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.5.0/lib/thinking_sphinx/search.rb:603:in retry_on_stale_index' /Users/its/rails/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.5.0/lib/thinking_sphinx/search.rb:419:inpopulate' /Users/its/rails/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.5.0/lib/thinking_sphinx/search.rb:286:in total_entries' /Users/its/rails/releases/20130829144322/app/views/ricerca/risultati.html.erb:1:in_run_erb_app47views47ricerca47risultati46html46erb' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_view/renderable.rb:34:in send' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_view/renderable.rb:34:inrender' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_view/base.rb:306:in with_template' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_view/renderable.rb:30:inrender' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_view/template.rb:205:in render_template' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_view/base.rb:265:inrender' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_view/base.rb:348:in _render_with_layout' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_view/base.rb:262:inrender' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/base.rb:1252:in render_for_file' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/base.rb:936:inrender_without_benchmark' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/benchmarking.rb:51:in render' /Users/its/rails/shared/bundle/ruby/1.8/gems/activesupport-2.3.10/lib/active_support/core_ext/benchmark.rb:17:inms' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in realtime' /Users/its/rails/shared/bundle/ruby/1.8/gems/activesupport-2.3.10/lib/active_support/core_ext/benchmark.rb:17:inms' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/benchmarking.rb:51:in render' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/base.rb:1328:indefault_render' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/base.rb:1334:in perform_action_without_filters' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/filters.rb:617:incall_filters' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/filters.rb:610:in perform_action_without_benchmark' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/benchmarking.rb:68:inperform_action_without_rescue' /Users/its/rails/shared/bundle/ruby/1.8/gems/activesupport-2.3.10/lib/active_support/core_ext/benchmark.rb:17:in ms' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:inrealtime' /Users/its/rails/shared/bundle/ruby/1.8/gems/activesupport-2.3.10/lib/active_support/core_ext/benchmark.rb:17:in ms' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/benchmarking.rb:68:inperform_action_without_rescue' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/rescue.rb:160:in perform_action_without_flash' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/flash.rb:151:inperform_action' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/base.rb:532:in send' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/base.rb:532:inprocess_without_filters' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/filters.rb:606:in process' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/base.rb:391:inprocess' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/base.rb:386:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/routing/route_set.rb:438:incall' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/dispatcher.rb:87:in dispatch' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/dispatcher.rb:121:in_call' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/dispatcher.rb:130:in build_middleware_stack' /Users/its/rails/shared/bundle/ruby/1.8/gems/activerecord-2.3.10/lib/active_record/query_cache.rb:29:incall' /Users/its/rails/shared/bundle/ruby/1.8/gems/activerecord-2.3.10/lib/active_record/query_cache.rb:29:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/activerecord-2.3.10/lib/active_record/connection_adapters/abstract/query_cache.rb:34:incache' /Users/its/rails/shared/bundle/ruby/1.8/gems/activerecord-2.3.10/lib/active_record/query_cache.rb:9:in cache' /Users/its/rails/shared/bundle/ruby/1.8/gems/activerecord-2.3.10/lib/active_record/query_cache.rb:28:incall' /Users/its/rails/shared/bundle/ruby/1.8/gems/activerecord-2.3.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/warden-0.10.7/lib/warden/manager.rb:35:incall' /Users/its/rails/shared/bundle/ruby/1.8/gems/warden-0.10.7/lib/warden/manager.rb:34:in catch' /Users/its/rails/shared/bundle/ruby/1.8/gems/warden-0.10.7/lib/warden/manager.rb:34:incall' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/string_coercion.rb:25:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/rack-1.1.3/lib/rack/head.rb:9:incall' /Users/its/rails/shared/bundle/ruby/1.8/gems/rack-1.1.3/lib/rack/methodoverride.rb:24:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/params_parser.rb:15:incall' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/session/cookie_store.rb:100:in call' /Users/its/rails/shared/bundle/ruby/1.8/bundler/gems/devise-efc42d7662f3/lib/devise/rails/warden_compat.rb:43:incall' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/failsafe.rb:26:in call' /Users/its/rails/shared/bundle/ruby/1.8/gems/rack-1.1.3/lib/rack/lock.rb:11:incall' /Users/its/rails/shared/bundle/ruby/1.8/gems/rack-1.1.3/lib/rack/lock.rb:11:in synchronize' /Users/its/rails/shared/bundle/ruby/1.8/gems/rack-1.1.3/lib/rack/lock.rb:11:incall' /Users/its/rails/shared/bundle/ruby/1.8/gems/actionpack-2.3.10/lib/action_controller/dispatcher.rb:106:in call' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/rack/request_handler.rb:96:inprocess_request' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_request_handler.rb:513:in accept_and_process_next_request' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_request_handler.rb:274:inmain_loop' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/classic_rails/application_spawner.rb:321:in start_request_handler' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/classic_rails/application_spawner.rb:275:insend' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/classic_rails/application_spawner.rb:275:in handle_spawn_application' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/utils.rb:479:insafe_fork' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/classic_rails/application_spawner.rb:270:in handle_spawn_application' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:357:insend' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:357:in server_main_loop' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:206:instart_synchronously' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:180:in start' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/classic_rails/application_spawner.rb:149:instart' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:219:in spawn_rails_application' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server_collection.rb:132:inlookup_or_add' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:214:in spawn_rails_application' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server_collection.rb:82:insynchronize' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server_collection.rb:79:in synchronize' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:213:inspawn_rails_application' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:132:in spawn_application' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:275:inhandle_spawn_application' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:357:in __send__' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:357:inserver_main_loop' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously' /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/helper-scripts/passenger-spawn-server:99

Jerome
  • 5,583
  • 3
  • 33
  • 76

1 Answers1

0

My guess without seeing the stack trace is that Sphinx's searchd and indexer command-line tools aren't accessible directly by cron (they're in your PATH, but not cron's). Thus, Thinking Sphinx is presuming an older version of Sphinx and sending/expecting a slightly different protocol. Although the fact that it's making progress on this front is odd... perhaps you have two different versions of Sphinx installed?

You can set the Sphinx version manually in your config/sphinx.yml file:

production:
  version: 2.0.8

Also setting the SPHINX_VERSION environment variable will have the same affect.

Unrelated, but there's no need to rebuild on a regular basis - just running an index ensures the data Sphinx has loaded is up to date. A rebuild is only required when you're changing your index definitions (much like a db:migrate call).

pat
  • 16,116
  • 5
  • 40
  • 46
  • The server does have various versions. This rails app is in 2.3.10, whereas thinking-sphinx' is set at '1.5.0'. The assumption of running different versions makes sense: the cron job started failing later when sphinx was loaded on rails 3 app. Now, the application being in rails 2.3 has no sphinx.config.yml file; what is a proper way about this? – Jerome Sep 14 '13 at 06:26
  • I'm actually referring to the Sphinx version, not the Thinking Sphinx version... if config/sphinx.yml doesn't exist, you can create it - the settings are per environment, just like config/database.yml. – pat Sep 15 '13 at 07:18
  • Also: this answer is appropriate for Thinking Sphinx pre version 3. If you're using version 3, then the error you're seeing isn't what I've guessed, and a stack trace will certainly help tracking it down. – pat Sep 15 '13 at 07:19
  • Right, it's definitely an issue with Sphinx version expectations. What version of Sphinx do you have installed? – pat Sep 16 '13 at 01:53
  • It was not specified initially in the sphinx.yml file. I added 2.0.8 as per above. But the cron task yielded the stack trace which is in the updated question. Gemfile.lock states thinking-sphinx (1.5.0) activerecord (~> 2.1) after_commit (>= 1.0.7) innertube (~> 1.0.2) riddle (>= 1.5.6) – Jerome Sep 16 '13 at 07:38
  • Right, but if you run `indexer` from the command line on the server, the first line of the output should indicate what version is installed. – pat Sep 16 '13 at 07:39
  • Sphinx 2.0.8-release (r3831) is what is stated just now. Should I try removing the spinx.yml entry for 2.0.8 and see what that returns? – Jerome Sep 16 '13 at 07:42
  • Out of interest, for the other sphinx-enabled apps on the same server, the sphinx.yml file does not have the version specified, but indexer returns Sphinx 2.0.8-release (r3831) in all cases – Jerome Sep 16 '13 at 07:53
  • sphinx.yml doesn't change what version of Sphinx is on your machine, it just tells Thinking Sphinx what version to expect (should there be PATH or other issues stopping automatic detection). – pat Sep 16 '13 at 10:14
  • Issue still unsolved. However I tried to run a cron job for another app cd /Users/me/saim/current && bundle exec rake ts:index . Got an interesting error 'Could not find rake-0.9.2.2 in any of the sources' notwithstanding that version is specified in the gemfile and appears with the command 'bundle list'; RVM gemset also exists. Could there be any relation between the issues here? – Jerome Oct 04 '13 at 07:06