macbre / docker-sphinxsearch

Docker image for Sphinx search engine
https://hub.docker.com/r/macbre/sphinxsearch/
MIT License
55 stars 24 forks source link

FATAL: no valid indexes to serve #8

Closed jpRsah closed 4 years ago

jpRsah commented 4 years ago

I attempt use your sphinx container with mediaWiki CMS.

If i run docker-compose up i get this crash:

sphinx_1      | [Tue Mar 31 09:49:31.647 2020] [1] using config file '/opt/sphinx/conf/sphinx.conf'...
sphinx_1      | [Tue Mar 31 09:49:31.650 2020] [1] listening on 127.0.0.1:9312
sphinx_1      | listening on 127.0.0.1:9312
sphinx_1      | precaching index 'wiki_main'
sphinx_1      | [Tue Mar 31 09:49:31.650 2020] [1] WARNING: index 'wiki_main': prealloc: failed to open /opt/sphinx/index/wiki_main.sph: No such file or directory; NOT SERVING
sphinx_1      | WARNING: index 'wiki_main': prealloc: failed to open /opt/sphinx/index/wiki_main.sph: No such file or directory; NOT SERVING
sphinx_1      | precaching index 'wiki_incremental'
sphinx_1      | [Tue Mar 31 09:49:31.650 2020] [1] WARNING: index 'wiki_incremental': prealloc: failed to open /opt/sphinx/index/wiki_incremental.sph: No such file or directory; NOT SERVING
sphinx_1      | WARNING: index 'wiki_incremental': prealloc: failed to open /opt/sphinx/index/wiki_incremental.sph: No such file or directory; NOT SERVING
sphinx_1      | [Tue Mar 31 09:49:31.650 2020] [1] FATAL: no valid indexes to serve
sphinx_1      | FATAL: no valid indexes to serve

How can i run indexing first in your container?

my sphinx.conf

# Sphinx configuration for MediaWiki

source src_wiki_main
{
        type            = mysql
        sql_host        = localhost
        sql_db          = palomnik
        sql_user        = root
        sql_pass        = root
        # these two are optional
        #sql_port       = 3306
        #sql_sock       = /var/lib/mysql/mysql.sock

        # pre-query
        sql_query_pre   = SET NAMES utf8

        sql_query       = SELECT page_id, page_title, page_namespace, page_is_redirect, old_id, old_text FROM page, revision, text WHERE rev_id=page_latest AND old_id=rev_text_id

        sql_attr_uint   = page_namespace
        sql_attr_uint   = page_is_redirect
        sql_attr_uint   = old_id

        # collect all category ids for category filtering
        sql_attr_multi  = uint category from query; SELECT cl_from, page_id AS category FROM categorylinks, page WHERE page_title=cl_to AND page_namespace=14
}

source src_wiki_incremental : src_wiki_main
{
        sql_query       = SELECT page_id, page_title, page_namespace, page_is_redirect, old_id, old_text FROM page, revision, text WHERE rev_id=page_latest AND old_id=rev_text_id AND page_touched>=DATE_FORMAT(CURDATE(), '%Y%m%d070000')
        # all other parameters are copied from the parent source
}

# main index definition
index wiki_main
{
        source          = src_wiki_main
        path            = /opt/sphinx/index/wiki_main

        morphology      = stem_en
        #stopwords      = /var/lib/sphinxsearch/data/stopwords.txt
        min_word_len    = 1

        # allow wildcard (*) searches
        min_infix_len = 2

        # charset definition and case folding rules "table"
        charset_table   = 0..9, A..Z->a..z, a..z, \
                U+C0->a, U+C1->a, U+C2->a, U+C3->a, U+C4->a, U+C5->a, U+C6->a, \
                U+C7->c,U+E7->c, U+C8->e, U+C9->e, U+CA->e, U+CB->e, U+CC->i, \
                U+CD->i, U+CE->i, U+CF->i, U+D0->d, U+D1->n, U+D2->o, U+D3->o, \
                U+D4->o, U+D5->o, U+D6->o, U+D8->o, U+D9->u, U+DA->u, U+DB->u, \
                U+DC->u, U+DD->y, U+DE->t, U+DF->s, \
                U+E0->a, U+E1->a, U+E2->a, U+E3->a, U+E4->a, U+E5->a, U+E6->a, \
                U+E7->c,U+E7->c, U+E8->e, U+E9->e, U+EA->e, U+EB->e, U+EC->i, \
                U+ED->i, U+EE->i, U+EF->i, U+F0->d, U+F1->n, U+F2->o, U+F3->o, \
                U+F4->o, U+F5->o, U+F6->o, U+F8->o, U+F9->u, U+FA->u, U+FB->u, \
                U+FC->u, U+FD->y, U+FE->t, U+FF->s,
}

# ! incremental index definition
index wiki_incremental : wiki_main
{
        source          = src_wiki_incremental
        path            = /opt/sphinx/index/wiki_incremental
}

indexer
{
        mem_limit       = 64M
}

searchd
{
        # IP address and port on which search daemon will bind and accept
        listen          = 127.0.0.1:9312
        # listen          = 127.0.0.1:36307

        log             = /opt/sphinx/log/searchd.log
        query_log       = /opt/sphinx/log/query.log

        # client read timeout, seconds
        read_timeout    = 5
        # maximum amount of children to fork
        max_children    = 30

        # a file which will contain searchd process ID
        pid_file = /var/run/searchd.pid
}
macbre commented 4 years ago

@jpRsah: you can use docker-compose run to index your documents first.

