Code

Opened 4 years ago

Closed 23 months ago

#14026 closed New feature (invalid)

Setting for TRANSACTION_LEVEL on db backends

Reported by: adamnelson Owned by: nobody
Component: Database layer (models, ORM) Version: master
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)

Attachments (0)

Change History (9)

comment:1 follow-up: Changed 4 years ago by sebastian_noack

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

comment:2 in reply to: ↑ 1 Changed 4 years ago by craig.kimerer@…

  • Resolution set to invalid
  • Status changed from new to 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 Changed 3 years ago by graham_king

  • Easy pickings unset
  • Severity set to Normal
  • Type set to Uncategorized

comment:4 Changed 3 years ago by TomaszZielinski

  • Cc tomasz.zielinski@… added

comment:5 Changed 2 years ago by gcbirzan

  • Cc gcbirzan@… added
  • Resolution invalid deleted
  • Status changed from closed to reopened
  • Type changed from Uncategorized to New feature
  • UI/UX unset
  • Version changed from 1.2 to 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.

comment:6 follow-up: Changed 2 years ago by 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.

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 in reply to: ↑ 6 Changed 2 years ago by gcbirzan

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 Changed 23 months ago by aaugustin

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 Changed 23 months ago by aaugustin

  • Resolution set to invalid
  • Status changed from reopened to 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.