﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27504	Cannot Make ORM Queries After an Error and Rollback In Non-autocommit Mode	Mark Young	nobody	"In non-autocommit mode, after an error has occurred (specifcally, IntegrityError and ValidationErrors are known to cause the issue, but I haven't fully investigated which errors can cause this), the db connection's needs_rollback attribute is set to True. When the flag is set to True, no further orm queries can be made to the database. Once this has happened, there appears to be no way to clean up the transaction, as a transaction.rollback() does not unset this flag.

An example failing scenario: 

{{{
    transaction.set_autocommit(False)
    r1 = Reporter.objects.create(first_name=""Archibald"", last_name=""Haddock"")
    r2 = Reporter(first_name=""Cuthbert"", last_name=""Calculus"", id=r1.id)
    try:
        r2.save(force_insert=True)
    except IntegrityError:
        transaction.rollback()
    # This raises a TransactionManagementError
    last_reporter = Reporter.objects.last()
}}}

This ticket is related to https://code.djangoproject.com/ticket/26340 and solves a subset of the scenarios affected by it.
"	Uncategorized	new	Database layer (models, ORM)	1.10	Normal				Unreviewed	1	0	0	0	0	0
