Avoid the ADD operation spam from all threads trying to access
a tombstoned key by checking the interim value cache timestamp.
This also avoids the GET/CAS spam from threads that manage to
get the mutex. If a single thread repeatedly accesses the same
tombstoned value in rapid succession, there will significantly
less cache operation spam.
Do the same for cache updates to keys in the holdoff state
due to "check keys" or the "touchedCallback" function.
Relatedly, fix getWithSetCallback() to disregard interim values
set prior to or at the same time as the latest delete() call.
This can slightly reduce the chance of the cache being behind
replica DBs for a second. It also avoids unit test failures
were a series of deletes and cache access happen at the same
timestamp (via time injection or regular system time calls).
In addition:
* Add PASS_BY_REF flag with backwards compatibility to avoid
bloating the signature of get()/getMulti() with the new
tombstone information needed for the above changes.
* Avoid confusing pass-by-reference in getInterimValue() and
fix use of incorrect $asOf parameter.
* Move some more logic into setInterimValue().
* Update some comments regarding broadcasted operations that
were not true for the currently assumed mcrouter setup.
* Rename $cValue => $curValue and $versioned => $needsVersion
for better readability.
Bug: T203786
Change-Id: I0eb3f9b697193d39a70dd3c0967311ad7e194f20
Instead, make the "high read lag with lockTSE" case just lower FLD_TTL.
This also avoids constant regenerations by threads getting the mutex.
Added logging for TTL adjustments in set() for the lockTSE case.
Also remove some delete() calls from tests that were not needed.
Change-Id: Id7695f0377235e4a2f6e0efc88e870c8a990c3b0
* Make the SET_DELAY_HIGH_SEC check more sensitive to other types
of delay, such as increased get() latency. Any such slowness is
relevant to the set() stampede concern.
* Also added a statsd timing metric for this delay.
Change-Id: I053a73b40dc7e566cc59fc97aeab1a4e1bee0f28
Follow-up to 70bf85d462 which only affected the case of tombstoned keys.
Improve documentation about getWithSetCallback() options.
Bug: T203786
Change-Id: I683a38f65a79cb98a4ae71cbc5dd88aefe48d022
* Remove 'channels' field references from config/setup
* Remove 'relayer'/'channels' field reference in unit tests
* Remove unused DEFAULT_PURGE_CHANNEL class constant
* Also remove long-since bogus 'pool' field references
Follow-up to 4753b0a4ed
Change-Id: If6670ff4e1dccc8ae253a08b46d205601da10024
The use of that class for WAN cache by third parties is extremely unlikely
and the approach was abandoned at WMF in favor of mcrouter (dynomite was
also considered preferable).
Change-Id: I328eb74f21c23db80acc5178bc3c9cf9f823da13
* Move $value === false checks to isValid()
* Rename $isTombstone variable to avoid confusion with the new value
* Reorganize conditionals around set() calls in doGetWithSetCallback()
* Skip getInterimValue() check when there is no reason to assume anything
might even be there (e.g. the key is not tombstoned)
* Fold the tombstone case for $useMutex into the ternary
Change-Id: I257110097cffe7fe87c6a9896e875f09d5c936d9
This largely follows-up 6b2f13b055.
* Make the comments and use of temporary variables easier to follow.
* Simplified some conditionals by remove redundant checks.
* Bypass the final set() call if $isTombstone is true. It will almost
always be rejected due to the tombstone still being there anyway, so
there is no point in the roundtrips. Also, the most likely case where
it would succeed is due to the callback taking a long time to run, in
which case data from the replication lag uncertainty period that the
tombstone represents would be getting saved to cache with the full
nominal TTL, which is wrong.
Change-Id: Ic28e15b24f39e128bd72ad4d905edb852bc907aa
This is useful when the timestamps to be checked depend on the value or are stored
in the database rather than as check keys.
Change-Id: I81ab08a943ee7d2f96a132d371965501941ed37f
Also add headings to separate docs for deployment/administration,
from docs for developers using an existing instance of it.
Change-Id: Id43c7700564c2979549afa5379f644027fb6585b
This can be used to discard all values before a certain point in
time, such as periods of severe network problems or misconfiguration
that resulted in missed purges.
Change-Id: I612db8f91a5960b912e9f35645a3d3872df47460
This will usually let one distinguish asynchronous preemptive cache refreshes
from synchronous value recomputations due to actual cache misses.
Change-Id: I3424a89cc96a12fe283460eeaf722ee0cf299534
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '
(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)
Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).
Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
The 'pool' parameter was removed in commit 09a0a5e4f6 (change
I5631eb1b13), retaining it in this helper method just confuses people
who read the code.
Change-Id: I7907a1fc4c613362d74e9045bc7dc41bbd9bf815
Also removed useless line from testLockTSE(). That would have needed
to be using $this->internalCache and those locks are freed immediately.
Bug: T180035
Change-Id: Ida1a923f779aaf8410da76643457d2200da6cb20