[Django] #26299: Rollback bug on Postgres for multidb applications

25 views
Skip to first unread message

Django

unread,
Mar 1, 2016, 10:48:04 AM3/1/16
to django-...@googlegroups.com
#26299: Rollback bug on Postgres for multidb applications
---------------------------------+--------------------
Reporter: silviogutierrez | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------
Hi there,

Was putting together a fairly straightforward multidb project:

1. Most models go in db1
2. Some models in a special app go to db2.
3. Models from db2 don't ever communicate with db1.

Noticed that, in tests, rollbacks do not work for models in db2. I thought
it could be environmental, but I setup a very simple project to reproduce,
see https://github.com/silviogutierrez/django-multidb-bug

You just need to install the requirements, activate the virtual env and
run `python manage.py test --keepdb` *twice*. You'll notice the model
created in the test are not cleared.

Note that it is the `--keepdb` flag that triggers the bug, as uniqueness
constraints will fail for unique fields.

For the purposes of this demo, and just to reproduce this bug, I routed
all requests to db2.

Hope this helps someone. Oddly enough, I do see a rollback statement in my
DB logs, but it doesn't "take."

Thanks for an awesome project,

Silvio

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

Django

unread,
Mar 1, 2016, 10:56:16 AM3/1/16
to django-...@googlegroups.com
#26299: Rollback bug on Postgres for multidb applications
---------------------------------+--------------------------------------

Reporter: silviogutierrez | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.9
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
---------------------------------+--------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Does adding
[https://docs.djangoproject.com/en/dev/topics/testing/tools/#django.test.TransactionTestCase.multi_db
multi_db = True] to your `TestCase` help?

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

Django

unread,
Mar 1, 2016, 12:30:31 PM3/1/16
to django-...@googlegroups.com
#26299: Rollback bug on Postgres for multidb applications
---------------------------------+--------------------------------------

Reporter: silviogutierrez | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.9
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
---------------------------------+--------------------------------------

Comment (by silviogutierrez):

It does! That seems to fix it.

So is this a documentation gap then? Or should the rollback behavior
automatically apply based on the router?

Ideally the latter, I think, but even the former would help others avoid
this.

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

Django

unread,
Mar 1, 2016, 1:18:43 PM3/1/16
to django-...@googlegroups.com
#26299: Rollback bug on Postgres for multidb applications
---------------------------------+--------------------------------------

Reporter: silviogutierrez | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.9
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
---------------------------------+--------------------------------------

Comment (by timgraham):

Where do you think the documentation gap is? Is something missing in the
section I linked?

--
Ticket URL: <https://code.djangoproject.com/ticket/26299#comment:3>

Django

unread,
Mar 2, 2016, 7:46:33 AM3/2/16
to django-...@googlegroups.com
#26299: Rollback bug on Postgres for multidb applications
---------------------------------+--------------------------------------
Reporter: silviogutierrez | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 1.9
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 timgraham):

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


Comment:

Please open a new ticket if you believe any documentation is missing.
Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/26299#comment:4>

Reply all
Reply to author
Forward
0 new messages