Hi all,
We’re attempting to use Ferret with the DRb server at the moment, and
it doesn’t work, at all…
= Executive Summary
The DRb server process keeps on calling the remote index to the DRb
server process… Which means DRb is calling itself, and itself, and
itself, until Ruby kills the Thread with a SystemStackLevel error.
= The excruciating details…
Mongrel is started using:
mongrel_rails start --port 6543 --environment development --daemonize
2>&1
config/ferret_server.yml
development:
host: 127.0.0.1
port: 3000
pid_file: log/ferret.3000.pid
Ferret’s DRb server is started using:
script/runner -e development
vendor/plugins/acts_as_ferret/script/ferret_start
app/models/email.rb:
class Email < ActiveRecord::Base
acts_as_ferret :store_class_name => true, :remote => true,
:fields => (self.content_columns.map(&:name) rescue []) +
%w(main_identifier party_display_name)
end
app/controllers/search_controller.rb
class SearchController < ApplicationController
def quick
@results = Email.id_multi_search(params[:q], %w(Contact Company))
end
end
Backtrace
stack level too deep
(druby://127.0.0.1:3000) /usr/local/lib/ruby/1.8/drb/drb.rb:1649:in
current_server' (druby://127.0.0.1:3000) /usr/local/lib/ruby/1.8/drb/drb.rb:1704:in
to_obj’
(druby://127.0.0.1:3000) /usr/local/lib/ruby/1.8/drb/drb.rb:1079:in
method_missing' (druby://127.0.0.1:3000) /home/francois/src/xlsuite.org/vendor/plugins/acts_as_ferret/lib/remote_index.rb:25:in
id_multi_search’
(druby://127.0.0.1:3000)
/home/francois/src/xlsuite.org/vendor/plugins/acts_as_ferret/lib/ferret_server.rb:69:in
send' (druby://127.0.0.1:3000) /home/francois/src/xlsuite.org/vendor/plugins/acts_as_ferret/lib/ferret_server.rb:69:in
method_missing’
/home/francois/src/xlsuite.org/vendor/plugins/acts_as_ferret/lib/remote_index.rb:25:in
id_multi_search' /home/francois/src/xlsuite.org/vendor/plugins/acts_as_ferret/lib/class_methods.rb:117:in
id_multi_search’
/home/francois/src/xlsuite.org/app/controllers/search_controller.rb:9:in
`quick’
$ rake log:clear && sleep 50 && du -h log/ferret*
(in /home/francois/src/xlsuite.org)
4.0K log/ferret.3000.pid
0 log/ferret_index.log
229M log/ferret_server.log
4.0K log/ferret_server.out
There’s nothing really useful in ferret_server.log: only the same
backtrace that I showed above.
module ActsAsFerret
module Remote
class Server
# vendor/plugins/acts_as_ferret/lib/ferret_server.rb:65
def method_missing(name, *args)
clazz = args.shift.constantize
begin
@logger.debug “call index method: #{name} with
#{args.inspect}”
clazz.aaf_index.send name, *args
rescue NoMethodError
@logger.debug “no luck, trying to call class method instead”
clazz.send name, *args
end
rescue
@logger.error “ferret server error #{$!}\n#{$!.backtrace.join
‘\n’}”
raise
end
end
end
end
When I change the logging statement inside the first begin/rescue clause
of:
http://projects.jkraemer.net/acts_as_ferret/browser/trunk/plugin/acts_as_ferret/lib/ferret_server.rb#L68
I get this (see patch at end of message):
ActsAsFerret::Server#method_missing calling:
Email.id_multi_search([“position”, [“Contact”, “Company”, “Email”],
{}])
ActsAsFerret::Server#method_missing calling:
Email.id_multi_search([“position”, [“Contact”, “Company”, “Email”],
{}])
ActsAsFerret::Server#method_missing calling:
Email.id_multi_search([“position”, [“Contact”, “Company”, “Email”],
{}])
ActsAsFerret::Server#method_missing calling:
Email.id_multi_search([“position”, [“Contact”, “Company”, “Email”],
{}])
…
In total, there are 816 calls to #method_missing before Ruby gives up
and raises.
From my limited understanding of the code, it looks like the Ferret
DRb server is using a remote index instead of a local one.
This is all using the Rails 1.2 stable branch with r179 of the
acts_as_ferret plugin and the Ferret gem at 0.11.3.
So, what have we configured wrong ?
Thanks !
François Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/
$ svn diff vendor/plugins/acts_as_ferret/
Index: vendor/plugins/acts_as_ferret/lib/ferret_server.rb
— vendor/plugins/acts_as_ferret/lib/ferret_server.rb (revision 179)
+++ vendor/plugins/acts_as_ferret/lib/ferret_server.rb (working copy)
@@ -65,7 +65,8 @@
def method_missing(name, *args)
clazz = args.shift.constantize
begin
-
@logger.debug "call index method: #{name} with #{args.inspect}"
-
@logger.debug "ActsAsFerret::Server\#method_missing calling:
#{clazz.name}.#{name}(#{args.inspect})"
-
#raise "auto block" clazz.aaf_index.send name, *args rescue NoMethodError @logger.debug "no luck, trying to call class method instead"