[Django] #33222: MySQL Connection respawns a closed connection before closing (?)

4 views
Skip to first unread message

Django

unread,
Oct 22, 2021, 12:24:09 PM10/22/21
to django-...@googlegroups.com
#33222: MySQL Connection respawns a closed connection before closing (?)
-------------------------------------+-------------------------------------
Reporter: Yuta | Owner: nobody
Okamoto |
Type: Bug | Status: new
Component: Database | Version: 3.1
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I found that `is_usable()` method for MySQL, which is used in
`close_if_unusable_or_obsolete()`, calls `ping()` method implemented in
PyMySQL.

-
https://github.com/django/django/blob/306607d5b99b6eca6ae2c1e726d8eb32b9b2ca1b/django/db/backends/base/base.py#L528

But it has `reconnect` as a parameter and its default is `True`, so it
seems it automatically reconnects to the DB even when the original
connection is unusable and will be closed right after the reconnection.

-
https://github.com/PyMySQL/PyMySQL/blob/78f0cf99e5d5351df0821442e4dc35c49a6390c6/pymysql/connections.py#L561

Is it the intentional behavior or not?

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

Django

unread,
Oct 22, 2021, 1:01:53 PM10/22/21
to django-...@googlegroups.com
#33222: MySQL Connection respawns a closed connection before closing (?)
-------------------------------------+-------------------------------------
Reporter: Yuta Okamoto | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

Django officially supports and recommends `mysqlclient` not `PyMySQL`. As
far as I'm aware `mysqlclient` doesn't
[https://github.com/PyMySQL/mysqlclient/blob/204fb123683454cdb670e0065f09e50d425b94c8/MySQLdb/_mysql.c#L1806-L1809
reconnect by default].

--
Ticket URL: <https://code.djangoproject.com/ticket/33222#comment:1>

Django

unread,
Oct 22, 2021, 1:11:51 PM10/22/21
to django-...@googlegroups.com
#33222: MySQL Connection respawns a closed connection before closing (?)
-------------------------------------+-------------------------------------
Reporter: Yuta Okamoto | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Yuta Okamoto):

Ok, thanks for correcting my misunderstanding!

--
Ticket URL: <https://code.djangoproject.com/ticket/33222#comment:2>

Reply all
Reply to author
Forward
0 new messages