objectcache: fix race conditions in RedisBagOStuff::incr()
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 12 Jul 2019 15:29:10 +0000 (08:29 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 13 Jul 2019 23:33:21 +0000 (23:33 +0000)
commit7e647d2f0f5ba9d4837f2a1626ec402e925bf722
treeefb3cca214658547b957ce91fbf9b6af8ce8a3bd
parent5209b053541517073e669ff8584e0508bf8f5b06
objectcache: fix race conditions in RedisBagOStuff::incr()

The exist() check was not atomic, so a non-expiring TTL could be
make by mistake on race conditions. Use the redis WATCH command
for CAS-style atomicity of the exists()/incrBy() cycle.

Also optimized RedisBagOStuff::incrWithInit().

Change-Id: Ia003e054a41d4b4bbe73508e39d6606d8cc47291
includes/libs/objectcache/RedisBagOStuff.php