重建sphinx索引失败

时间:2013-03-11 12:19:29

标签: sphinx

我们使用一个表中的数据构建了4个sphinx索引。所有索引都具有相同的源设置,除了它们采用不同的文档。我们有像mod(id, 4) = <index number>这样的检查来在索引之间分发文档和文档属性。

问题:几乎每次重建索引时,四个索引中的一个(同一个索引)都无法重建。其他索引永远不会出现此问题并且可以正确重建。

我们已经对文档和属性表进行了分区。例如,这是文档表的分区方式:

PARTITION BY HASH(mod(id, 4))(
  PARTITION `p0` COMMENT '',
  PARTITION `p1` COMMENT '',
  PARTITION `p2` COMMENT '',
  PARTITION `p3` COMMENT ''
);

我们认为索引器在收到所有文档之后但在开始接收属性之前就会挂起。当我们检查MySQL服务器上的会话时,我们可以看到这一点。

无法重建的索引使用mod(id, 4) = 0条件。

我们在Ubuntu 64bit 12.04.02 LTS上使用Sphinx 2.0.4版本。


数据源配置

source ble_job_2 : ble_job
{
    sql_query = select job_notice.id as id, \
        body, title, source, company, \
        UNIX_TIMESTAMP(insertDate) as date, \
        substring(company, 1, 1) as companyletter, \
        job_notice.locationCountry as country, \
        location_us_state.stateName as state, \
        0 as expired, \
        clusterId, \
        groupCity, \
        groupCityAttr, \
        job_notice.cityLat as citylat, \
        job_notice.cityLng as citylng, \
        job_notice.zipLat as ziplat, \
        job_notice.zipLng as ziplng, \
        feedId, job_notice.rating as rating, \
        job_notice.cityId as cityid \
        from job_notice \
        left join location_us_state on job_notice.locationState = location_us_state.stateCode \
        where job_notice.status != 'expired' \
        and mod(job_notice.id, 4) = 1

    sql_attr_multi = uint attr from query; \
        select noticeId, attributeId as attr from job_notice_attribute where mod(noticeId, 4) = 1
} # source ble_job_2

索引配置

index ble_job_2
{
    type            = plain
    source          = ble_job_2
    path            = /var/lib/sphinxsearch/data/ble_job_2

    docinfo         = extern
    mlock           = 0
    morphology      = none
    stopwords       = /etc/sphinxsearch/stopwords/blockwords.txt
    min_word_len    = 1
    charset_type    = utf-8
    enable_star     = 0
    html_strip      = 0
} # index_ble_job_2

非常感谢任何帮助。

热烈的问候。

1 个答案:

答案 0 :(得分:0)

幸运的是,我们已经解决了这个问题。

我们已应用range query设置,这有助于我们让索引重建稳定。我认为这是因为Sphinx运行了几个查询,每个查询返回有限的相对较小的结果集。这允许MySQL正常完成查询并将所有结果发送回Sphinx。

在Sphinx论坛Indexer Hangs & MySQL Query Sleeps上描述了同样的问题。


数据源配置的更改是

    sql_query_range = SELECT MIN(id),MAX(id) FROM job_notice where mod(job_notice.id, 4) = 1
    sql_range_step = 200000
    sql_query = select job_notice.id as id, \
    ...
        and mod(job_notice.id, 4) = 1 and job_notice.id >= $start AND job_notice.id <= $end

请注意,sql_attr_multi查询不应该应用范围 - Bad query in Sphinx MVA