#30636: mysqldump errors out with "unknown variable" when --parallel and
--defaults-file
-------------------------------------+-------------------------------------
     Reporter:  fallen               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by fallen:

Old description:

> What happens?
> Running tests gives:
> Creating test database for alias 'default'...
> Cloning test database for alias 'default'...
> mysqldump: unknown variable 'defaults-
> file=/var/lib/jenkins/workspace/Pytition_master/my.cnf'
> And then every test fails with 'E' (error).
>
> How to reproduce?
> 1/ Configure your database like this:
>
> {{{
> DATABASES = {
>     'default': {
>         'ENGINE': 'django.db.backends.mysql',
>         'OPTIONS': {
>             'read_default_file': '/path/to/my.cnf', # file with
> credentials and db name
>         },
>     }
> }
> }}}
>

> 2/ run tests with "manage.py test --parallel 2 appname"
> The important here is "--parallel 2" (or more than 2)
>
> Explanations?
>
> This happens because Django tries to clone the database using mysqldump:
> https://github.com/django/django/blob/master/django/db/backends/mysql/creation.py#L60
> In my case I've printed the arguments, it gives:
> dump_cmd: ['mysqldump', '--routines', '--events', '--defaults-
> file=/var/lib/jenkins/workspace/Pytition_master/my.cnf', 'test_']
> load_cmd: ['mysql', '--defaults-
> file=/var/lib/jenkins/workspace/Pytition_master/my.cnf', 'test__1']
> mysqldump: unknown variable 'defaults-
> file=/var/lib/jenkins/workspace/Pytition_master/my.cnf'
>
> However, it seems that, even if this is undocumented in mysqldump's man
> page, it does only support --defaults-file parameter when in first
> position.
>
> See the Note on this StackOverflow answer:
> https://stackoverflow.com/questions/10725209/specifying-separate-config-
> file-on-mysqldump-command-line
>
> Proposed solution:
> Test if read_default_file is in settings, and in this case put it as
> first argument to mysqldump

New description:

 What happens?
 Running tests gives:
 Creating test database for alias 'default'...
 Cloning test database for alias 'default'...
 mysqldump: unknown variable 'defaults-
 file=/var/lib/jenkins/workspace/Pytition_master/my.cnf'
 And then every test fails with 'E' (error).

 How to reproduce?
 1/ Configure your database like this:

 {{{
 DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.mysql',
         'OPTIONS': {
             'read_default_file': '/path/to/my.cnf', # file with
 credentials and db name
         },
     }
 }
 }}}


 2/ run tests with "manage.py test --parallel 2 appname"
 The important here is "--parallel 2" (or more than 2)

 Explanations?

 This happens because Django tries to clone the database using mysqldump:
 
https://github.com/django/django/blob/master/django/db/backends/mysql/creation.py#L60
 In my case I've printed the arguments, it gives:

 {{{
 dump_cmd: ['mysqldump', '--routines', '--events', '--defaults-
 file=/var/lib/jenkins/workspace/Pytition_master/my.cnf', 'test_']
 load_cmd: ['mysql', '--defaults-
 file=/var/lib/jenkins/workspace/Pytition_master/my.cnf', 'test__1']
 mysqldump: unknown variable 'defaults-
 file=/var/lib/jenkins/workspace/Pytition_master/my.cnf'

 }}}

 However, it seems that, even if this is undocumented in mysqldump's man
 page, it does only support --defaults-file parameter when in first
 position.

 See the Note on this StackOverflow answer:
 https://stackoverflow.com/questions/10725209/specifying-separate-config-
 file-on-mysqldump-command-line

 Proposed solution:
 Test if read_default_file is in settings, and in this case put it as first
 argument to mysqldump

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30636#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.b0d7ce98f271931e0b777df614214faf%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to