Page MenuHomePhabricator

Deferred CdnCacheUpdate only sends request when return value is saved
Open, Needs TriagePublic

Description

I am seeing a very weird bug where CdnCacheUpdate only sends PURGE requests to varnish, if the return value of $http->runMulti() is saved to a variable.

Changing https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/refs/heads/REL1_35/includes/deferred/CdnCacheUpdate.php#318 from
changing $http->runMulti( $reqs ); to $val = $http->runMulti( $reqs ); sends the purge request to varnish else nothing gets sent.

In this setup MediaWiki runs in a docker container with a varnish container in the same network. I've tested my varnish.vcl thoroughly, invalid permissions aren't the issue.
Manually sending PURGE requests using curl do result in the cache being purged.

Furthermore I manually edited HtmlCacheUpdater::purgeUrls to disable deferred updates which too results in the cache being purged, only when DeferredUpdates are active no request gets send.


I am using the official MW Docker image tagged at 1.35.2 with no modifications to php.ini.
Here is the Dockerfile used to build the container GitHub Dockerfile

Event Timeline

Debugging another problem, with tcpdump, I could see sometimes, after saving a page, the PURGE is not sent at all, and it seems to be random,

Normal TCP flow:

PHP     Varnish

------> SYN
<------ SYN,ACK
------> ACK
------> PUSH,ACK (packet content contains the actual PURGE HTTP request)

But sometimes I only see this:

PHP     Varnish

------> SYN
<------ SYN,ACK
------> ACK
(nothing more)

No packet content is sent (it hasn't reached the HTTP level). Hence, the page isn't purged.

Maybe it's just random? or some PHP optimization? I think the idea here is to send the PURGE request the fastest you can and forget about the response. Maybe we're forgetting too much about the response that PHP optimizes it to not sending the request at all, or closing the connection too early...

I've seen this on MW 1.36