Changes between Initial Version and Version 2 of Ticket #26332


Ignore:
Timestamp:
03/07/2016 04:36:39 AM (6 years ago)
Author:
Przemysław Suliga
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #26332 – Description

    initial v2  
    11[https://github.com/django/django/blob/2109975e901440da70e29d0f330a600bc2d37e9a/django/core/cache/backends/base.py#L150-L169 BaseCache.get_or_set()] returns `False` if the key was set in cache between the first `.get()` and `.add()`.
    22
    3 The reason for using `.add()` instead of `.set()` in there is a "big race condition" as stated in [https://code.djangoproject.com/ticket/12982 12982]. However, it is very unlikely that the caller will pass a `default` callable that reads the key from the cache and returns a result that depends on the value currently stored in cache which would be a prerequisite for a race condition to occur. Using `set()` as originally stated in the description of [https://code.djangoproject.com/ticket/12982 12982] means that there will be a ''data race'' which doesn't affect the correctness of the program, because the result is that multiple writes happened, but all of them are correct.
     3The reason for using `.add()` instead of `.set()` in there is a "big race condition" as stated in #12982. However, it is very unlikely that the caller will pass a `default` callable that reads the key from the cache and returns a result that depends on the value currently stored in cache which would be a prerequisite for a race condition to occur. Using `set()` as originally stated in the description of #12982 means that there will be a ''data race'' which doesn't affect the correctness of the program, because the result is that multiple writes happened, but all of them are correct.
    44
    55Following texts contain a nice explanation of what is a race condition and how it relates to a data race:
Back to Top