Wednesday, July 27, 2016

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

Hi Stodge,

As said in Django current version of documentation, '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.
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> 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.
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/e76d5cfa-f4bc-41db-a322-0d44aa0719dd%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 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/CAK52boWeFYGOhk0CL%2BoEimreb2k%2BgFwL2rBb0imoPbmfpwo5Yw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment