Commit graph

62 commits

Author SHA1 Message Date
thiemowmde
32d214dd6d Drop duplicate test cases and @dataProviders from tests
A single test function can have multiple @dataProviders. No problem.

A @dataProvider can also be used by multiple test functions. No
problem. No need to duplicate such large pieces of code when it's
identical anyway.

Change-Id: I5aea36304ec2d1666ff2334ba883df07a70c15c5
2024-07-19 10:18:31 +00:00
Ebrahim Byagowi
fab78547ad Add namespace to the root classes of ObjectCache
And deprecated aliases for the the no namespaced classes.

ReplicatedBagOStuff that already is deprecated isn't moved.

Bug: T353458
Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
2024-07-10 00:14:54 +03:30
Derick Alangi
dc91d2d6c5
objectcache: Migrate BagOStuff from StatsdD to StatsLib
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
2024-02-27 19:23:10 +03:00
Reedy
c14dd609a7 tests: Move Wikimedia tests into Wikimedia\Tests
Change-Id: I9c64a631b0b4e8e4fef8a72ee0f749d35f918052
2024-02-17 02:09:08 +00:00
Reedy
85396a9c99 tests: Fix @covers and @coversDefaultClass to have leading \
Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
2024-02-16 22:43:56 +00:00
James D. Forrester
ebb03c7496 WANObjectCacheTest::testPreemptiveRefresh: Skip flaky test for PHP 8.2+
Bug: T353180
Change-Id: Iac8e6fab0f6a95ba3534ab0ce40b91d0967f74c0
2023-12-14 14:57:34 -05:00
Amir Sarabadani
f5abfb8d58 Bump codesniffer to 42.0.0
Most noisily, this enables MediaWiki.Arrays.OneSpaceInlineArray.

Change-Id: I8ab11399c67ce7e3ab1b6249b591452774393428
2023-09-27 15:06:32 -04:00
Tim Starling
7f00b40340 WANObjectCache: don't set a hold-off when the cache is empty
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
2023-08-15 16:37:10 +00:00
Timo Tijhof
75aec3686a objectcache: Reduce boilerplate and indirection around makeKey()
== 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
2023-08-03 10:42:56 +02:00
Timo Tijhof
83f2f714c2 objectcache: Remove unused WRAPPER_COLLECTION_CALLBACK feature
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
2023-07-24 05:01:17 +01:00
Umherirrender
1086958611 Replace array_keys in foreach to use $_ as value instead
When the value of the associated array is not used, there is no need to
use array_keys and create internal a copy of the array, just omit the
value with $_ to tell static analyzer that the var is unused.

Change-Id: I5c6d667e98c0167c0573c683f0d617bc1d4ca619
2023-07-10 02:53:52 +00:00
Umherirrender
d36073cdcf tests: Make some PHPUnit data providers static
Initally used a new sniff with autofix (T333745),
but some provide are defined non-static in TestBase class
and need more work to make them static in a compatible way

Bug: T332865
Change-Id: I889d33424f0c01fb26f2d86f8d4fc3de3e568843
2023-05-20 01:05:27 +02:00
Aaron Schulz
731af1e059 objectcache: deprecate ATTR_EMULATION/QOS_EMULATION_SQL
QOS_DURABILITY_RDBMS can be checked instead

