#21597: (2006, 'MySQL server has gone away') in django1.6 when wait_timeout 
passed
-------------------------------------+-------------------------------------
     Reporter:  ekeydar@…            |                    Owner:  aaugustin
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  1.6
  (models, ORM)                      |               Resolution:  wontfix
     Severity:  Release blocker      |             Triage Stage:  Accepted
     Keywords:  mysql                |      Needs documentation:  0
    Has patch:  1                    |  Patch needs improvement:  1
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------
Description changed by aaugustin:

Old description:

> '''EDIT -- THE SOLUTION TO THIS PROBLEM IS EXPLAINED IN
> [https://code.djangoproject.com/ticket/21597#comment:29 COMMENT 29]. JUST
> DO WHAT IT SAYS. THANK YOU!'''
>
> ----
>
> In django 1.6, when the wait_timeout passed (of mysql), then DB access
> cause the (2006, 'MySQL server has gone away') error.
> This was not the case in django 1.5.1
>
> I've noticed this error when using workers that run the django code
> (using gearman).
>
> To reproduce:
>
> Set the timeout to low value by editing /etc/mysql/my.cnf
> add the following under [mysqld]
>
> wait_timeout    = 10
> interactive_timeout = 10
>
> Then
>
> {{{
> % python manage.py shell
>
> >>> # access DB
> >>> import django.contrib.auth.models
> >>> print list(django.contrib.auth.models.User.objects.all())
> >>> import time
> >>> time.sleep(15)
> >>> print list(django.contrib.auth.models.User.objects.all())
> }}}
>
> Now you get the error.
>
> Simple solution I found on the web is to call
> django.db.close_connection() before the access
>
> {{{
> >>> import django.db
> >>> django.db.close_connection()
> >>> print list(django.contrib.auth.models.User.objects.all())
> }}}
> works ok.

New description:

 '''EDIT -- THE SOLUTION TO THIS PROBLEM IS EXPLAINED IN
 [https://code.djangoproject.com/ticket/21597#comment:29 COMMENT 29]. JUST
 DO WHAT IT SAYS. THANK YOU! '''

 ----

 In django 1.6, when the wait_timeout passed (of mysql), then DB access
 cause the (2006, 'MySQL server has gone away') error.
 This was not the case in django 1.5.1

 I've noticed this error when using workers that run the django code (using
 gearman).

 To reproduce:

 Set the timeout to low value by editing /etc/mysql/my.cnf
 add the following under [mysqld]

 wait_timeout    = 10
 interactive_timeout = 10

 Then

 {{{
 % python manage.py shell

 >>> # access DB
 >>> import django.contrib.auth.models
 >>> print list(django.contrib.auth.models.User.objects.all())
 >>> import time
 >>> time.sleep(15)
 >>> print list(django.contrib.auth.models.User.objects.all())
 }}}

 Now you get the error.

 Simple solution I found on the web is to call django.db.close_connection()
 before the access

 {{{
 >>> import django.db
 >>> django.db.close_connection()
 >>> print list(django.contrib.auth.models.User.objects.all())
 }}}
 works ok.

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21597#comment:37>
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/075.44281cefcc243a45709dfe728bb29669%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to