Thursday, July 28, 2016

Re: Any way to force Django to commit a write so another process can read the correct data from DB?

Hi Mike,

It is not a bug.
It is just how it works.

Regards

On Thu, Jul 28, 2016 at 3:53 AM, Mike Dewhirst <miked@dewhirst.com.au> wrote:
On 28/07/2016 5:46 AM, Constantine Covtushenko wrote:
Hi Stodge,

As said in Django current version of documentation
<https://docs.djangoproject.com/en/1.9/ref/signals/#post-delete>,
'post_delete' signal is sent after record is deleted. This means also
that transaction is closed at that moment. And DB should not has deleted
instance any more.

I have double checked the Django code and can say that Django send that
signal just before transaction is committed.

Is this a Django bug?

Is it the same for post_save?

Mike

So technically instance should be inside DB for Hibernate processing.

I can suggest you to create a custom signal and send it after
transaction closed.
That should solve your problem.

Regards,

On Wed, Jul 27, 2016 at 5:27 PM, Stodge <stodge@gmail.com
<mailto:stodge@gmail.com>> wrote:

    My website uses a combination of Django + Java apps to function. For
    this particular problem, a record is deleted from the DB via a
    TastyPie resource DELETE operation. A Django signal post_delete
    handleris invoked, which submits a DELETE request to Jetty running
    in the Java app. The Java app then performs a query using Hibernate.

    What appears to be happening is that Django thinks the record was
    deleted:

    DynamicVolume.objects.filter(user=instance.user).count()

    Returns ZERO.

    However, the Java app thinks the record still exists unless I make
    it sleep for several seconds before asking Hibernate to query the DB.

    I've tried forcing Hibernate to clear its cache with no success. Is
    there a way to force Django to commit the deletion (flush the cache)?

    Thanks

    --
    You received this message because you are subscribed to the Google
    Groups "Django users" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to django-users+unsubscribe@googlegroups.com
    <mailto:django-users+unsubscribe@googlegroups.com>.
    To post to this group, send email to django-users@googlegroups.com
    <mailto:django-users@googlegroups.com>.
    Visit this group at https://groups.google.com/group/django-users.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/django-users/e76d5cfa-f4bc-41db-a322-0d44aa0719dd%40googlegroups.com
    <https://groups.google.com/d/msgid/django-users/e76d5cfa-f4bc-41db-a322-0d44aa0719dd%40googlegroups.com?utm_medium=email&utm_source=footer>.
    For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscribe@googlegroups.com
<mailto:django-users+unsubscribe@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAK52boWeFYGOhk0CL%2BoEimreb2k%2BgFwL2rBb0imoPbmfpwo5Yw%40mail.gmail.com
<https://groups.google.com/d/msgid/django-users/CAK52boWeFYGOhk0CL%2BoEimreb2k%2BgFwL2rBb0imoPbmfpwo5Yw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/450c40f7-8997-6669-b307-b39825d00adb%40dewhirst.com.au.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK52boUd%3D1-QiYBhA-284%3D-J-VZCiGKcnsmRs9Kpk%2BYtaff8ww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment