Hello, I'm having an issue looking up objects immediately after they are saved and am wondering if anyone has any advice on how to address the problem. Specifically, I'm saving an object in a view (nothing fancy, a simple save()) and then kicking off a Gearman task to do some operations on that saved object in the background. I pass the newly created object's PK as data to the Gearman worker which then does a simple Objects.objects.get(pk=PK). However, almost all of the time this lookup operation fails with an DoesNotExist exception. I believe the problem has to do with transactions. Namely, the read in the Gearman worker is happening before the write from the view is committed to the database. I've tried several things including refactoring the saving code to be wrapped in a @transaction.commit_on_success block, moving the worker submission to post_save and adding a long delay before the Gearman worker does the lookup. Nothing really seems to solve the problem completely. Even with a 60 second delay, the lookup fails with some frequency. Am I missing something here? Is there some Django query cache that I can clear? Or should I just rewrite all this to just to use a look-back perspective.
The stack is Django 1.4 connecting to MySQL 5.5.27. Django is handling 200-1000 requests per second and the database is handling about double that. Thanks, Chris -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.