MatthiasLohr/munin-plugins-gitlab

gitlab_total_issues_*: schema "gitlab" does not exist

Closed this issue · 5 comments

I guess it's only me being stupid, but running the gitlab_total_issues_* plugins, I get the following error:

~# munin-run gitlab_total_issues_open
Traceback (most recent call last):
  File "/etc/munin/plugins/gitlab_total_issues_open", line 19, in <module>
    cursor.execute("SELECT COUNT(*) FROM gitlab.issues WHERE state = 'opened'")
psycopg2.ProgrammingError: schema "gitlab" does not exist
LINE 1: SELECT COUNT(*) FROM gitlab.issues WHERE state = 'opened'

But when trying to do the same thing, your plugin does, manually, it's working just fine:

~# su git
~# embedded/bin/psql --username=gitlab -h /var/opt/gitlab/postgresql gitlabhq_production
psql (9.2.10)
Type "help" for help.

gitlabhq_production=> SELECT COUNT(*) FROM gitlab.issues WHERE state = 'opened'
gitlabhq_production->

There's no output, 'cos there're no issues, yet - but at least I'm not presented an error, when doing it manually. Database and table do exist and user gitlab has access.

Running gitlab v8.1.2-ce.0 on Debian Jessie. I used their install-script and repo and didn't change any of their sql configuration. (Did add Mattermost, SSL and some other stuff, though..)

Hope, you can help - thanks in advance!

There's no output from your query because you missed the semicolon. Please try to execute it again:

SELECT COUNT(*) FROM gitlab.issues WHERE state = 'opened';

Please, also show the output from

SELECT DISTINCT(table_schema) FROM information_schema.tables;

and

SHOW search_path;

Ahhh.. See? I told you it's me being stupid.. ;)
Now it's displaying the very same error doing it manually as it does when running the plugin:

ERROR:  schema "gitlab" does not exist
LINE 1: SELECT COUNT(*) FROM gitlab.issues WHERE state = 'opened';
                             ^

The rest, you asked for:

gitlabhq_production=> SELECT DISTINCT(table_schema) FROM information_schema.tables;
    table_schema
--------------------
 information_schema
 pg_catalog
 public
(3 rows)
gitlabhq_production=> SHOW search_path:
gitlabhq_production-> (nothing)

Can you please investigate your database? Maybe there is another database created from the install script or the tables are in the public schema.

I'm sorry, I'm not used to the postgresql terminology, but yes, I guess they are at the "public schema", since there is nothing called gitlab, when listing the tables inside the database gitlabhq_production, but there is a table called issues.
So I removed the gitlab. part from your queries and it's looking good, so far.. (Still 0 issues, but that'll change soon.. ;) )
Thank you for your help!

With commit 6fa950a, i removed the schema name from the queries and added an option in plugin configurations for setting the search_path. I think this should finally solve your issue in a good way.