More MessageCache locking/update cleanups
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 27 Aug 2015 08:46:05 +0000 (01:46 -0700)
committerOri.livneh <ori@wikimedia.org>
Wed, 2 Sep 2015 22:41:18 +0000 (22:41 +0000)
commit89a167b500dc857f9def03bd83d951161d312d4d
treec380b7b672a19e8a30ec79382ef5ad558cd4c25a
parentb5910ec960e783726cc3a6ae7c01d7d1dc2ed2ee
More MessageCache locking/update cleanups

* Made the status key only act as a backoff key inside
  loadFromDBWithLock(), instead of also being a lock key. The
  getReentrantScopedLock() call is now non-blocking, which has
  a similar affect to the add() call on the status key but much
  better prioritizes replace(); that method already has a blocking
  getReentrantScopedLock() call, so once it gets that lock, there
  is no worry of load() failing due to contention.
* Bail out in loadFromDBWithLock() if the scope lock was not acquired.
  Normally the status lock often assured the lock could be obtained,
  unless a competing replace() came in. The old status lock would
  cause a bail if not acquired, and this carries over that behavior
  but also avoids clobbering updates when replace() contention happens.
* Avoid calling saveToCaches() in replace() if the lock was not
  acquired to avoid clobbering conflicting writes.
* Made the loadFromDB() call in replace() use DB_MASTER to avoid
  seeing stale data if the cache is volatile.
* Lowered WAIT_SEC, as the default PHP timeout is 30.
  We want this to be able to at least finish the other calls
  in replace() even if the lock times out.
* Avoid checking the status key an extra time in load().
* Made a few small code and doc cleanups.

Change-Id: Ibaf1f67618ec374c83c3135a71e90223dd2b1856
includes/cache/MessageCache.php