pat / thinking-sphinx

Sphinx/Manticore plugin for ActiveRecord/Rails
http://freelancing-gods.com/thinking-sphinx
MIT License
1.63k stars 468 forks source link

`ts:rt:index` is not reached when running `ts:rebuild NODETACH=true` #1150

Closed eduardoj closed 4 years ago

eduardoj commented 4 years ago

When running a rebuild in no-detach mode, the task ts:rt:index is not executed.

For example:

> /usr/bin/bundle.ruby2.5 exec rails ts:rebuild NODETACH=true
searchd is not currently running.
Generating configuration to /obs/src/api/config/development.sphinx.conf
Sphinx 2.2.11-id64-release (95ae9a6)
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/obs/src/api/config/development.sphinx.conf'...
listening on 127.0.0.1:9312
precaching index 'package_core'
precaching index 'project_core'
precached 2 indexes in 0.002 sec
accepting connections

There are no problems in detached mode:

> /usr/bin/bundle.ruby2.5 exec rails ts:rebuild              
searchd is not currently running.
Generating configuration to /obs/src/api/config/development.sphinx.conf
Sphinx 2.2.11-id64-release (95ae9a6)
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/obs/src/api/config/development.sphinx.conf'...
listening on 127.0.0.1:9312
precaching index 'package_core'
precaching index 'project_core'
precached 2 indexes in 0.001 sec
Started searchd successfully (pid: 77).
Generating index files for package_core
..............................................................................................................................................................................................
..............................................................................................................................................................................................
......................................................................................................................................................................
Generating index files for project_core
.............
>

I would like that the rebuild task also generates the real time index files.

pat commented 4 years ago

The issue here is that for real-time indices, Sphinx needs to be running, so start is invoked before indexing. And for no-detach, the start task takes over the process, so nothing else will happen after it…

So, I'm not really sure if rebuilding while using no-detach is possible. I'm not sure what such a thing would look like!

A potential workaround could be to run a rebuild in detached mode, and then restart in no-detached mode?

pat commented 4 years ago

This issue's been dormant for a couple of months now, so I'm thinking I'm going to close it.

I realise there hasn't been a fix, but I think any solution for this is either going to manage multiple processes (which I think is beyond the scope of TS), or it's a matter of running ts:rebuild and ts:stop without the env flag (thus, letting the real-time indexing occur), and then ts:start afterwards with NODETACH=true. Either way, I'm feeling this is up to users to choose what suits them, rather than changes to TS's behaviour - but I'm open to suggestions otherwise, should anyone have ideas!