Search isn't searching, how to fix?

Summary

Search isn’t returning any results, despite doing something for a noticeable amount of time.

Steps to reproduce

Using the current Mac desktop client, and server 5.12.2, enter a term in the Search field, then hit Enter.

Expected behavior

Search results are returned.

Observed behavior

The “Searching…” and wait spinner appear in the Search Results panel. After ~30 seconds, “No results found. Try again?” This is for a term I can see on the screen. This fails for every term we’ve tried, other than literally the word “work” which returns results after a short delay.

The only relevant thing I can see in the logs is:

{“level”:“warn”,“ts”:1562590449.2580738,“caller”:“sqlstore/post_store.go:955”,“msg”:“Query error searching posts: pq: canceling statement due to user request”}

Is there some way to re-index the message database so Search works again? Is there something I can do to figure out why it’s failing?

Hi @Taffer, depending on if you use Postgres or Mysql, this doc might help: https://docs.mattermost.com/help/getting-started/searching.html#differences-between-mysql-and-postgres-search.

Not sure if you use Elasticsearch, but this doc might also help: https://docs.mattermost.com/deployment/elasticsearch.html.

Did this issue start to happen after you upgraded to v5.12?

I’m using Postgres as the back-end, and don’t have Elasticsearch installed.

I first noticed it in 5.10, but anecdotally it’s been broken for “a long time” on our server.

@Taffer For both this and the other issue you posted, it looks like it could be that your database server isn’t powerful enough. As we understand it, it’s unable to answer queries in time. This doc might help: https://docs.mattermost.com/install/requirements.html.

Thanks; when I spec’d out this VM, I used that document, but it’s possible things have changed since then. Going to do some Postgres tuning as well.

I’ve bumped the RAM and cores in our VM, both exceed the total requirements for running Mattermost and PostgreSQL, so hopefully this isn’t an issue now.

I’ve done some tuning of our PostgreSQL settings based on postgresqltuner hints.

Still no results for searches, other than this in the logs:

{"level":"warn","ts":1564152580.2032804,"caller":"sqlstore/post_store.go:955","msg":"Query error searching posts: pq: canceling statement due to user request"}

I guess the query is taking too long and the server cancels the request? Is there any way to configure this timeout?

@Taffer There is a query timeout setting in the System Console > Database: https://docs.mattermost.com/administration/config-settings.html#query-timeout

I’m also wondering what the timeout is configured on your Postgres database?