Bug: T279977
Change-Id: I42a00275995dd855c60c8f45a01d2da11bab7029
2023-05-17 19:36:35 +00:00
Tim Starling
d36ea70309 Fix some PHPStorm inspections (#1)
* Triple backslash in regex should really be quadruple backslash
* Using the returned value of a void method
* Immediately overwritten array keys
* Duplicate array keys
* Foreach variable reuse
* sprintf() with too many params
* Incorrect reference usage

Change-Id: I3c649b543c9561a1614058c50f3847f663ff04df
2023-03-25 00:19:33 +00:00
Timo Tijhof
bf34238252 objectcache,rdbms: Widen needlessly narrow @covers test annotations
We'd lose more useful coverage and spend more effort keeping these
accurate through refactors etc than is worth the theoretically "bad"
accidental coverage. Plus, even then we still very often forget to
update these and waste time digging into seemingly uncovered code
and either write duplicate test or discover they are already covered.

Especially for private methods this can be a flawed endavour as
we tend to trust tests when changing those and thus feel we shouldn't
update tests, except it's riddled with private method mentions for
coverage purposes (not in terms of actual called code).

I think the best practice is to write good narrow unit tests,
not to write bad tests and then hide their coverage. Generally
that's what we do. Maybe these are useful when invoking a huge
legacy class, but generally we don't need these I think, at least
in the libs our team maintains.

Change-Id: I4c7d826c7ec654b9efa20778c46c498784661f1c
2023-02-21 21:27:40 +00:00
Timo Tijhof
0e3727b23b objectcache: Fix flaky WANObjectCacheTest::testLockTSESlow case
I noticed this in CI during development for Ia893ddb36427eb5e9bff,
however, it is reproducible on latest master as well. Locally, it
happens about 1/30 times:

```
$ php phpunit.php --filter testLockTSESlow unit/includes/libs/objectcache/
Using PHP 8.1.13
PHPUnit 9.5.27 by Sebastian Bergmann and contributors.
There was 1 failure:
1) WANObjectCacheTest::testLockTSESlow with data set #0 (array('hash_tag'), '{')
Callback not used (mutex not acquired, stale value used)
Failed asserting that 3 is identical to 2.
/w/tests/phpunit/unit/includes/libs/objectcache/WANObjectCacheTest.php:1311
/w/tests/phpunit/MediaWikiUnitTestCase.php:11
```

* Remove randomisation from test. The HashBag is empty at this point,
  and a dedicated instance is created for each test case. Remove doubt
  over conflicts or other uncertainty, and make it easier to debug at
  the same time.

* Increase mocked time gap from 2s to 32s similar to what the
  previous assertion in the same test does already. 2s does not actually
  go past the reduced logical TTL which is 30s at this point.

  It seems to still pass on master in most cases, but it makes sense
  that it can fail. I could not reproduce failures after this change.

Change-Id: I6e491ae3c4f41413e7a952aa0796a787d559ac48
2023-01-13 23:46:51 +00:00
Timo Tijhof
0c42d3313d objectcache: Simpler @covers annotations for WANObjectCacheTest
Loosen up the code coverage a bit so that we can more clearly identity
what logic truly isn't excercised by tests. It also restores some
gaps that were left behind by various refactors when code moved around
or out into various private methods.

Change-Id: I4e65f92ea1eb3f0e781ada4fb2ced0f8ef9d3cc4
2023-01-13 22:48:25 +00:00
daniel
df9a729e57 BagOStuff: never use the full cache key as metrics key
When the cache key doesn't contain a prefix indentifying the collection,
don't use the entire cache key as the metrics name. Doing so may explode
the number of metrics.

Bug: T323357
Change-Id: Ia7ff3f060a36f848c7a74e39070bd62a932120e7
2022-11-21 14:03:44 +01:00
Aaron Schulz
f6fec396c5 objectcache: use WRITE_BACKGROUND in WANObjectCache where applicable
This avoids the latency of waiting for a response.

Change yieldStampedeLock() to use delete() instead of changeTTL() since
the PECL memcached client does not support WRITE_BACKGROUND with TOUCH.

Also, simply relayVolatilePurges() into relayVolatilePurge() and tweak
some related documentation for WANObjectCache

Bug: T302623
Change-Id: I16f011b730f34332aa54a48c579de3c6606dafda
2022-11-09 21:17:03 +00:00
Aaron Schulz
b24871a15c objectcache: add "segmentable" option to WANObjectCache
This allows for large string value storage similar to that
of direct BagOStuff callers.

Bug: T309126
Change-Id: I22d2d8bb520ef2ea6ccd28016d34db36fe27c3df
2022-11-04 00:12:44 +00:00
Aaron Schulz
a454105b48 objectcache: split out WANObjectCache::setMainValue() helper method
Make set() and getWithSetCallback() wrap setMainValue(), avoiding some
duplicate option array resolution logic.

Track set() calls via statsd, now that it can be distinguished from
getWithSetCallback() invocations.

Change-Id: Ia1e7b244b1db3b76314d718b3aea9e6e708235c0
2022-11-01 15:53:48 -07:00
Timo Tijhof
1cf6f04768 objectcache: Remove WANObjectCacheReaper feature
Introduced in 2017 with I7f14b9ca2533032 (2e5eb693) but remains
unused at WMF, and disabled by default.

Follows-up I62107789fa (9e49260fc9) which added reap to LinkCache
test cases in 2021.

Change-Id: I0654c29a671467dd6b366f462d1c09b90a273413
2022-10-25 23:09:39 +01:00
Tim Starling
0077c5da15 Use short array destructuring instead of list()
Introduced in PHP 7.1. Because it's shorter and looks nice.

I used regex replacement.

Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
2022-10-21 15:33:37 +11:00
Timo Tijhof
7a6301e03d objectcache: Deprecate WANObjectCache::reap() and ::reapCheckKey()
Follows-up Ia550ef7fe3 (4d3549ad71) which added reap to NameTableStore
in 2018, which was then (mostly) removed again with I63e61e1ab (2c7e4adcea)
for T198561, except one call was left behind in reloadMap(). I've
changed this to match the existing delete call in acquireId().

To be removed in I0654c29a671467dd6.

Change-Id: I7541c9c6d1ef70d552944aca94cbc4d0f7ec0d5b
2022-10-20 14:56:50 +01:00
Daimona Eaytoy
ee672592d8 tests: Replace assertRegExp with assertMatchesRegularExpression
And also assertNotRegExp -> assertDoesNotMatchRegularExpression. The
methods were renamed in PHPUnit 9.

Done automatically with:
  grep -rl assertRegExp tests/ | xargs sed -r -i "s/>assertRegExp\(/>assertMatchesRegularExpression\(/"
  grep -rl assertNotRegExp tests/ | xargs sed -r -i "s/>assertNotRegExp\(/>assertDoesNotMatchRegularExpression\(/"

Split out from Ifdba0f9e98eb6bce4590b7eb73170c51a697d7c6 so that it
remains smaller and easier to review.

Also make a test use MediaWikiUnitTestCase (it's already in the unit/
dir) so that it can access the forward-compat method.

Bug: T243600
Change-Id: Ifa279d5f201d7abeebece292141ebface8278046
2022-10-07 14:13:16 -04:00
Matěj Suchánek
b5349b17d7 Fix typo in "overridden"
Bug: T201491
Change-Id: I4fc428c77bd2f094d194bcd5aaa3636449ef2658
2022-05-15 11:35:55 +02:00
Timo Tijhof
c2c663e6e1 objectcache: Clean up getMultiWithUnionSetCallback() test cases
It took me a good half hour to understand what these tests are doing,
and another half hour to build up a modicum of confidence that the
current behaviour is the indeed the desired behaviour.

* Remove random strings.

* Remove indirection and computed expected values as much as possible
  in favour of inlined literals that explicitly expect outcomes.

* Remove confusing second argument from the data provider
  getMultiWithUnionSetCallback_provider, which wasn't used, and
  add labels to it.

* Remove some of the existing inline comments.

* Add some inline comments with what I've understood.

* Fix bug in "C: Repeat case with recently created check keys",
  which claimed to be observing that caches were ignored due to the
  check key being too new, when in fact it was a cache miss simply
  because the key didn't exist yet upto this point. Make it actually
  repeating by adding a second call afterwards to observe the
  stated behaviour.

Bug: T303092
Change-Id: I874a20ecd49464f7b0e6a0b579c000dc0e804c0a
2022-03-18 15:41:08 +00:00
Aaron Schulz
892c3383dd objectcache: clarify usage of getMultiWithUnionSetCallback()
The examples and comments were misleading with regard to the handling
of missing entities.

Bug: T303092
Change-Id: Ib672fd18d1270c35253683eb54b48be056e6dc3c
2022-03-17 17:40:45 +00:00
Aaron Schulz
d1a69ac84a objectcache: add more guessSerialValueSize() tests
Change-Id: I76feaa559e2e55ca11f49df3df63534a34127f2c
2022-01-26 14:55:53 -08:00
Aaron Schulz
8f6d05e62c objectcache: add watchErrors() to BagOStuff/WANObjectCache
The new style of checking for the last error during a section of
calls is more robust since it allows nesting of callers. Typically,
an external caller will want to watch a section of code that will
involve zero or more internally watched sections. Errors that are
seen internally (leading to a failing response) should also be
visible externally.

Replace internal BagOStuff clearLastError() calls.

Replace WANObjectCache clearLastError() calls. Such a class should not
clear the error codes since the class is effectively "internal". Callers
that are more meaningfully "external" might want to check the errors.

Cleanup "last" error handling for proxy backends.

Change-Id: I281817a85602967c0ec2bdd23a5d8be101680b64
2021-11-10 00:38:27 +00:00
Aaron Schulz
278bcbb7a6 Reduce microtime()/mt_rand() fragility in WANObjectCacheTest
Tweak testLockTSESlow() tests to reduce mt_rand() dependency.

Also, rename last few $now variables to $mockWallClock and use
integral floats to make it easier to find raw microtime() values
via debugging statements.

Change-Id: Ie2b125e42d3ac37104f5b87b75a9a81558956518
2021-10-09 03:16:57 +00:00
Aaron Schulz
c7b6548bc5 objectcache: improve the WANObjectCache "lag mitigation" TTL logic
Handle edge case of fast callbacks that happen to run just before
the transaction age reaches MAX_READ_LAG. Such callbacks will no
longer be considered "slow".

Distinguish slow and fast regenerations for the case when TTL
mitigation is triggered by the combination of snapshot and
replication lag.

Reduce the cases where TTL_UNCACHEABLE is used as the mitigation
TTL, to avoid operational risk.

Simplify the mitigation TTL code by reducing needless variation
between the "lockTSE" and non-"lockTSE" cases.

Track the key and time of the last 10 get() calls that returned
either a stale value or no value at all. Use this this estimate
the walltime in set(), if it was not provided.

Bug: T285070
Change-Id: Ie6c88fbf7dbfc831d67bfb6cde082c123555a8cf
2021-09-14 00:17:56 +00:00
Timo Tijhof
11ed63fe89 objectcache: Update WANObjectCache test to not require fraction in purge value
In prep for the next commit and to confirm that it passes
both before and after.

Change-Id: I4d203843a8cb2486584df1601fec589389110f73
2021-09-11 19:48:08 +01:00
Aaron Schulz
7e12163708 objectcache: simplify BagOStuff::ATTR_* flags and set them for backends
* Remove unused ATTR_SYNCWRITES/QOS_SYNCWRITES_* constants
* Remove unused ATTR_LOCALITY/QOS_LOCALITY_* constants

Bug: T279977
Change-Id: I5ada228fbd504f8e94833df8a8414ed8da0bce4b
2021-08-31 11:23:28 -07:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
DannyS712
ae4efe66c6 Don't pass unneeded variables into anonymous functions
Change-Id: Iad4d1dc4727828f9e0120c8bf99dc245a29ee14d
2021-07-13 19:48:26 +00:00
Thiemo Kreuz
2ba01c7ee7 Remove some more comments that literally repeat the code
… including PHPDoc tags like `@return <type> $variableName`.
A return value doesn't have a variable name. I can see that
some people do this intentionally, repeating the variable
name that was used in the final `return $var;` at the end
of a method. This can indeed be helpful. I leave a lot of
these untouched and removed them only when it's obviously
wrong, or does not provide any additional information in
addition to what the code already says.

Change-Id: Ia18cd9f25ef658b08ad25b97a744897e2a8deffc
2021-06-18 21:23:56 +00:00
Thiemo Kreuz
b95a07380a Remove meaningless ->expects( $this->any() ) from all tests
It is not entirely meaningless. It might be an indicator that
the number of calls to a method is intentionally unlimited.
This is similar to e.g. an @inheritDoc PHPDoc comment that
marks a method as being "intentionally undocumented".

However, what's the meaning of being "intentionally
unconstrained"? Let's just not have any constraint then.

I feel all these ->expects( $this->any() ) bloat the test
code so much that it's never worth it.

Change-Id: I9925e7706bd03e1666f6eb0b284cb42b0dd3be23
2021-04-23 11:58:58 +02:00
Thiemo Kreuz
e2ec44d73f Replace ->exactly( 1 ) with ->once() in tests
It's shorter, the more canonical form, and easier to read
because of this.

Change-Id: I9c68a49c1f31bddfac91a74a6592fe3545ca00a7
2021-04-22 09:42:28 +02:00
Daimona Eaytoy
535d7abf59 phpunit: Mass-replace setMethods with onlyMethods and adjust
Ended up using
  grep -Prl '\->setMethods\(' . | xargs sed -r -i 's/setMethods\(/onlyMethods\(/g'

special-casing setMethods( null ) -> onlyMethods( [] )

and then manual fix of failing test (from PS2 onwards).

Bug: T278010
Change-Id: I012dca7ae774bb430c1c44d50991ba0b633353f1
2021-04-16 20:15:00 +02:00
Timo Tijhof
a6a25a1efc objectcache: Replace 'cluster' and 'mcrouterAware' with 'broadcastRoutingPrefix'
Also remove the unused 'region' option.

Added release notes, and updated the notes for coalesceKeys as well
to reside in the configuration section instead.

Change-Id: I219ea67416c6d121ce1488d99dab9a3a089f27d9
2021-04-09 23:04:41 +00:00
Timo Tijhof
16ac6980f8 objectcache: Implement 'onHostRoutingPrefix' option in WANObjectCache
Renamed several methods for clarity and updated various comments

Use explicit number_format() instead of casting floats to strings
when making purge values

Fix LocalRepoTest mocking of WANObjectCache::makeGlobalKey()

Bug: T264604
Change-Id: Ib03b97fcab8a34d38d3a8a12da6e28e12feef4ad
2021-04-09 00:27:13 +00:00
Aaron Schulz
19de9147d1 objectcache: cleanups to broadcast/relay code in WANObectCache
* Split makePurgeValue() into one for "check" keys and one for
  tombstones.
* Simplify tombstones by ommitting the zeroed-out holdoff component.
* Remove unused and deprecated HOLDOFF_NONE constant.
* Clarify various comments.

Change-Id: If6cc34538b1ea30764836b6870ba8648424ce9d7
2021-04-07 08:22:40 +00:00
Aaron Schulz
74ebf0ec9c objectcache: replace "coalesceKeys" with "coalesceScheme"
Key coalescing hints are now unconditionally enabled, using
the mcrouter style by default. This can be changed by setting
"coalesceScheme" (e.g. in case of experimental dynomite use).

Change-Id: I4866ed66d42d7d7da2b3edc2f99b8ba35fe3d511
2021-04-01 19:52:07 -07:00
jenkins-bot
2d2fe36d3c Merge "objectache: Revert "throw on Closure" in WANObjectCache" 2021-02-09 16:58:36 +00:00
Krinkle
0ec2643767 objectache: Revert "throw on Closure" in WANObjectCache
This reverts commit 4e94fa8812.

The extra serialization call here is not needed since storing
a value naturally results in serialization and thus exception
throwing already (hence the fatal error at T273242).
Performing serialization twice comes with a significant cost,
which has in past led to notable regressions.

Adding a try-catch makes sense, but this can be placed at a
higher level instead, as is already done by Ibfcbf0eceb4b7a36
which was already merged and back-ported, making this obsolete.

Other use cases:

- Continuous integration where HashBag is used, which doesn't
  need serialize and thus doesn't cover the Closure issue.
  Cost of serialize was removed there for performance reasons,
  but if we want to add it back, let's do so there in the natural
  place where it once was (or in MediumBag, which might be preferable
  so that we can use that same code path to gradually switch to JSON
  encoding and warn/throw for non-jsonic values).

- Regular getWithSet calls (rather than the async refresh from which
  the fatal is currently seen). For regular getWithSet calls we already
  get a useful stack trace that points directly to the line of code
  where the value and cache key are computed, so additional logging
  does not seem that valuable. But for consistency we could move the
  try-catch from Ibfcbf0eceb4b7a36e33a8 a little lower to cover all
  fetchOrRegenerate() calls, not just those from scheduleAsyncRefresh.

Bug: T273242
Change-Id: Ic649016dde7b58323a028ce6d4fe617ef62a1ff8
2021-02-09 16:27:48 +00:00
jenkins-bot
726f87c0c6 Merge "WANObjectCache: throw on Closure" 2021-02-09 13:35:31 +00:00
daniel
4e94fa8812 WANObjectCache: throw on Closure
Alternative to Ia91d9f8533d4cc58564473ee9a375ba6be90eb64

Bug: T273242
Change-Id: I76a6667a1fcdc35ff972ebcdf1ad0b95ef07e015
2021-02-09 11:10:41 +00:00
Umherirrender
a1de8b8700 Tests: Mark more more closures as static
Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208

Bug: T274036
Change-Id: I695873737167a75f0d94901fa40383a33984ca55
2021-02-09 02:55:57 +00:00
Reedy
729f20afc8 Tests: Mark more closures as static
Bug: T274036
Change-Id: I911d3041cebe417d162934223b46ea295c6d20e3
2021-02-07 13:26:56 +01:00