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)

comment:1 by Sebastian Noack, 14 years ago

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

in reply to:  1 comment:2 by craig.kimerer@…, 14 years ago

Resolution: invalid
Status: newclosed

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 Graham King, 13 years ago

Easy pickings: unset
Severity: Normal
Type: Uncategorized

comment:4 by Tomasz Zieliński, 13 years ago

Cc: tomasz.zielinski@… added

comment:5 by gcbirzan, 12 years ago

Cc: gcbirzan@… added
Resolution: invalid
Status: closedreopened
Type: UncategorizedNew feature
UI/UX: unset
Version: 1.2master

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.

comment:6 by Anssi Kääriäinen, 12 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.

in reply to:  6 comment:7 by gcbirzan, 12 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 Aymeric Augustin, 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 Aymeric Augustin, 12 years ago

Resolution: invalid
Status: reopenedclosed

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.

Note: See TracTickets for help on using tickets.
Back to Top