Commit graph

19 commits

Author SHA1 Message Date
Amir Sarabadani
7690ab4e33 Reorg: Move HeaderCallback to Request directory
Cleaning root of includes/

Bug: T321882
Change-Id: I1844da95d4fd79824646fdf4b6063cb771ca3000
2022-11-08 10:53:27 +01:00
Zabe
f6b9381d7f Revert "Reorg: Move some of request related classes to MediaWiki/Request"
This reverts commit 2bdc0b2b72.

Reason for revert: T166010#8349431

Bug: T166010
Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
2022-10-27 13:14:16 +00:00
Amir Sarabadani
2bdc0b2b72 Reorg: Move some of request related classes to MediaWiki/Request
Moving:
 - DerivativeRequest
 - FauxRequest
 - FauxRequestUpload
 - PathRouter
 - WebRequest
 - WebRequestUpload

Bug: T166010
Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
2022-10-26 16:49:10 +02:00
Umherirrender
5c5498a202 Remove unused key variable from foreach loops
Change-Id: Id2d91e30a6f7cc4eb93427b50efc1c5c77f14b75
2022-09-21 21:18:43 +02:00
Timo Tijhof
5965ae141a ResourceLoader: Remove redundant getCombinedVersion() try-catch
The getCombinedVersion() method itself already catches errors
in its loop. There are no known exception that we know can happen
and would want to tolerate within the loop logic itself.

Empirically, there are indeed zero messages in WMF Logstash for the
past 30 days that contain "Calculating version hash failed". Other
diagnostic messages in channel:resourceloader do show up from time
to time, e.g. once a week or so, indicating that the other
conditions and this log method generally do work and are enabled.

Bug: T312806
Change-Id: I2fe5ad104a6404c53c1b73b259468a6ed1071936
2022-08-03 01:05:23 +00:00
Timo Tijhof
584d5dd163 ResourceLoader: Remove outer TimeoutException try-catch in respond()
Follows-up I4c3770b9ef. While timeouts in load.php are extremely
rare (one in 90 days?), we did find one in the perf-team Logstash
dashboard and it coincided with this runtime error as result of the
added try-catch:

> PHP Notice: Undefined variable: etag

Remove the try-catch and let these fatal the same way as other very
early or very late errors with HTTP 500 instead.

Bug: T312806
Change-Id: Iffb238de2243d0885dcf1d78fcce7827b09cb84d
2022-07-31 18:39:48 -07:00
jenkins-bot
82df7b7b63 Merge "tests: Remove intermediary suites concept from /tests/qunit" 2022-07-13 20:00:00 +00:00
jenkins-bot
352c68b793 Merge "ResourceLoader: Remove DependencyStore::renew" 2022-07-13 05:03:50 +00:00
Timo Tijhof
68d4fe68b9 tests: Remove intermediary suites concept from /tests/qunit
I don't recall why I added this. Possibly in a confused effort
to match /tests/phpunit, except /tests/phpunit/suites is not
where test cases live, they live under /tests/phpunit/* directly,
mostly /tests/phpunit/includes named after the source directory.
The correct equivalent to that is /tests/qunit/resources for JS.

While at it, also remove mention of this concept from various other
places where it doesn't add value. It's one more word/concept to
learn, process, understand, or translate mentally. They're just tests,
or for the one or two places where we care about how they are
internally transmitted, a "test module".

Bug: T250045
Change-Id: I5ea22e4965d190357aa69883f29f9049ee8ebf13
2022-07-13 01:52:57 +00:00
Timo Tijhof
1d66a22805 ResourceLoader: Remove DependencyStore::renew
== Background

When file dependency information is lost, the startup module computes
a hash that is based on an incomplete summary of bundled resources.
This means it arrives at a "wrong" hash. Once a browser actually asks
for that version of the module, though, we rediscover the dependency
information, and subsequent startup responses will include arrive once
again at the same correct hash. These 5-minute windows of time where
the browser cache of anyone visiting is churned over are not great,
and so we try to avoid them.

The status quo is the dedicated module_deps table in core with no
expiry. This means a potential concern is building up gargage over
time for modules and extensions that no longer exist or are no longer
deployed on that wiki. In practice this has not been much of an issue,
we haven't run the cleanupRemovedModules.php or purgeModuleDeps.php
scripts in years. Once in 2017 to fix corrupt rows (T158105), and
once in 2020 to estimate needed space if we had expiries
<https://phabricator.wikimedia.org/T113916#6142457>.

Hence we're moving to mainstash via KeyValueDepStore, and not to
memcached. But for that we might as well start using experies.

To not compromise on losing dep info regularly and causing avoidable
browser cache for modules that are hot and very much still existing,
we adopted `renew()` in 5282a0296 when drafting KeyValueDepStore, so that
we keep moving the TTL of active rows forward and let the rest naturally
expire.

== Problem

The changeTTL writes are so heavy and undebounced, that it fully
saturates the hardware disk, unable to keep up simply with the amount
of streaming append-only writes to disk.

https://phabricator.wikimedia.org/T312902

== Future

Perhaps we can make this work if SqlBagOStuff in "MainStash" mode
was more efficient and lenient around changeTTL. E.g. rather than
simultanously ensure presence of the row itself for perfect eventual
consistency, maybe it could just be a light "touch" to ensure the
TTL of any such row has a given minimum TTL.

Alternatively, if we don't make it part of the generalised
SqlBag/MainStash interface but something speciifc to KeyValueDepStore,
we could also do something several orders of magnitudes more efficient,
such as only touching it once a day or once a week, instead of several
hundred times a second after every read performing a write that
amplifies the read back into a full row write, with thus a very large
and repetative binlog.

== This change

As interim measure, I propose we remove renew() and instead increase
the TTL from 1 week to 1 year. This is still shorter than "indefinite"
which is what the module_deps table does in the status quo, and that
was never an issue in practice in terms of space. This is because
the list of modules modules is quite stable. It's limited to modules
that are both file-backed (so no gadgets) and also have non-trivial
file dependencies (such as styles.less -> foo.css -> bar.svg).

== Impact

The installer and update.php (DatabaseUpdater) already clear
`module_deps` and `objectcache` so this is a non-issue for third
parties.

For WMF, it means that the maintenance script we never ran, can
be removed as it will now automatically clean up this stuff after
a year of inactivity, with a small cache churn cost to pay at that
time.

Bug: T113916
Bug: T312902
Change-Id: Ie11bdfdcf5e6724bc19ac24e4353aaea316029fd
2022-07-12 15:25:39 -07:00
Timo Tijhof
e06081bbfd ResourceLoader: Restore 5min startup cache-control (was 60s)
Follows-up I81eb79cc5b398d95b6, which accidentally shortened this
to 60s.

Bug: T312796
Change-Id: I73b3144b9e461541b0c5c820dbdcaf90d8d1fa1a
2022-07-11 10:34:29 -07:00
Derick Alangi
ae22031299 ResourceLoader: Inject HookContainer & UserOptionsLookup to getUserDefaults
Change-Id: I328ee0f959f0898a7e2632dfcfa3e3bbb579106e
2022-07-01 00:53:37 +00:00
DannyS712
fd7f14a79e ResourceLoader: readability cleanup and simplifications
Use `continue` to reduce nesting, put `catch` on the same line
as the closing } from `try` (or a prior `catch` block), unhoist
variables, should be a no-op in terms of functionality.

Change-Id: Ibd3fe0708ecb25caaa72b189b9cfc68a3f2f23a0
2022-06-22 21:44:32 +00:00
Timo Tijhof
75a97c69a5 resourceloader: Separate error response from unversioned and shorten to 60s
5min seems like a long time to wait for a deployment race to
self-correct, likewise for internal errors that caused (part of)
a bundle to not be available.

I've shortened WMF's /w/static.php mismatch and error response to
1min caching for the same reason in e4468a4c942.

Change-Id: I81eb79cc5b398d95b6c3d5b52716dd74e62fa5eb
2022-06-02 18:29:07 +01:00
Timo Tijhof
519e95adc0 resourceloader: Decouple some internal constructor args
Move config defaults to ResourceLoader class, so that the defaults
reside within the component responsibility, and for future standalone
use and unit testing with the same set of defaults.

Bug: T32956
Change-Id: I4a268e11686e526c4377542d45e198a72e57f182
2022-06-02 18:27:33 +01:00
Timo Tijhof
85892edce5 resourceloader: Minor doc changes following PSR-4 namepace change
Follows Id08a220e1d60 (after I92998ae6a82e).

Change-Id: I33d20201bfee4595baa39c01eaf8b7de6034a8ed
2022-05-29 16:41:19 +00:00
Tim Starling
3e2653f83b ResourceLoader namespace (attempt 2)
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader itself.

Move the tests by analogy.

I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".

I did not address DependencyStore which continues to have a non-standard
location and namespace.

Revert of a241d83e0a.

Bug: T308718
Change-Id: Id08a220e1d6085e2b33f3f6c9d0e3935a4204659
2022-05-24 15:41:46 +00:00
Lucas Werkmeister (WMDE)
a241d83e0a Revert "ResourceLoader namespace"
This reverts commit e08ea8ccb9.

Reason for revert: Breaks Phan in extensions, and as far as I’m aware,
this change isn’t urgently needed for anything, so the simplest fix is
to revert it again for now. After PHP 7.4 it should be safer to try this
again (we hopefully won’t need the two “hack” classes by then).

Bug: T308443
Change-Id: Iff3318cbf97a67f821f78e60da62a583f63e389e
2022-05-16 14:43:33 +00:00
Tim Starling
e08ea8ccb9 ResourceLoader namespace
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader and
ResourceLoaderContext.

Move the tests by analogy.

I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".

I did not address DependencyStore which continues to have a non-standard
location and namespace.

Change-Id: I92998ae6a82e0b935c13e02a183e7c324fa410a3
2022-05-16 14:41:27 +10:00
Renamed from includes/resourceloader/ResourceLoader.php (Browse further)