# no middleware that does any writes
# no decorators
def view(request, param):
# do some checking, no writes here
foo = Foo(user=request.user, param=param)
foo = Foo(user=request.user, param=param)
foo.save()
submit_background_task(foo.pk)
messages.success(request, "success message")
return HttpResponseRedirect
Before now, I assumed the foo.save() was a _blocking_ operation that did the following:
START TRANSACTION;
INSERT INTO TABLE foo(user_id, param) VALUES (?, ?);
COMMIT;
Which would allow you at any time, even 1 millisecond, after the save() to do the following and lookup the record:
SELECT * FROM foo WHERE id=<foo.pk>;
Isolation levels or whatever shouldn't matter in my mind, the SELECT is happening after the COMMIT. Do any of those assumptions strike you as wrong?
Chris
On Tuesday, May 28, 2013 3:43:38 PM UTC-4, Christophe Pettus wrote:
--
On May 28, 2013, at 12:20 PM, Chris Conover wrote:
> Well, you can inspect the object and see it's primary key. Surely that means the INSERT is completed?
That shows the INSERT is completed, but it doesn't show that any enclosing transaction has committed; that's what the database logs will show you. It's very unlikely that this is a bug in Django or MySQL; those are very well-trod paths in those two applications.
--
-- Christophe Pettus
x...@thebuild.com
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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment