Nate
Nate

Reputation: 28424

Can't merge sphinx delta index immediately after rotating?

I noticed my delta index wasn't being merged into the main index and after doing some investigating discovered this happens when I try to merge the delta index to the main index immediately after rotating the delta index.

This is the command I was running on my dev computer (Windows):

C:\Sphinx\bin\indexer.exe --config C:\wamp\www\path\to\sphinx\etc\sphinx_windows.conf my_delta_index --rotate && C:\Sphinx\bin\indexer.exe --config C:\wamp\www\path\to\sphinx\etc\sphinx_windows.conf --merge my_index my_delta_index --rotate

The output showed that both commands executed successfully, but items didn't show up in search that should have.

When I tried running the first part of that command:

C:\Sphinx\bin\indexer.exe --config C:\wamp\www\path\to\sphinx\etc\sphinx_windows.conf my_delta_index --rotate

Followed a few seconds later by:

C:\Sphinx\bin\indexer.exe --config C:\wamp\www\path\to\sphinx\etc\sphinx_windows.conf --merge my_index my_delta_index --rotate

Everything worked.

I haven't been able to find anything suggesting this in the documentation, but do you have to wait a certain amount of time after rotating a delta index before merging it into the main index?

Upvotes: 0

Views: 510

Answers (1)

barryhunter
barryhunter

Reputation: 21091

--rotate by its nature is asynchronous - indexer builds the new version of the index, but just 'tells' searchd to 'activate' it. searchd can do this at its leasure. It may take effect right away, or may take many seconds.

So when the 'merge' happens, its quite possible that the new index hasnt finished being 'activated'; so the merge process, just remerges the old version of delta. (the old version is still in use until rotation completes)

But its also possible that its the second rotation that hasnt completed, searchd hadnt finished loading the new merged main yet, so you still searching the old version.

... so yes, you do need to wait after running a --rotate style reindex before doing anything more with the index. There is no built in commands to monitor the process, all can do is either watch the searchd log file, or watch the filenames of the indexes, as the old and new are switched around.

Upvotes: 1

Related Questions