Opened 10 years ago
Closed 10 years ago
#26299 closed Uncategorized (invalid)
Rollback bug on Postgres for multidb applications
| Reported by: | Silvio J. Gutierrez | Owned by: | nobody |
|---|---|---|---|
| Component: | Uncategorized | Version: | 1.9 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Hi there,
Was putting together a fairly straightforward multidb project:
- Most models go in db1
- Some models in a special app go to db2.
- 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
Change History (4)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
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.
comment:3 by , 10 years ago
Where do you think the documentation gap is? Is something missing in the section I linked?
comment:4 by , 10 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
Please open a new ticket if you believe any documentation is missing. Thanks!
Does adding multi_db = True to your
TestCasehelp?