--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/a6077f33-1113-4767-828c-8b2c0c77bd78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
If you do what Simon and I suggest, you should get the result you just described. If you don’t, please explain what happens.
Within a transaction — and disabling autocommit means you’re within a transaction — transaction.atomic() uses savepoints.
Note that in Django 1.6, after set_autocommit(False), you couldn’t use transaction.atomic(). That was fixed in 1.8 (I think).
--Aymeric.
On 04 Mar 2016, at 21:21, Tore Lundqvist <t...@mima.x.se> wrote:
Hi, SimonNo, I would need to wrap everything i a atomic block to start the transaction and it's only when that outermost atomic block exits that I actually get a commit the nested ones just makes save point./Tore
Den fredag 4 mars 2016 kl. 21:09:17 UTC+1 skrev charettes:Hi Tore,
Is there a reason you can't simply wrap your updates in a `transaction.atomic()` blocks?
You should be able to avoid deadlocks and control exactly when data is written to disk
with this construct.
Simon
Le vendredi 4 mars 2016 15:02:45 UTC-5, Tore Lundqvist a écrit :Reply to comments in ticket: https://code.djangoproject.com/ticket/26323#comment:10Hi,@Aagustin: I get your point but in the code I'm working on there is a lot of transaction.commit(), not to handle transactions but to manage when data is written to disk and to avoid deadlocks. Running in autocommit mode does not work, its slow and sometimes the commits is used to save in a known good state. So I disable autocommit with transaction.set_autocommit(False) and run the code with explicit commits in it and than turn autocommit on again.The documentation for set_autocommit says "Once you turn autocommit off, you get the default behavior of your database adapter, and Django won’t help you." That is what I want and thats way I think that the TransactionManagementError should not de raise if your not using atomic blocks.--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsub...@googlegroups.com.
--Aymeric.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/a6077f33-1113-4767-828c-8b2c0c77bd78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/79611d30-21e0-45bc-8ab7-8754a39db4fc%40googlegroups.com.
--Aymeric.
To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsub...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/a6077f33-1113-4767-828c-8b2c0c77bd78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On 07 Mar 2016, at 12:55, Tore Lundqvist <t...@mima.x.se> wrote:
an example of when it happens is when:Starting with auto commit on.transaction.set_autocommit(False)... a lot of time passes without the connection being used so it times out....close_old_connections()
Now autocommit is on again. I'm not saying that it's a bug, but it's inconvenient.
The problem is that the legacy code uses COMMIT side effects to manage disk writes and avoid deadlocks, securing an adequate transactional integrity is often not an issue.
So I'm trying to disable or at least use as little as possible of Djangos transaction management for this code.
Specifically, could you try adding `self.needs_rollback = False` at the bottom of the `BaseDatabaseWrapper.rollback()` and tell me if that helps?
On 07 Mar 2016, at 12:55, Tore Lundqvist <t...@mima.x.se> wrote:an example of when it happens is when:Starting with auto commit on.transaction.set_autocommit(False)... a lot of time passes without the connection being used so it times out....close_old_connections()There’s a long discussion of this use case here: https://code.djangoproject.com/ticket/21597.Now autocommit is on again. I'm not saying that it's a bug, but it's inconvenient.This surprises me. The connection shouldn’t reopen at all. It should become unusable, for the reasons explained in that issue (ticket 21597).
Given MySQL’s interesting approach to transactional integrity, you can call transaction.set_rollback(False) after a query that failed with an IntegrityError and keep going.
Given MySQL’s interesting approach to transactional integrity, you can call transaction.set_rollback(False) after a query that failed with an IntegrityError and keep going.You can't use set_rollback() outside an atomic block so that not an option for me.
You can use atomic just over the section that causes the error. The issue is that different db engines have different semantics under error during transaction. Rolling back to the last savepoint (as atomic does when nested) recovers the ability to complete the remainder of the transaction. With a savepoint to roll back to, in some DBs, the full transaction is lost.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/a8daaa98-f66a-40e5-bb4d-c0d4ad647f70%40googlegroups.com.
I can't use atomic blocks