Thursday, October 22, 2015

Re: Locking / serializing access to one element in database

Am 22.10.2015 um 01:16 schrieb Simon Charette:
> I would suggest you use select_for_update()
> <https://docs.djangoproject.com/en/1.8/ref/models/querysets/#select-for-update> in a
> transaction.

This only covers the case where the object with the given ID already exists, doesn't it?

That is, if a new object is created in the except-clause, concurrent threads might
create a new object each, whereas it would presumably be expected that new_text is
(twice) added to a single common instance.

As I had the quasi exact same question a while ago (see
https://groups.google.com/forum/#!topic/django-users/SOX5Vjedy_s) but never got a reply,
I (too) am wondering how the new-object case in the except-clause could be handled?

Best regards,
Carsten

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5628EAD4.9090602%40cafu.de.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment