Opened 14 years ago
Closed 12 years ago
#14026 closed New feature (invalid)
Setting for TRANSACTION_LEVEL on db backends
Reported by: | Adam Nelson | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | tomasz.zielinski@…, gcbirzan@… | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
For DB backends, there should be a TRANSACTION_LEVEL settings.py variable that sets the transaction level for the database backend connection. For now, this would apply to MySQL (Ticket #13906)
Change History (9)
follow-up: 2 comment:1 by , 14 years ago
comment:2 by , 14 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Replying to sebastian_noack:
I have written in my blog about an issue raised due to wrong isolation level in MySQL.
http://www.no-ack.org/2010/07/mysql-transactions-and-django.html
You certainly can do this already with the OPTIONS key on the Database dictionary, see http://docs.djangoproject.com/en/dev/ref/settings/#options
To set ISOLATION LEVEL use something like {"init_command": "SET SESSION TRANSACTION ISOLATION LEVEL $DESIRED_ISOLATION_LEVEL"}
comment:3 by , 14 years ago
Easy pickings: | unset |
---|---|
Severity: | → Normal |
Type: | → Uncategorized |
The link to the OPTIONS docs is: http://docs.djangoproject.com/en/dev/ref/settings/#std:setting-OPTIONS
comment:4 by , 14 years ago
Cc: | added |
---|
comment:5 by , 13 years ago
Cc: | added |
---|---|
Resolution: | invalid |
Status: | closed → reopened |
Type: | Uncategorized → New feature |
UI/UX: | unset |
Version: | 1.2 → master |
This only works for MySQL. There should be a DB agnostic way of doing this. That should be split into two parts, a the config setting and the actual setting/fetching of isolation level.
follow-up: 7 comment:6 by , 13 years ago
FWIW I would find a feature allowing transaction isolation level settings per transaction/per session to be useful. Now, the setting would have to be database specific (there is absolutely no hope to guarantee similar behaving isolation levels cross-backend) and should come with a big warning that using any other isolation level than the default voids your warranty.
My main use-case would be SERIALIZABLE transactions in PostgreSQL 9.1+. The "true serializable" behavior is really nice if your application can use it.
comment:7 by , 13 years ago
Replying to akaariai:
FWIW I would find a feature allowing transaction isolation level settings per transaction/per session to be useful. Now, the setting would have to be database specific (there is absolutely no hope to guarantee similar behaving isolation levels cross-backend) and should come with a big warning that using any other isolation level than the default voids your warranty.
You can, even now, do that, for PostgreSQL. I was planning on implementing this by making sure all backends support the setting the serialisation level and using that. One could then also use a generic function for setting isolation, at whatever point.
My main use-case would be SERIALIZABLE transactions in PostgreSQL 9.1+. The "true serializable" behavior is really nice if your application can use it.
Yeah, that's what I want it for too. :-)
comment:8 by , 12 years ago
This ticket is getting confusing: the report says "this would apply to MySQL", a correct solution for MySQL is provided in the comments. Then it's re-openend, asking for something more generic.
For the sake of clarity, it'd be better to open a new ticket describing exactly what you want (if possible with a patch or pull request), and re-close this one. Otherwise I'm afraid your request will just stay buried here.
comment:9 by , 12 years ago
Resolution: | → invalid |
---|---|
Status: | reopened → closed |
I just discussed this with Andrew Godwin. He confirms that both init_command
and raw SQL can be used to control the isolation level.
If you want more, please explain it in more than one line :) A post to the django-developers mailing list would be best. Re-closing until then.
I have written in my blog about an issue raised due to wrong isolation level in MySQL.
http://www.no-ack.org/2010/07/mysql-transactions-and-django.html