Bug 8796

Summary: Remove all manual transaction management
Product: [Build System, Metadata & Runtime] Toaster Reporter: Michael Wood <michael.g.wood>
Component: toasterAssignee: Michael Wood <michael.g.wood>
Status: VERIFIED FIXED QA Contact: Mihail Stanciu <stanciux.mihail>
Severity: normal    
Priority: Medium CC: belen.barros.pena, jessica.zhang, stanciux.mihail
Version: unspecified   
Target Milestone: 2.1 M3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)
Bug Depends on:    
Bug Blocks: 8895    

Description Michael Wood 2015-12-11 18:06:41 UTC
Currently we have a lot of manual database transaction management code, after upgrading to Django 1.8 this seems to cause issues on MySQL. MySQL has a complicated way of dealing with transactions 

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=cb23e3043bf5c07f111787287a321df0ece647dd

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=ee1af30548a6ac3f243c9ee61f0988aa307c0c6b

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=e248a503ba84658dea086e65e9cde8b845b9c0ed

I don't think managing our own transactions was the right solution as we support multiple database backends which may have different versions and we may also have different versions of the database adapter, we should just avoid this entirely and leave Django to manage the transactions for us.

See also

https://docs.djangoproject.com/en/1.8/topics/db/transactions/

"MySQL transaction peculiarities are outside the scope of this article, but the MySQL site has information on MySQL transactions.http://dev.mysql.com/doc/refman/5.6/en/sql-syntax-transactions.html "

https://code.djangoproject.com/ticket/24921

"
 The ORM assumes that Django has control of the database connection, including control of its transactional behavior.

The docs make it pretty clear that you're on your own in that case:

    Once you turn autocommit off, you get the default behavior of your database adapter, and Django won't help you."

So in summary manual transaction management is a can of worms we don't want to nor should open.
Comment 2 Mihail Stanciu 2016-03-01 13:53:32 UTC
Verified while checking bug 9116.