Opened 8 years ago

Closed 8 years ago

#6763 closed (invalid)

Transactions don't work as per the documentation

Reported by: KayEss Owned by: nobody
Component: Uncategorized Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


The documentation here describes features of the transaction management, but there appears to be a fault which causes transactions not be managed correctly.

The following code should result in no database changes (the type of object created is not important - it can be anything).

from django.db import transaction
from django.http import HttpResponseRedirect
from bmf.core.models import *

def company_fail(request):
    ct = CompanyType() = "Charity"
    raise ValueError, 'Do not carry this out'

Executed as a view it raises an error page as expected, but the new CompanyType instance is still added to the database.

Using postgres 8.3 & psycopg 2-2.0.6 on Windows.

Change History (1)

comment:1 Changed 8 years ago by KayEss

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

We've tracked this down to the way that Postgres reports table statistics on some platforms/builds. An aborted transaction still counts the inserts so table statistics show more rows inserted than are in the table. The rolled back inserts are not counted as deletions so the row counts appear larger than they really are.

There does appear to be something up with commit_on_success, but we haven't managed to isolate that problem fully. Sometimes it seems to require an explicit rollback in order for the connection to continue to work. We'll file a separate ticket when we work it out.

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