【问题标题】:ThinkingSphinx3: How to prevent searchd threads from freezing?ThinkingSphinx3:如何防止搜索线程冻结?
【发布时间】:2013-04-27 20:26:00
【问题描述】:

我正在使用 Rails 3.2.12、RSpec-rails 2.13.0 和 ThinkingSphinx 3.0.10

问题:

当我运行 bundle exec rpsec spec/controllers/ads_controller_spec.rb 时,我认为 sphinx 会产生 3 个被冻结的 searchd 进程,我的测试只是锁定,直到我手动终止 searchd 进程,之后测试继续运行。

设置:

这是我的 sphinx_env.rb 文件,我在其中设置 TS 进行测试:

require 'thinking_sphinx/test'

def sphinx_environment(*tables, &block)
  obj = self
  begin
    before(:all) do
      obj.use_transactional_fixtures = false
      ThinkingSphinx::Test.init
      ThinkingSphinx::Test.start
      sleep(0.5)
    end

    yield
  ensure
    after(:all) do
      ThinkingSphinx::Test.stop
      sleep(0.5)
      obj.use_transactional_fixtures = true
    end
  end
end

这是我的测试脚本:

describe "GET index" do
  before(:each) do
    @web_origin   = FactoryGirl.create(:origin)
    @api_origin   = FactoryGirl.create(:api_origin)
    @first_ad     = FactoryGirl.create(:ad, :origin_id => @web_origin.id)

    ThinkingSphinx::Test.index #index ads created above
    sleep 0.5
  end

  sphinx_environment :ads do 
    it 'should return a collection of all live ads' do
      get :index, {:format => 'json'}
      response.code.should == '200'
    end 
  end
...

更新

没有取得任何进展,但这里有一些额外的细节:

  • 当我运行测试时,认为 sphinx 总是开始 3 searchd 过程。
  • test.sphinx.pid 中的 pid 始终只有一个 searchd pid,它始终是第二个 searchd 进程 pid。
  • 这是我的 test.searchd.log 文件的输出:

    [568] binlog: 0.006 秒内完成回放总共 49 个

    [568] 接受连接

    [568] 捕捉到 SIGHUP(无缝=1,在队列中=1)

    [568] 旋转索引“ad_core”:开始

    [568] 捕捉到 SIGHUP(无缝=1,在队列中=2)

    [568] 捕捉到 SIGTERM,正在关闭

感谢任何帮助,我已经尝试解决这个问题超过一天,有点迷茫。

谢谢。

【问题讨论】:

  • 您能确认您使用的是什么版本的 Thinking Sphinx(最新的是 3.0.2,而不是 3.0.10)?另外,您使用的是什么版本的 Sphinx 和什么操作系统?
  • 嗨,Pat,我正在使用 TS 3.0.2、Mountain Lion 和 Sphinx 2.0.2

标签: ruby-on-rails-3 sphinx thinking-sphinx


【解决方案1】:

Sphinx 2.0.x 带有线程化 Sphinx 工作线程的版本(这是 Thinking Sphinx v3 使用的,因此有多个 searchd 进程)在 OS X 上存在错误,但这在 Sphinx 2.0.6 中得到了修复(这是主要的事情之一阻碍 TS v3 开发 - 由于您所看到的问题,我自己的测试无法运行)。

我建议将 Sphinx 升级到 2.0.6,我很确定应该可以解决这些问题。

【讨论】:

  • 一如既往地感谢这个,我真的很茫然!下次你在都柏林时欠你一杯啤酒:)
猜你喜欢
  • 1970-01-01
  • 2015-08-16
  • 2013-05-20
  • 1970-01-01
  • 1970-01-01
  • 2019-09-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多