aboutsummaryrefslogtreecommitdiffstats
path: root/includes/libs/objectcache
Commit message (Collapse)AuthorAgeFilesLines
...
* objectcache: Remove deprecated unused method from BagOStuff classDerick Alangi2024-07-061-27/+0
| | | | | | | This was already hard deprecated and unused, since 1.42. Time for it to go. Farewell `setNewPreparedValues()`. Change-Id: I95c8e4ba91187348603515df2b453d4a11623b99
* objectcache: Remove unused key (`$i`) in `foreach()` loopDerick Alangi2024-07-051-1/+1
| | | | | | | | | | | | | | | | | | | | In I6b3167cac824d8bd8773bc66c386f41e4d380021 (75aec3686a2e3f4d0), awesome Krinkle did some huge refactor of the BagOStuff parent and subclasses to reduce boiler plate and indirection logic around the `makeKey()` method. In the process of doing that, the key that was previously used in the foreach() loop in the `makeKeyInternal()` method was no longer used. The main intention of the `$i` was to append a colon(:) delimiter infront of the keyspace before concatenating the various components values to construct a cache key for the given keyspace and components. Now that it's been handled differently, it's time to say farewell to the `$i`. Change-Id: I03a4b85509a9b841b05d000afb6242f91e06d9be
* objectcache: inject the timestamp into WANObjectCache::fetchKeys()Aaron Schulz2024-07-031-8/+9
| | | | | | | | This avoids an extra method call and makes time calculations consistent. For very low TTL keys, this approach is a less pathological when cache server latency increases, since values will not count as expired so easily. Change-Id: I99a6cd582a729a16e8b28019613a0d73b239b077
* Add namespace and deprecation alias to MultiHttpClientEbrahim Byagowi2024-05-201-0/+1
| | | | | | | | | This patch introduces a namespace declaration for the Wikimedia\Http to MultiHttpClient and establishes a class alias marked as deprecated since version 1.43. Bug: T353458 Change-Id: I4ebc1a3b496de08b2b430301da376578d13fcfe6
* Remove auto-generated "Class ClassName" commentsthiemowmde2024-05-061-3/+0
| | | | | | | | This is most certainly auto-generated by some IDEs. Unfortunately there is nothing to learn from such comments. It's just noise. Especially in tests. Change-Id: Idf59332d96ca4718b6ce9d17b4da79a88641d4fd
* objectcache: Drop SerializedValueContainer::isUnifiedDerick Alangi2024-04-231-22/+3
| | | | | | | | | | | This method was deprecated in 1.42 and now can be dropped from MW core. In addition, some cosmetic changes in this patch: * Type-hint `isSegmented()` to return bool. Bug: T344521 Change-Id: Idace008e9a961953041bd21b499bfec3f8226142
* objectcache: remove deprecated QOS_EMULATION_SQL constantAaron Schulz2024-03-271-3/+0
| | | | Change-Id: I8dec3f73faec44a00ef12614039c323dd07b695f
* objectcache: Deprecate `SerializedValueContainer::isUnified()`Derick Alangi2024-03-192-4/+5
| | | | | | | | | | Since the method for constructing a serialized value container via `newUnified()` has been removed in Id5179be032d45732db659d506d2781, its corresponding `isUnified()` method is now obsolete and this patch deprecates it to be removed in 1.43. Bug: T344521 Change-Id: I5a90028c2a596dfec9a1df306cc9d0ab90dfedd6
* Merge "objectcache: Drop `SerializedValueContainer::newUnified()`"jenkins-bot2024-03-181-13/+0
|\
| * objectcache: Drop `SerializedValueContainer::newUnified()`Derick Alangi2024-03-181-13/+0
| | | | | | | | | | | | | | | | This patch deletes the `::newUnified()` method from this class, it's already hard deprecated and due for removal. Bug: T344521 Change-Id: Id5179be032d45732db659d506d2781752f03f8be
* | Fix some spelling errorsTim Starling2024-03-182-3/+3
|/ | | | Change-Id: I3632ce1ae00527f806652deb96cafb473aed3dcf
* build: Fix line indentsUmherirrender2024-03-111-3/+3
| | | | | | | Fixed SkinModuleTest::provideGetFeatureFilePathsOrder as nesting of arrays for parameters is wrong Change-Id: I9875008adf62d284c48662ebfbd245d72e5be064
* objectcache: Migrate BagOStuff from StatsdD to StatsLibDerick Alangi2024-02-272-29/+55
| | | | | | | | | | | | | | | | | | | | | | | This patch migrates BagOStuff metrics capture from StatsdD to StatsLib. `updateOpStats()` definition significantly changed with this migration thereby affecting the changes in the test case. What we tried to do in the test is to assert that the metrics match the StatsLib equivalent ones which is the new format we're using and that the values corresponding to the samples are also in the range of values written to the cache. Notes ===== * And the cache key also uses underscore (_) instead of (.) because of StatsLib as well. * The most important thing which is tested is that the keys inserted into the cache are all there and correspond to their values. The way we do this is observe the metrics stream after `->flush()`. Bug: T356062 Change-Id: Ia6c14746de5bddeaca7917c76f1c9d1e100ae2b2
* build: Upgrade mediawiki/mediawiki-phan-config from 0.13.0 to 0.14.0 manuallyJames D. Forrester2024-02-101-1/+1
| | | | | | | | | | | * Switch out raw Exceptions, mostly for InvalidArgumentExceptions. * Fake exceptions triggered to give Monolog a backtrace are for some reason "traditionally" RuntimeExceptions, instead, so we continue to use that pattern in remaining locations. * Just entirely give up on PostgresResultWrapper's resource vs. object mess. * Drop now-unneeded false positive hits. Change-Id: Id183ab60994cd9c6dc80401d4ce4de0ddf2b3da0
* Update name & email for bvibberBrooke Vibber2024-02-081-1/+1
| | | | | | | | | | | | | Updating name & email addresses for Brooke Vibber. Re-ran updateCredits.php as well so there are some new entries in there as well. There are a couple of files in resources/libs that will have to be changed upstream to keep tests happy, I will do patches later. :D Change-Id: I2f2e75d3fa42e8cf6de19a8fbb615bac28efcd54
* Change uses of getDBLoadBalancerFactory() to getConnectionProvider()Bartosz Dziewoński2024-01-221-9/+9
| | | | | | | | | | | | Update cases where one of the IConnectionProvider methods is called immediately. This doesn't really change anything, but I hope it helps promote getConnectionProvider() as the common way to do this. Follow-up to 8604c384f624273f46b653ec252ffaed30e6ff89. Change-Id: Id0e7d02bab0c570343c2b1f03c70b44ee39db112
* Merge "objectcache: Soft deprecate ReplicatedBagOStuff"jenkins-bot2023-12-211-0/+2
|\
| * objectcache: Soft deprecate ReplicatedBagOStuffDerick Alangi2023-12-191-0/+2
| | | | | | | | | | | | | | | | | | The MainStash use case is already covered by the use of CACHE_DB (SqlBagOStuff) and at this point, we no longer have any uses of ReplicatedBagOStuff. So, it can be deprecated and removed. Bug: T352481 Change-Id: Id691eafd60040792ae8ab767ee6013c1681461c1
* | ServiceWiring: Replace $wgCommandLineMode checks with MW_ENTRY_POINT (follow-up)Bartosz Dziewoński2023-12-191-1/+1
|/ | | | | | | | Follow-up to 94bbc1db01cfe9d7734f8ee7550c1a541c8a200b, I missed the relevant documentation. Bug: T313841 Change-Id: Icc63d8ad4b9ebb5a88913b16c6f97af3d64886eb
* Use thousands separators in selected integer literalsTim Starling2023-12-126-12/+12
| | | | | | | | | | For readability. Allowed since PHP 7.4. I searched for integer literals of 6 or more digits, and also changed some nearby smaller numbers for consistency. Bug: T353205 Change-Id: I8518e04889ba8fd52e0f9476a74f8e3e1454b678
* objectcache: rename TINY_POSTIVE constant to TINY_POSITIVEAmmarpad2023-12-091-2/+2
| | | | | | More intuitive and saving one letter is not worthwhile here Change-Id: Ibab9bc8262a4c0252c7f8471deb276d9df76dae3
* objectcache: Hard-deprecate `BagOStuff::setNewPreparedValues()`Derick Alangi2023-11-221-1/+2
| | | | | | | Per code search, no longer used anywhere: https://codesearch.wmcloud.org/search/?q=setNewPreparedValues&files=&excludeFiles=&repos= Change-Id: I38e12610112aad7f7e9e59b348aff9d80eb78254
* objectcache: Stop using wfGetDb() in documentationAmir Sarabadani2023-10-311-9/+9
| | | | Change-Id: I2bff59492205ee4709562a0f732619a95a02814c
* objectcache: fix BagOStuff::watchErrors() commentAaron Schulz2023-10-041-1/+1
| | | | Change-Id: I60e2fcd32daad2e0f4d6db89882a03313fc6b7c4
* http: MultiHttpClient supports TelemetryHeadersInterfacePiotr Miazga2023-09-121-1/+1
| | | | | | | | | | | | | | Introduce a new interface Wikimedia/Http/TelemetryHeadersInterface that provides telemetry information that could be attached to HTTP Requests. MultiHttpClient is expecting `telemetry` option of TelemetryHeadersInterface type. The MediaWiki/Http/Telemetry implements the interface, therefore ObjectCache can inject it to RESTBagOStuff, that further injects it to MultiHttpClient. Bug: T344926 Change-Id: I59a3f1048c403fe2e4ef0c74353dfe74ff9ca893
* objectcache: Hard deprecate SerializedValueContainer::newUnified()Derick Alangi2023-08-181-0/+2
| | | | | | | | | | | | | | | | Introduced in I0667a02612526d8ddfd91d5de48b6faa78bd1ab5 (in 2019) and used for consistency by default in BagOStuff::set(), even for the 99% of values that don't need segmentation. The method was removed from use in I830c78a50efd1ba83fbe2aa39c1, due to the overhead of SerializedValueContainer being undesirable, so there is no longer a use case for it. If a value doesn't need segmentation, it shouldn't be wrapped in SerializedValueContainer. See https://codesearch.wmcloud.org/search/?q=SerializedValueContainer%3A%3AnewUnified&files=&excludeFiles=&repos= Bug: T344521 Change-Id: Id1c283201cd42c4eabac8ef4d949329959016b18
* WANObjectCache: don't set a hold-off when the cache is emptyTim Starling2023-08-151-2/+3
| | | | | | | | | | | | | | | | | | | | | When getWithSetCallback() is called with check keys, if the keys are missing, a check key is inserted with the current time, as if touchCheckKey() were called. This causes cache misses for HOLDOFF_TTL = 11 seconds. This seems unnecessary since in the case of an empty cache, there is no expectation of replication delay. However, it's reasonable for it to be a cache miss when the check key is missing, and a cache hit subsequently, so we do need to add a purge value. So, in getWithSetCallback(), set the holdoff to zero when inserting a purge value. Also, use a holdoff of zero when initialising a missing touch key in getCheckKeyTime(). Bug: T344191 Change-Id: Ib3ae4b963816e5b090e87e4cb93624afefbf8058
* objectcache: Remove unused `$walltime` parameter in WANObjectCacheDerick Alangi2023-08-091-7/+3
| | | | | | | | | | | | | | Introduced in I4060b19583cdfd9fa36c91d7014441eeef4b3609 and removed in I62ec1c269ffb87eca03003b3f3c5336ee562a7b3 but the parameter was not cleaned up. This patch removes the parameter from the method and callers including other methods that passed this in. NOTE: These are all private methods so we can go ahead and remove this paramter without deprecation. Change-Id: Ifa76334e671ba8a8577be886bd407a6ac8038fa6
* objectcache: Remove IExpiringStore interfaceDerick Alangi2023-08-081-15/+0
| | | | | | | | | | | | Interface was deprecated since 1.35 in favor of ExpirationAwareness or StorageAwareness interfaces. No longer used anywhere, see dependent patches. Depends-On: Ida557b3180eb5e7ebae46968142b4f154f26ffbc Depends-On: I3d6fbf535560655472ade27c37b0e42b3e11a535 Depends-On: I2b0a669d41d9e6a8a859cba314c0e9e4c0ef40d7 Depends-On: I776040c2c8f61e25ae986e93bb1975fdd8bf9dd5 Change-Id: I9c5ffa9f51aec6356e3e27458fd098a37cd754ad
* objectcache: Reduce boilerplate and indirection around makeKey()Timo Tijhof2023-08-0314-234/+147
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | == Background Most of this was introduced in commit 5c335f9d77 (I1eb897c2cea3f5b7). The original motivation was: * Ensure wrappers like MultiWriteBagOStuff naturally do the right thing. In practice, makeKey() results are interchangeable, with the most contrained one (Memcached) also generally used as the first tier. However, this is not intuitive and may change in the future. To make it more intuitive, the default implemention became known as "generic", with proxyCall() responsible for decoding these, and then re-encoding them with makeKey() from the respective underlying BagOStuff. This meant that MultiWriteBag would no longer use the result of the Memcached-formatted cache key and pass it to SqlBagOStuff. * Allow extraction of the key group from a given key cache, for use in statistics. Both motivations remains valid and addressed after this refactor. == Change * Remove boilerplate and indirection around makeKey from a dozen classes. E.g. copy-paste stubs for makeKey, makeKeyInternal, and convertGenericKey. Instead, let BagOStuff::makeKey and ::makeKeyInternal hold the defaults. I believe this makes the logic easier to find, understand, and refer to. The three non-default implementations (Memcached, WinCache, Sql) now naturally reflect what they are in terms of business logic, they are a method override. Introduce a single boolean requireConvertGenericKey() to let the three non-default implementations signal their need to convert keys before use. * Further improve internal consistently of BagOStuff::makeKeyInternal. The logic of genericKeyFromComponents() was moved up into BagOStuff::makeKeyInternal. As a result of caling this directly from BagOStuff::makeKey(), this code now sees $keyspace and $components as separate arguments. To keep the behaviour the same, we would have to either unshift $keyspace into $components, or duplicate the strtr() call to escape it. Instead, excempt keyspace from escaping. This matches how the most commonly used BagOStuff implementations (MemcachedBag, and SqlBag) already worked for 10+ years, thus this does not introduce any new responsibility on callers. In particular, keyspace (not key group) is set by MediaWiki core in service wiring to the wiki ID, and so is not the concern of individual callers anyway. * Docs: Explain in proxyCall() why this indirection and complexity exists. It lets wrapping classes decode and re-encode keys. * Docs: Explain the cross-wiki and local-wiki semantics of makeKey and makeKeyGlobal, and centralise this and other important docs about this method in the place with the most eye balls where it is most likely seen and discovered, namely BagOStuff::makeKey. Remove partial docs from other places in favour of references to this one. Previously, there was no particular reason to follow `@see IStoreKeyEncoder` much less to know that it holds critical that communicate the responsibility to limit the key group to 48 chars. * Docs: Consistently refer to the first component as the "key group", thus unifying what was known as "key class", "collection", "key collection name", or "collection name". The term "key group" seems to be what is used by developers in conversations for this concept, matching WMF on-boarding docs and WMF's Grafana dashboard for WANObjectCache. Change-Id: I6b3167cac824d8bd8773bc66c386f41e4d380021
* objectcache: remove deprecated BagOStuff::addBusyCallback() methodAaron Schulz2023-08-015-28/+0
| | | | Change-Id: I523faa6c8c516edd9f6cd81e9275c3a54a169818
* Merge "objectcache: Fix foreach warning in ReplicatedBagOStuff"jenkins-bot2023-07-311-1/+1
|\
| * objectcache: Fix foreach warning in ReplicatedBagOStuffTimo Tijhof2023-07-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When enabling $wgResourceLoaderUseObjectCacheForDeps in I79299f80fe06, I get the following warning: > PHP Warning: Invalid argument supplied for foreach() > > BagOStuff.php(772): MWExceptionHandler::handleError() > > ReplicatedBagOStuff.php(218): BagOStuff->proxyCall() > > KeyValueDependencyStore.php(81): ReplicatedBagOStuff->setMulti(array, …) > > ResourceLoader.php(547): KeyValueDependencyStore->storeMulti() > > … This is happening because setMulti is configured as RES_KEYMAP, which sets the expectation of an array return value, when actually BagOStuff::setMulti returns bool. There is similar code in MultiWriteBagOStuff, which already used RES_NONKEY correctly. Change-Id: Ifc9db0758f0e150862d163eb7a4df03042f54e83
* | objectcache: Remove unused WRAPPER_COLLECTION_CALLBACK featureTimo Tijhof2023-07-242-84/+6
|/ | | | | | | | | | | | | | | | | | | | This was introduced for use by WANObjectCache, however, this never worked in practice. The feature only influences determineKeyPrefixForStats(), which in turn is only called by MediumSpecificBagOStuff::updateOpStats, which in turn is exclusively called within BagOStuff subclasses that aren't used with WANObjectCache (RESTBag, RedisBag, SqlBag). The next commit simplifies BagOStuff::makeKey, which can make a bigger impact if this feature doesn't need to be supported. During drafting of the next commit, I found that the feature doesn't appear to work well in practice, because getCollectionFromSisterKey did not account for mcrouter-style route prefixes, as inserted by makeSisterKey(). Change-Id: Iecea959c88abbd7a0a17b92c1c4d854602748280
* Replace substr with cleaner string methodsMatěj Suchánek2023-05-201-3/+2
| | | | | | | | | | Use str_starts_with, str_ends_with or string offset where appropriate. This fixes a bug in MimeAnalyzer where the "UTF-16LE" header could not be identified because of wrong constant. This is the exact type of bug that the new functions can avoid. Change-Id: I9f30881e7e895f011db29cf5dcbe43bc4f341062
* objectcache: deprecate ATTR_EMULATION/QOS_EMULATION_SQLAaron Schulz2023-05-171-2/+2
| | | | | | | QOS_DURABILITY_RDBMS can be checked instead Bug: T279977 Change-Id: I42a00275995dd855c60c8f45a01d2da11bab7029
* objectcache: Remove keyHigh* attributes from WANObjectCacheAmir Sarabadani2023-05-161-21/+0
| | | | | | Unused since Ie3a2215d3325f Change-Id: I5a7b1164ba4f06913ba578bc418a94a8935b25e6
* objectcache: Remove stat keys also from READMEUmherirrender2023-05-051-57/+0
| | | | | | No longer used since f83f75d3e64e9352c36d10b6280ca0d0b52b38d2 Change-Id: I663418469fcb46c97bb14267877d038adbf737c2
* objectcache: Remove WANObjectCache's internal cool-off bounce featureTimo Tijhof2023-04-291-81/+2
| | | | | | | Bug: T203786 Bug: T302623 Bug: T321634 Change-Id: Ie3a2215d3325fe7290658e1013adaac4f4565884
* Simplify RedisBagOStuff::incrWithInitTim Starling2023-03-271-21/+11
| | | | | | | | * Combine the scripts. * Use luaEval() to reduce the network overhead. * Remove "r" prefix on local variables Change-Id: I7c3097e18dd8570023d9a711327e139e395dfbbb
* Just another 80 or so PHPStorm inspection fixes (#4)Tim Starling2023-03-251-2/+0
| | | | | | | | | | | | | * Unnecessary regex modifier. I agree with this inspection which flags /s modifiers on regexes that don't use a dot. * Property declared dynamically. * Unused local variable. But it's acceptable for an unused local variable to take the return value of a method under test, when it is being tested for its side-effects. And it's acceptable for an unused local variable to document unused list expansion elements, or the nature of array keys in a foreach. Change-Id: I067b5b45dd1138c00e7269b66d3d1385f202fe7f
* Fix more PHPStorm inspections (#2)Tim Starling2023-03-252-4/+4
| | | | | | | | | | | | | | | * Illegal string offset and invalid argument supplied to foreach, due to incorrect type information * Array internal pointer reset is unnecessary * $hookData unused since MW 1.35 due to incomplete revert * array_push() with single element * Unnecessary sprintf() * for loop can be replaced with str_repeat() * preg_replace() can be replaced with rtrim() * array_values() call is redundant * Unnecessary cast to string * Unnecessary ternary. Often the result relies on short-circuit evaluation, but I find it more readable nonetheless. Change-Id: I4c45bdb59b51b243fa96286bec8b58deb097d707
* Merge "Fix some typos"jenkins-bot2023-03-231-1/+1
|\
| * Fix some typosMatěj Suchánek2023-03-211-1/+1
| | | | | | | | | | Bug: T201491 Change-Id: I5c9408c262f09c936525f35abfacfa92a193b791
* | Merge "objectcache: fix RedisBagOStuff::incrWithInit() return value"jenkins-bot2023-03-221-4/+21
|\ \
| * | objectcache: fix RedisBagOStuff::incrWithInit() return valueAaron Schulz2023-03-201-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Return the new value as per the base class. Also, avoid use the "setex" command when the TTL is zero (which is invalid). This fixes a failing test in RedisBagOStuffIntegrationTest. Follow-up to 79ea356f1bf8aa. Change-Id: Ia33bed959928788252fdf7bf37d56fa9e5946765
* | | Merge "objectcache: fix connections in RedisBagOStuff multi methods"jenkins-bot2023-03-221-102/+86
|\ \ \
| * | | objectcache: fix connections in RedisBagOStuff multi methodsAaron Schulz2023-03-201-102/+86
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, a bug resulted in a connection per key for getMulti() and similar methods. RedisConnRef instances are treated as if they belong to different callers, so RedisConnectionPool::getConnection cannot be used in naive loops to build (key => RedisConnRef) arrays. Create a RedisBagOStuff::getConnectionsForKeys() method to properly get connection handles for multiple keys and reduce code duplication. Bug: T332371 Change-Id: Id58b9ac61c59277f7cd8f17821c1905b930b02cb
* | | Merge "objectcache: remove FLD_GENERATION_TIME field from WANCache entries"jenkins-bot2023-03-221-7/+1
|\ \ \ | |/ / |/| |
| * | objectcache: remove FLD_GENERATION_TIME field from WANCache entriesAaron Schulz2023-03-191-7/+1
| | | | | | | | | | | | | | | | | | | | | This value was unused and rarely set. LOW_TTL should be sufficient to avoid stampedes without needing to use the generation time cost. Change-Id: I62ec1c269ffb87eca03003b3f3c5336ee562a7b3