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
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
Callback code that happens to make use of $oldValue might not be able
to handle missing, new, or changed fields due to key version changes.
Overhaul testGetWithSetCallback_versions() to be cleaner and cover the
case of unversioned => versioned keys.
Change-Id: If108a73078c530c985d30bdadcbfa9ddd53dc2be
Use of microtime() is now just for baselines, and it is no longer
assumed to be increasing with each call. Such an assumption is
particuliarly bad on Windows.
I've done 100X run rounds with now failures on Windows.
Change-Id: Ica2a47982495bc95b10ca507414972744ea9507e
This simply involves passing it through to the set() call
Also added some related commons to adaptiveTTL() involving
usage of this option.
Change-Id: Id5833a5d4efb6cad2eb646832e5b0188e86e12fc
This stores values for very short times while the main
value is a tombstone in case of particularly high traffic.
Also make mutex keys expire immediately on unlock.
Change-Id: I4ec5cf7f8b49239fdd2518e5d955534877a0f7ee
class WANObjectCache (methods: 40% -> 67%, lines: 65% -> 88%)
* Allow indirect coverage of protected/private utility methods from
existing tests.
* Add basic test for setLogger().
* Add basic test for newEmpty().
* Add basic test for getQoS().
Change-Id: Ifb79ed2ff1febbd2f5477b8ed6319992ce88eb29
Reenable MediaWiki.WhiteSpace.SpaceBeforeClassBrace.NoSpaceBeforeBrace,
because the mentioned bug is fixed
Bug: T172933
Change-Id: I1593bdba2295ebed401b921f2beabed69dba7638
The used phpcs has a bug, so the version 0.9.0 could not be enforced at the moment.
Will be fixed in next version, see T167168
Changed:
- Remove duplicate newline at end of file
- Add space between function and ( for closures
- and -> &&, or -> ||
Change-Id: I4172fb08861729bccd55aecbd07e029e2638d311
Similar to what WANObjectCache and CachedBagOStuff are already doing.
Also add missing tests for WANObjectCache (similar to those for CachedBagOStuff).
Bug: T167465
Change-Id: I1a0c9324726aa6a1b221def985773b1b819181fd
Backend cache queries are now avoided if they are fresh in memory.
Also factor out some code into private methods for clarity.
Change-Id: Ib343fde3dbf63f39e8cb09eca6278811a7d9738b
The warmup cache was not properly prefixed and was also using the entity
IDs instead of the cache keys. Thus, it effectively just wasted a
getMulti() query and resulted in the usual separate GETs anyway.
Added some unit tests for this.
Change-Id: I75b7a31214b515511856f9d95db32e8881d80ccc
Replaces \TestingAccessWrapper (defined in core) with
\Wikimedia\TestingAccessWrapper (defined in the composer package
wikimedia/testing-access-wrapper).
See https://gerrit.wikimedia.org/r/#/q/topic:librarize-testing-access-wrapper
for downstream patches.
The core version of the class is kept around for a while to avoid
circular dependency problems.
Bug: T163434
Change-Id: I52cc257e593da3d6c3b01a909e554a950225aec8
The default will remain PHPUnit 4.x due to PHP 5.5 support.
But, we should allow developers to run tests with newer PHPUnit
versions which are noticably faster (especially for code coverage
reports).
* <https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-5.4.0>
PHPUnit 5 deprecates the getMock() shortcut for getMockBuilder()->getMock().
It instead introduces the shortcut createMock() which has better defaults
than getMockBuilder(). For example, it sets 'disableArgumentCloning' and
other things by default.
Going forward, code should either use getMockBuilder directly and configure
it using the setter methods (instead of the confusing variadic arguments
of getMock) or simply use the new minimalistic createMock method. This patch
backports the createMock method to MediaWikiTestCase so that we can start
using it.
Change-Id: I091c0289b21d2b1c876adba89529dc3e72b99af2
* This fixes keys based on some sort of change log.
Updates are wrapped in a mutex and keep track of the
last known good position.
* Make WANObjectReapUpdate class that cleans up title
related keys using the recentchanges table. This triggers
as a deferred updates on RC view.
Change-Id: I7f14b9ca2533032147e62b1a3cc004a23da86579
Causes HHVM 3.12.7 to segfault and or:
Fatal error: Stack overflow in includes/libs/objectcache/BagOStuff.php on line 754
This reverts commit b47ce21cec.
Bug: T150833
Change-Id: Ia52fdf65f5e386c0eaa1046328680fb5c8a9081a
This works by setting a callback to return the cache set
options. The callback will watch DB reads and create a
merged result from said usage.
This handles callers that are missing getCacheSetOptions().
Change-Id: Ia264f011e45e8cf105480955dad7e2c4c2357b73
Because the process cache can be lagged by virtue of blind TTL,
the HOLDOFF_TTL might not be enough to account for it, so avoid
using it when already inside a callback.
Also split of the tests from the MediaWiki test class, so this
does not require DB access anymore.
Change-Id: I743a1233a5efc7f036fad140a9ff8a30b32f8f27
Follows-up 24200e8, 37df4f8. Test coverage still broken.
> Trying to @cover not existing method
> "WANObjectCache::getMultitWithSetCallback".
Change-Id: Ie4c9a998ea352f93f3c7dcdea25ea5c017ffbab5
This does what it says on the tin, e.g. a way to fetch
multiple keys at once. Callbacks are still called in a
serial manner when needed.
Change-Id: I8e24a6de7f46499a53ec41636c5a4f106b9b3d09
This lets callers use adaptive TTLs on the near-expiration
preemptive refreshes if the new and current values match,
using the as-of time as $mtime.
Change-Id: Ie541c35f890c9f789d1accf9f2a43506daaf31f0
This lets callers have their own process cache but keep it
managed in a central location, making it easier to reset
when DB transaction snapshot are flushed or when unit tests
want to clear caches between runs.
Use this to replace the Revision text process cache.
Change-Id: Ic61ee9140d4ce9836cc4650adb5bb75a291fea18
Callers using wfTimestamp( TS_UNIX, ... ) where getting $minTTL
due to the output being a string number.
Change-Id: I6b67a941940f40ef9a543f11d0dbccacafaaa53b
* This better handles delayed/lost cache purges by
having lower TTLs for entries that often changes.
* Use this for foreign upload description page caches,
we purges are never received from the source wiki.
* Also use this for User and LocalFile cache TTLs.
* Also move the Database::getCacheSetOptions() call in
User *before* doing the queries, which is preferred.
* Fixed some IDEA errors too, like the undeclared
mApiBase field.
Change-Id: I70f8ebb29ac853c2a530d9eedb9e7facc1b7b710
* Update documentation about relay methods.
* Change interim key set() to add() to avoid broadcasting it.
* Remove the behavior of doing purges synchronously in the
local DC first before relay. In both the event relayer and
mcrouter case, they will be asynchronous. It was hardly
even possible to use such behavior since loads come from
slave DBs, which do not see changes right after COMMIT.
Bug: T97562
Change-Id: I7759c82ae6e1b72fc227882a99c9a712a46374f6
This is useful for avoiding stampedes in the one case that lockTSE
does not alone cover, which is when the key does not exist or is
tombstoned.
Also avoid saving interim values unless the key is tombstoned
since there is no point in doing that otherwise.
Change-Id: I70997e90217a0979e0589afa7a5107b0e623c7cf
* getWithSetCallback() takes a 'version' parameter.
* If the value at a key has a different version, then
getWithSetCallback() will automatically use a separate
key. Which value "wins" the main key does not matter.
* Purges are handled by using the main key as a sort of
check key (with no hold-off). Note that this key is always
purged on delete().
* Changed stash keys to track the same info as other keys
both for consistency and because this change needs the
generation timestamp. Renamed the stash prefix to avoid
corrupt results with Het Deploy.
* This is useful for things like the User class that use
versioning and have cross-wiki key access and purges.
Currently, bumps to version must be deployed to all wikis
at once, which this aims to avoid.
Change-Id: I26ae62f116e32b48bcf06bc13f8b9e79ae976745
If a set() happened around the exact same time as check key was
initialized via get(), the curTTL in future get() calls could
sometimes be 0 instead of a negative value, even though hold-off
should apply.
Change-Id: Ide1fd65112aff425a4798e2ec406d71f2a8e84a7