Browse Source

add note about Django 1.6 transaction changes to userguide

See #2472.

Django 1.6 introduced a change to the tranasction model, switching to autocommit
by default and deprecating much of the old transaction API, with plans to
remove it completely in 1.8.

This commit adds a note to the userguide section that discusses race conditions
involving database transactions, pointing out the ramifications of the
example code in Django 1.6+
Anders Pearson 10 years ago
parent
commit
106b40b01e
1 changed files with 10 additions and 0 deletions
  1. 10 0
      docs/userguide/tasks.rst

+ 10 - 0
docs/userguide/tasks.rst

@@ -1548,6 +1548,16 @@ depending on state from the current transaction*:
             transaction.commit()
             expand_abbreviations.delay(article.pk)
 
+Note that Django 1.6 and later enable autocommit mode by default
+(deprecating `commit_on_success` and `commit_manually`), automatically
+wrapping each SQL query in its own transaction, avoiding the race
+condition by default and making it less likely that you'll encounter
+the above problem. However, enabling `ATOMIC_REQUESTS` on the database
+connection will bring back the transaction per request model and the
+race condition along with it. In this case, the simplest solution is
+just to use the `@transaction.non_atomic_requests` to switch it back
+to autocommit for that view.
+
 .. _task-example:
 
 Example