Bug 726150

Summary: bacula-dir.conf for mysql support should not point to QueryFile with bad SQL commands
Product: [Fedora] Fedora Reporter: Edouard Bourguignon <madko>
Component: baculaAssignee: Andreas Thienemann <andreas>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 15CC: andreas, dnovotny, fedora, fschwarz, hhorak, limburgher, mmcgrath, negativo17, vanmeeuwen+fedora
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-07-18 05:29:32 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:

Description Edouard Bourguignon 2011-07-27 12:56:39 EDT
Description of problem:
bacula-dir.conf from bacula-dir-mysql indicates as a QueryFile the /etc/bacula/query.sql which seems to contains sample SQL commands. This commands are preventing bacula-dir to collect its catalog.

Version-Release number of selected component (if applicable):
bacula-common-5.0.3-9.fc15.x86_64
bacula-director-mysql-5.0.3-9.fc15.x86_64
bacula-director-common-5.0.3-9.fc15.x86_64
bacula-storage-common-5.0.3-9.fc15.x86_64
bacula-console-5.0.3-9.fc15.x86_64
bacula-storage-mysql-5.0.3-9.fc15.x86_64

How reproducible:
static

Steps to Reproduce:
1. Manually start bacula-dir (cf bug #726147)
2. run bconsole
3. try any command depending on catalog access (ie list, run etc)
  
Actual results:
*list
Could not open catalog database "bacula".
mysql.c:194 Unable to connect to MySQL server.
Database=bacula User=bacula
MySQL connect failed either server not running or your authorization is incorrect.

Expected results:
bacula-dir should be able to retrieve its catalog


Additional info:
Changing QueryFile to a even non existent file correct this problem.
Comment 1 Honza Horak 2011-08-08 12:20:03 EDT
It seems like your mysql database configuration is not correct. Try to connect to mysql using user bacula and show all tables:

$ mysql -u bacula -p
  myslq> use bacula;
  mysql> show tables;

Correct result:
Tables_in_bacula
BaseFiles
CDImages
Client
...
...
Comment 2 Edouard Bourguignon 2011-08-08 12:40:16 EDT
Content of query.sql:
#
# See the file <bacula-source>/examples/sample-query.sql
#  for some sample queries.
#
# 1
:The default file is empty, see <bacula-source>/examples/sample-query.sql for samples
SELECT 'See <bacula-source>/examples/sample-query.sql for samples' AS Info;

How the line starting if : and not ending with ; could be a valid sql query? The last line is ok and do nothing. So even if this file was correct (I don't know may be it is), it's useless. Removing the  QueryFile in bacula-dir.conf fix the problem, so if Bacula is working fine and storing cataly in MySQL I can say my database is ok. Or I miss something?

But here is the result of the show tables:

mysql> show tables;
+------------------+
| Tables_in_bacula |
+------------------+
| BaseFiles        |
| CDImages         |
| Client           |
| Counters         |
| Device           |
| File             |
| FileSet          |
| Filename         |
| Job              |
| JobHisto         |
| JobMedia         |
| Location         |
| LocationLog      |
| Log              |
| Media            |
| MediaType        |
| Path             |
| PathHierarchy    |
| PathVisibility   |
| Pool             |
| Status           |
| Storage          |
| UnsavedFiles     |
| Version          |
+------------------+
24 rows in set (0.00 sec)

Is it ok?
Comment 3 Honza Horak 2011-08-09 09:17:35 EDT
(In reply to comment #2)
> Content of query.sql:
> ...
> :The default file is empty, see <bacula-source>/examples/sample-query.sql for
> samples
> SELECT 'See <bacula-source>/examples/sample-query.sql for samples' AS Info;
> 
> How the line starting if : and not ending with ; could be a valid sql query?

This file is parsed by bacula-dir before executing in mysql. ':' and '*' are characters with special meaning, so this is intentional and probably right.

> mysql> show tables;
> +------------------+
> | Tables_in_bacula |
> +------------------+
> | BaseFiles        |
> ...
> | Version          |
> +------------------+
> 24 rows in set (0.00 sec)
> 
> Is it ok?

It seems ok, have you been connected to mysql using bacula user? I still suspect mysql, at least error message in comment #0 speaks clear: "Unable to connect to MySQL server."

You've mentioned you run bacula-dir directly, not with systemd/init script - so you run it under root, but bacula-dir is usually run under bacula user.
Comment 4 Edouard Bourguignon 2011-08-09 13:46:53 EDT
Here is how I manually start bacula:

bacula-dir -c /etc/bacula/bacula-dir.conf -v -f -u bacula -g bacula

I don't run it under but as you said under bacula user. But I also try under root same problem. I have no choice to run it directly because systemd/init script is not working. 
As I said if I comment the QueryFile line in bacula-dir.conf it's working fine so... my main concern is bug #726147