thinking-sphinx: Unknown MySQL error

I am developing a new web database app (Rails 5.2, mysql 5.6.38, libmysql - mysqlnd 5.0.12-dev, thinking-sphinx 4.0.0), and just deployed Sphinx and Thinking-Sphinx. All of the configurations work, the database is indexed with no problems.

But when I run a search (Grant.search ‘agriculture’), I get the following error:

Sphinx Query (2.0ms) SELECT * FROM grant_core WHERE MATCH(‘agriculture’) AND sphinx_deleted = 0 LIMIT 0, 20 Completed 500 Internal Server Error in 130ms (ActiveRecord: 93.9ms)

ThinkingSphinx::SphinxError (Unknown MySQL error):

mysql2 (0.5.1) lib/mysql2/client.rb:90:in `connect’

I interpret this as sphinx is not connecting to the MySQL server. My mysql server is running on a separate machine. I’m assuming this is simply a config problem, but I haven’t been able to find it.

Any thoughts?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 49 (23 by maintainers)

Most upvoted comments

I reverted the mysql2 gem back down to 0.4.9 and it started working again! I then put it up to 0.4.10, 0.5.0, or 0.5.1 and it re-breaks. I’ll continue to research this but have a viable solution for Rails 5.2.

In case it’s helpful to anyone:

I have a separate mysql5.7 install. Running thinking-sphinx against mysql2 versions installed with only that mysql5.7 on my laptop worked fine.

In setting up Thinking Sphinx though, I installed sphinx via brew brew install --with-mysql which of course installed mysql 8. Installing mysql2 gems after this caused Thinking Sphinx to fail with the Unknown Mysql Error because those gems were getting built against the Mysql 8 client lib /usr/local/opt/mysql/lib/libmysqlclient.21.dylib FWIW, trying to install the mysql2 gem while setting --with-mysql-config or --with-mysql-dir and pointing at my Mysql 5 install did not help — the mysql2 gem always built against the MySQL 8 client library. Uninstalling MySQL 8 from my laptop and re-installing the mysql2 gem got thinking sphinx working again.

I’ve just submitted a PR to Homebrew to lock the MySQL dependency in the Sphinx formula to 5.7.

However, I believe Homebrew has removed the ability to pass through the flag for PostgreSQL support (thus, it’s not useful if you’re using SQL-backed indices on a PostgreSQL database) … so, rather than relying on Sphinx via Homebrew, I’d either be installing Sphinx 3.1.1 manually, or using Manticore instead (as noted by others here). Manticore has all of Sphinx’s features (plus others), and Thinking Sphinx works fine with it (it’s part of the CI setup).

There’s also specific releases at http://sphinxsearch.com/downloads/archive/ - I’d recommend 2.2.11.

For Manticore Search there is now a tap https://github.com/manticoresoftware/homebrew-tap and a PR to official brew was submitted (please note mysql@5.7 was used at compiling).

It’s gonna be fixed in Manticore within few weeks. Done in release 2.7.2 (https://manticoresearch.com/downloads/)

Yes, downgrading to MySQL 5.7 will fix that issue.

@azbshiri if you’re back on MySQL 5.7, you’ll likely need to compile Sphinx from source rather than Homebrew (unless there’s a way to tell Homebrew to use a specific version of MySQL as the dependency?)

This is how I compile (using OpenSSL installed by Homebrew) once the Sphinx code is downloaded:

# configure
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
./configure --with-mysql --with-pgsql --enable-id64
# compile
make -j4
# install
make install

Hi

It’s gonna be fixed in Manticore within few weeks. Here’s the issue https://github.com/manticoresoftware/manticoresearch/issues/89