Query stuck in mattermost postgresql communication Ubuntu 18.04
PostgreSQL 10.10
Mattermost 5.15

On mattermost startup process stay forever on 


  {"level":"info","ts":1570609055.2422519,"caller":"sqlstore/supplier.go:223","msg":"Pinging
  SQL master database"}


Running this query

SELECT pid, age(clock_timestamp(), query_start), usename, query, state
FROM pg_stat_activity
WHERE query != '' AND query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;


Gives me 

 pid  |      age       | usename |         query         | state
------+----------------+---------+-------------------------------
 8700 | 00:08:54.84669 | mmuser  | SELECT * FROM Systems | idle


From there, how do I diagnose what makes this query never end ?
The query has already ended 9 minutes ago. PostgreSQL is sitting idle and waiting for the next statement on this connection, which isn't coming.

The block must be somewhere else in your startup process.