This saves a few bytes in the response size and make it easy
for memcached proxies to distinguish key fetches that are part
of check-and-set cycles from those that are not.
MediumSpecificBagOStuff now requires PASS_BY_REF to fetch CAS
tokens. BagOStuff::merge() and WinCacheBagOStuff::doCas() are
the only callers that need this mode.
Bug: T257003
Change-Id: If91963f58adc4cda94f6d634ee0252a479a0fc5e
T233963 added serizalization type to RESTBagOStuff. Although
there were no known callers that were not refactored to be
aware of this, T233963 also added a deprecated "legacy" type,
marked for removal in MW 1.35, just in case. There are still no
known callers using this, so remove "legacy" as planned.
Bug: T234779
Change-Id: I0c7707692aa1d0c75e262c914e064bddc10897c7
For compliance with the new version of the table interface policy
(T255803).
This patch was created by an automated search & replace operation
on the includes/ directory.
Bug: T257789
Change-Id: Ie32c1b11b3d16ddfc0c83a757327d449ff80b2e4
For compliance with the new version of the table interface policy
(T255803).
This patch was created by an automated search & replace operation
on the includes/ directory.
Bug: T257789
Change-Id: If560596f5e1e0a3da91afc36e656e7c27f040968
The following glasses are marked as newable per the
Stable Interface Policy, even though logically, they should not be
newable. This is done for classes that are currently instantiated
by extensions, and lack an alternative.
A better way for obtaining an instance of these classes should be
created in the future. At that point, direct instantiation should
be deprecated and replaced.
- includes/ApiMain.php - needs factory
- includes/media/BitmapMetadataHandler.php - should become a stateless service or use handler pattern
- includes/GitInfo.php - should become a stateless service
- includes/logging/LogPage.php - should become a stateless service or use command pattern
- includes/logging/ManualLogEntry.php - should become a stateless service or use command pattern
- includes/poolcounter/PoolCounterWorkViaCallback.php - needs a factory
- includes/context/RequestContext.php - needs to be narrowed down, and should use a factory
- includes/search/SearchHighlighter.php - should have a factory
- includes/TitleArrayFromResult.php - should perhaps be part of TitleFactory
- includes/user/User.php - should at least get a factory method for anons
- includes/diff/Diff.php: needs a TextDiffGenerator service or a factory
- includes/EditPage.php: needs a factory
Bug: T247862
Change-Id: I033158e693c98630ee167d9528fc8c9936f978d4
This annotates classes that can safely be instantiated by
extensions, per the Stable Interface Policy.
Bug: T247862
Change-Id: Ia280f559874fc0750265ddeb7f831e65fd7d7d6a
Create a simple APCUBagOStuff subclass and also fix
APCUBagOStuff::incrWithInit() default $init value.
Change-Id: If84963fe7dcfedd6edebfb8785235263e0868ece
This makes it easier to rollout one keyspace/project at a time even
if some keys are shared and receive purges. The shared keys can all
be done as the last step.
Also, simplify getMulti() to no longer need extractBaseKey().
Make the "warm up cache" logic a bit easier to follow and less
likely to copy values around.
Change-Id: I8b602ddf5dd1feaada45fb0af202c5603836a8dd
Track the serialized value bytes/second spent on cache backfills for
each key class. The combination of a Count and Timing metrics within
checkAndSetCooloff() permits calculation of bytes/call as well.
Bug: T248962
Change-Id: I324e29e85bc4df7689bd2d5fb45cf8750b92a8d9
If a key always takes a very long time to regenerate, is popular,
and does not use lockTSE, it still needs to be cacheable. Since a
value cannot be more up-to-date than the time it takes to regenerate
it, take the "lower the TTL" approach for these cases. Use "walltime"
to narrow down the "reject the set()" case based on regeneration time.
This is already provided by getWithSetCallback() automatically.
Bug: T244877
Change-Id: Id43fb02738b28dad3bc922057efb7eee0272d0e1
* Document how wgWANObjectCaches and wgMainWANCache are
used / should be used.
Remove outdated mention of event relayers.
* The easiest way I could document the 'other' options that
wgWANObjectCaches entries can have was by saying which keys
can't be set and that aside from these and class/cacheId
they are all passed on.
However, that wasn't (yet) technically right given we do pass
class/cacheId on blindly, which might be unexpected for
subclasses in theory. Explicitly unset those in ServiceWiring
to avoid any chance of confusion. Also simplify that code
slightly overall in terms of var names and var re-use,
and improve error messages a litle bit.
* Test plan for the wanobjectcache-deployment doc ref:
$ php maintenance/mwdocgen.php \
--file includes/DefaultSettings.php,includes/libs/objectcache/
Then open path/to/mediawiki/docs/html/, click on the docs for
DefaultSettings, and find-in-page to "wgMainWANCache".
Change-Id: I1cfc65c2cc4dbceed6b9777c2b808527a58daeb9
This can be used by WANObjectCache or statsd metrics to estimate
the size of objects and network commands without having to do an
extra serialization round.
Change-Id: I7b1b787bba39a21e2e04262e77ee7ae24e88f8ca
Rewrite checkAndSetCooloff() to have a clearer intent and a
broader scope. It now applies any time a key is evicted and
seems "risky" (based on value size and regeneration time).
Previously, only keys that used "lockTSE" were considered
for such throttling.
For scalar values, estimating the size is easy enough, though
the final object size might be smaller due to compression.
A pessimistic size is assumed for other variable types.
Bug: T239983
Change-Id: Ib233a650112a9d574a6aa744f6af23bc16d4f5d7
This better matches the BagOStuff interface. If a value is saved with
a TTL of X, then it should take ~X seconds for it to expire. A key may
need to use low, often randomized, TTLs, and this behavior will break
such use cases.
The default apc.use_request_time value (1) assigns writes a timestamp
equal to the web request timestamp. If a request has been going for Y
seconds, then a TTL of X becomes (X-Y) as far as new requests can see,
due to the "back-dating". If Y > X, then the value was effectively
purged for all new requests. This can easily be simulated via sleep().
Change-Id: I3d0abdc3a1870cb76386c6db2db27ad1c9b5885b
* Avoid direct $GLOBALS lookups.
* Avoid MediaWikiServices singleton for Config object.
Also given that newFromParams() constructs its Logger object
unconditionally as of I2aa835c5ec79, stop creating it ahead of
time in ServiceWiring.
This code, including the default loggroup value, was duplicated by
me from ObjectCache.php to ServiceWiring.php in commits 3828558140
and bd16c5eb34 because I needed to obtain the Logger object
in order to send a message to it about how it was created.
Solve this debt by letting ServiceWiring access the actual logger
that was created by newFromParams() through a new getLogger()
object.
Change-Id: Ib2de7b22f6c79db0c700fae06269d04fbe27831d
This is useful for grouping related keys on the same servers to reduce
the need for cache server connections and availability. A cache key that
uses "lockTSE" can already involve accessing several keys during the
read/write cache-aside paths:
a) The value key itself
b) The check key (named after the main key, a common pattern)
c) The mutex key (used if the value looks stale)
d) The cool-off key (used if regeneration took a while)
Any problems accessing the first two could cause extra value regenerations.
Problems with the mutex key could lead to stampedes due to threads assuming
another thread was regerating a soon-to-expire value when, in fact, none was.
A similar problem could happen with cool-off keys, with threads assuming
that another saved the newly regenerated value when, in fact, none did.
The use of hash stops puts the tiny related keys on the same server as the
main cache key that they serve. This is only for hash-based routing, and not
route prefix routing (e.g. All*Route still sends the key to multiple child
routes, but the PoolRoute/HashRoute function will hash differently).
The option is not enabled by default yet.
Change-Id: I37e92a88f356ef1e2a2b7728263040e2f6f09a13
These were spotted by phan's stricter type checks. All make*Key methods
can also take integers, and that's pretty common across core and
extensions.
Language::formatNum can also take numbers (and tests cover this case);
in this case, move the cast to the top of the method, so that we're
passing a string to strtr, too.
The methods touched in this patch are the main source of false positives
in both core and extensions.
Change-Id: I6d538ce3ca7fd2d495c2bafbab7cc279da69db1c
Scalar casts are still allowed (for now), because there's a huge amount
of false positives. Ditto for invalid array offsets.
Thoughts about the rest: luckily, many false positives with array offsets
have gone. Moreover, since *Internal issues are suppressed in the base
config, we can remove inline suppressions.
Unfortunately, there are a couple of new issues about array additions
with only false positives, because apparently they don't take
branches into account.
Change-Id: I5a3913c6e762f77bfdae55051a395fae95d1f841
To help isolate the referenced bug, which is a sporadic test failure
in testGetWithSetCallback().
Bug: T238197
Change-Id: If35d60340c804b6bfe1e9ddfcf53c76373c794b1
This is to ensure that the CI job is working with the new version.
Note: redundant_condition_detection should have worked as expected by
this version, but unfortunately it still has false positives.
Bug: T235049
Bug: T231636
Change-Id: Idaba6584cb5b2ff19b6455c7bbec6b89619ddbff