docker-compose run sphinx indexer -c /opt/sphinx/conf/sphinx.conf wiki_main

Please let me know if that helps.

snewer commented 4 years ago

Hi,

I have same issue (but after run indexer):

λ docker-compose run sphinx indexer -c /opt/sphinx/conf/sphinx.conf --all
Starting docker_db_1 ... done
Sphinx 3.2.1 (commit f152e0b8)
Copyright (c) 2001-2020, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/opt/sphinx/conf/sphinx.conf'...
indexing index 'catalog'...
collected 8570 docs, 13.8 MB
sorted 1.3 Mhits, 100.0% done
total 8570 docs, 13.76 Mb
total 3.2 sec, 4.350 Mb/sec, 2710 docs/sec

λ docker-compose up sphinx
docker_db_1 is up-to-date
Starting docker_sphinx_1 ... done
Attaching to docker_sphinx_1
sphinx_1      | Sphinx 3.2.1 (commit f152e0b8)
sphinx_1      | Copyright (c) 2001-2020, Andrew Aksyonoff
sphinx_1      | Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)
sphinx_1      |
sphinx_1      | [Sat Apr 18 09:37:42.701 2020] [1] using config file '/opt/sphinx/conf/sphinx.conf'...
sphinx_1      | [Sat Apr 18 09:37:42.707 2020] [1] listening on all interfaces, port=9312
sphinx_1      | listening on all interfaces, port=9312
sphinx_1      | [Sat Apr 18 09:37:42.707 2020] [1] listening on all interfaces, port=9306
sphinx_1      | listening on all interfaces, port=9306
sphinx_1      | precaching index 'catalog'
sphinx_1      | [Sat Apr 18 09:37:42.721 2020] [1] WARNING: index 'catalog': prealloc: failed to mmap file '/opt/sphinx/index/catalog.spa': Invalid argument (length=278592); NOT SERVING
sphinx_1      | WARNING: index 'catalog': prealloc: failed to mmap file '/opt/sphinx/index/catalog.spa': Invalid argument (length=278592); NOT SERVING
sphinx_1      | [Sat Apr 18 09:37:42.722 2020] [1] FATAL: no valid indexes to serve
sphinx_1      | FATAL: no valid indexes to serve
sphinx_1      |
sphinx_1      | --- crashed SphinxAPI request dump ---
sphinx_1      |
sphinx_1      | --- request dump end ---
sphinx_1      | Sphinx 3.2.1 (commit f152e0b8)
sphinx_1      | Handling signal 11
sphinx_1      | Crash!!! Handling signal 11
sphinx_1      | -------------- backtrace begins here ---------------
sphinx_1      | Program compiled with gcc 6.4.0
sphinx_1      | Configured with flags:  '--enable-dl' '--with-mysql' '--with-pgsql' '--with-unixodbc' 'CXXFLAGS=-DSPHINX_TAG= -DNDEBUG -O3 -g1 -D__MUSL__' 'LDFLAGS=-static-libstdc++ -static-libgcc'
sphinx_1      | Host OS is Linux alpine38 4.14.69-0-vanilla #1-Alpine SMP Mon Sep 10 19:33:23 UTC 2018 x86_64 Linux
sphinx_1      | Stack bottom = 0x7ffc93030187, thread stack size = 0x20000
sphinx_1      | Trying manual backtrace:
sphinx_1      | Something wrong with thread stack, manual backtrace may be incorrect (fp=0x5)
sphinx_1      | Wrong stack limit or frame pointer, manual backtrace failed (fp=0x5, stack=0x7ffc93030000, stacksize=0x20000)
sphinx_1      | -------------- backtrace ends here ---------------
sphinx_1      | Please, create a bug report in our bug tracker (http://sphinxsearch.com/bugs) and attach there:
sphinx_1      | a) searchd log, b) searchd binary, c) searchd symbols.
sphinx_1      | Look into the chapter 'Reporting bugs' in the documentation
sphinx_1      | (/usr/share/doc/sphinx/sphinx.txt or http://sphinxsearch.com/docs/current.html#reporting-bugs)
sphinx_1      | --- BT to source lines (depth 0): ---
sphinx_1      | conversion failed (error 'No such file or directory'):
sphinx_1      |   1. Run the command provided below over the crashed binary (for example, 'searchd'):
sphinx_1      |   2. Attach the source.txt to the bug report.
sphinx_1      | addr2line -e searchd > source.txt
sphinx_1      | --- BT to source lines finished ---
sphinx_1      | --- 0 active threads ---
sphinx_1      | ------- CRASH DUMP END -------
docker_sphinx_1 exited with code 2
macbre commented 4 years ago

@snewer - can you provide your Sphinx config file? I bet there's something wrong with the location of index files.

snewer commented 4 years ago

@macbre, I using /opt/sphinx/index directory in index config.

snewer commented 4 years ago

{
    source = catalog
    path = /opt/sphinx/index/catalog
    morphology = stem_ru

    min_word_len = 1
    min_prefix_len = 3
    #expand_keywords = 1
    #index_exact_words = 1

    html_strip = 1

    charset_table =  0..9, A..Z->a..z, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F, U+401->U+0435, U+451->U+0435
}```
macbre commented 4 years ago

You can run the following to check if the index files are actually in the container:

docker-compose run sphinx ls -lh /opt/sphinx/index/

There's clearly something fishy with paths and or the way you set up volumes in your composer's YAML file.

macbre commented 4 years ago

Please re-open if this issue is still valid.