Bug #71667 Unit tests not able to start the MySQL instance to run the tests
Submitted: 11 Feb 2014 10:34 Modified: 28 Mar 2014 16:58
Reporter: Peeyush Gupta Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S3 (Non-critical)
Version:1.1.4 OS:Any
Assigned to: CPU Architecture:Any

[11 Feb 2014 10:34] Peeyush Gupta
Description:
The test suite is not able to start the MySQL Server instance to run the
tests.

PYTHONPATH=build/lib.linux-x86_64-2.7/ python unittests.py
--with-mysql=/usr/ --mysql-topdir=./mysql_myconnpy/ --verbosity=10
--bind-address=:: --host=::1

$ cat mysql_myconnpy/cpy_server1/bootstrap.log
140118 17:06:19 [ERROR] An old style --language value with language
specific part detected: /usr/share/mysql/english/
140118 17:06:19 [ERROR] Use --lc-messages-dir without language
specific part instead.
140118 17:06:19 InnoDB: The InnoDB memory heap is disabled
140118 17:06:19 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140118 17:06:19 InnoDB: Compressed tables use zlib 1.2.8
140118 17:06:19 InnoDB: Using Linux native AIO
/usr/sbin/mysqld: Can't create/write to file
'./mysql_myconnpy/cpy_server1/tmp/ibGc4rBM' (Errcode: 2)
140118 17:06:19  InnoDB: Error: unable to create temporary file; errno: 2
140118 17:06:19 [ERROR] Plugin 'InnoDB' init function returned error.
140118 17:06:19 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
ERROR: 1049  Unknown database 'mysql'
140118 17:06:24 [ERROR] Aborting

140118 17:06:24 [Note] /usr/sbin/mysqld: Shutdown complete
```

but the directory is there (and empty):

$ ls ./mysql_myconnpy/cpy_server1/tmp/ -ld
drwxr-xr-x 2 morph morph 6 Jan 18 17:06 ./mysql_myconnpy/cpy_server1/tmp/

How to repeat:
Run the unittests as follows:

PYTHONPATH=build/lib.linux-x86_64-2.7/ python unittests.py
--with-mysql=/usr/ --mysql-topdir=./mysql_myconnpy/ --verbosity=10
--bind-address=:: --host=::1
[19 Feb 2014 8:05] Peeyush Gupta
The problem is because of AppArmor, for more information you can see
https://blogs.oracle.com/jsmyth/entry/apparmor_and_mysql

In summary AppArmor restricts an application to use system resources.
In the mentioned case because of apparmor /usr/sbin/mysqld is not able
to create files inside tmp folder even when it has required permission.

To avoid this one of the three things can be done:
1> Update /etc/apparmor.d/usr.sbin.mysqld and add the path to the directory
where mysqld will write data
2> Disable apparmor for /usr/sbin/mysqld
3> change apparmor mode to complain form enforce for /usr/sbin/mysqld
[19 Feb 2014 12:47] Sandro Tosi
Hello,
I'm not using AppArmor on my machine, so it can't be (only) that preventing to start the test instance.

Regards,
Sandro
[19 Feb 2014 12:53] Peeyush Gupta
Can you tell me which OS(with version number) you are using?
[19 Feb 2014 12:55] Sandro Tosi
it's Debian Unstable (amd64, if it's worth to mention)
[25 Mar 2014 10:33] Geert Vanderkelen
Re-opening; this should not have been closed.
[27 Mar 2014 12:48] Geert Vanderkelen
This was a problem with relative directories when using the topdir command line argument. We did some more improvements to support system MySQL installation (thus not in it's on folder like /usr/local/mysql).
[28 Mar 2014 16:58] Paul DuBois
Fixed in 1.1.7.

Changes for test suite. No changelog entry needed.