﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33537	Cloning test databases should reraise errors on MySQL.	Stephen Finucane	Mariusz Felisiak	"I've been seeing the following error message when attempting to run tests in parallel using a MySQL backend:

{{{
py36-django22 run-test-pre: PYTHONHASHSEED='1711093702'
py36-django22 run-test: commands[0] | python /home/patchwork/patchwork/manage.py test --noinput --parallel -- patchwork
mysqldump: Couldn't execute 'SELECT COLUMN_NAME,                       JSON_EXTRACT(HISTOGRAM, '$.""number-of-buckets-specified""')                FROM information_schema.COLUMN_STATISTICS                WHERE SCHEMA_NAME = 'test_patchwork' AND TABLE_NAME = 'auth_group';': Unknown table 'COLUMN_STATISTICS' in information_schema (1109)
mysqldump: Couldn't execute 'SELECT COLUMN_NAME,                       JSON_EXTRACT(HISTOGRAM, '$.""number-of-buckets-specified""')                FROM information_schema.COLUMN_STATISTICS                WHERE SCHEMA_NAME = 'test_patchwork' AND TABLE_NAME = 'auth_group';': Unknown table 'COLUMN_STATISTICS' in information_schema (1109)
System check identified no issues (0 silenced).
Creating test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
...
}}}

This is followed by a lot of test failures due to missing databases.

In my instance, I traced this back to the fact that I was using `mariadb-server` with `mysql-client` rather than `mariadb-server`. Switching the client packages resolved the issue. However, posts on StackOverflow suggest the same issue can occur when using older MySQL servers (5.7?) that don't provide these statistics with newer clients so it's not as clear cut as this.

I'm not sure there's much to be done here from a Django perspective. We could arguably add the `-column-statistics=0` flag to the `mysqldump` call (in `django.db.backends.mysql.creation.DatabaseCreation._clone_db`), but this is not compatible with the version of this tool provided by `mariadb-client`. We might also want to make this a more serious error and fail the test run rather than attempt to proceed, obscuring the failure in the process (this could conceivably get flaky if you had a mix of DB and non-DB tests running in different runner instances). Perhaps the best thing to do here is close this and leave it here as a breadcrumb for others that run into the issue."	Cleanup/optimization	closed	Database layer (models, ORM)	4.1	Normal	fixed		Sage Abdullah	Ready for checkin	1	0	0	0	0	0
