Page MenuHomePhabricator

PHP Warning: include(/srv/mediawiki/php-master/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php): Failed to open stream: Too many open files
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   PHP Warning: include(/srv/mediawiki/php-master/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php): Failed to open stream: Too many open files
FrameLocationCall
from/srv/mediawiki/php-master/vendor/composer/ClassLoader.php(576)
#0/srv/mediawiki/php-master/vendor/composer/ClassLoader.php(576)MWExceptionHandler::handleError(int, string, string, int)
#1/srv/mediawiki/php-master/vendor/composer/ClassLoader.php(576)include()
#2/srv/mediawiki/php-master/vendor/composer/ClassLoader.php(427)Composer\Autoload\{closure}(string)
#3/srv/mediawiki/php-master/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(275)Composer\Autoload\ClassLoader->loadClass(string)
#4/srv/mediawiki/php-master/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(205)GuzzleHttp\Handler\CurlFactory::createRejection(GuzzleHttp\Handler\EasyHandle, array)
#5/srv/mediawiki/php-master/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(157)GuzzleHttp\Handler\CurlFactory::finishError(GuzzleHttp\Handler\CurlHandler, GuzzleHttp\Handler\EasyHandle, GuzzleHttp\Handler\CurlFactory)
#6/srv/mediawiki/php-master/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php(47)GuzzleHttp\Handler\CurlFactory::finish(GuzzleHttp\Handler\CurlHandler, GuzzleHttp\Handler\EasyHandle, GuzzleHttp\Handler\CurlFactory)
#7/srv/mediawiki/php-master/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(28)GuzzleHttp\Handler\CurlHandler->__invoke(GuzzleHttp\Psr7\Request, array)
#8/srv/mediawiki/php-master/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(48)GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(GuzzleHttp\Psr7\Request, array)
#9/srv/mediawiki/php-master/vendor/guzzlehttp/guzzle/src/Middleware.php(207)GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(GuzzleHttp\Psr7\Request, array)
#10/srv/mediawiki/php-master/vendor/guzzlehttp/guzzle/src/Middleware.php(248)GuzzleHttp\Middleware::GuzzleHttp\{closure}(GuzzleHttp\Psr7\Request, array)
#11/srv/mediawiki/php-master/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php(35)GuzzleHttp\Middleware::GuzzleHttp\{closure}(GuzzleHttp\Psr7\Request, array)
#12/srv/mediawiki/php-master/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(55)GuzzleHttp\PrepareBodyMiddleware->__invoke(GuzzleHttp\Psr7\Request, array)
#13/srv/mediawiki/php-master/vendor/guzzlehttp/guzzle/src/Middleware.php(63)GuzzleHttp\RedirectMiddleware->__invoke(GuzzleHttp\Psr7\Request, array)
#14/srv/mediawiki/php-master/vendor/guzzlehttp/guzzle/src/HandlerStack.php(75)GuzzleHttp\Middleware::GuzzleHttp\{closure}(GuzzleHttp\Psr7\Request, array)
#15/srv/mediawiki/php-master/vendor/guzzlehttp/guzzle/src/Client.php(333)GuzzleHttp\HandlerStack->__invoke(GuzzleHttp\Psr7\Request, array)
#16/srv/mediawiki/php-master/vendor/guzzlehttp/guzzle/src/Client.php(107)GuzzleHttp\Client->transfer(GuzzleHttp\Psr7\Request, array)
#17/srv/mediawiki/php-master/vendor/guzzlehttp/guzzle/src/Client.php(124)GuzzleHttp\Client->sendAsync(GuzzleHttp\Psr7\Request, array)
#18/srv/mediawiki/php-master/includes/http/GuzzleHttpRequest.php(216)GuzzleHttp\Client->send(GuzzleHttp\Psr7\Request)
#19/srv/mediawiki/php-master/includes/filerepo/ForeignAPIRepo.php(562)GuzzleHttpRequest->execute()
#20/srv/mediawiki/php-master/includes/filerepo/ForeignAPIRepo.php(609)MediaWiki\FileRepo\ForeignAPIRepo::httpGet(string, string, array, null)
#21/srv/mediawiki/php-master/includes/libs/objectcache/WANObjectCache.php(1835)MediaWiki\FileRepo\ForeignAPIRepo->MediaWiki\FileRepo\{closure}(bool, int, array, null, array)
#22/srv/mediawiki/php-master/includes/libs/objectcache/WANObjectCache.php(1640)Wikimedia\ObjectCache\WANObjectCache->fetchOrRegenerate(string, int, Closure, array, array)
#23/srv/mediawiki/php-master/includes/filerepo/ForeignAPIRepo.php(621)Wikimedia\ObjectCache\WANObjectCache->getWithSetCallback(string, int, Closure, array)
#24/srv/mediawiki/php-master/includes/filerepo/ForeignAPIRepo.php(228)MediaWiki\FileRepo\ForeignAPIRepo->httpGetCached(string, array, int)
#25/srv/mediawiki/php-master/includes/filerepo/ForeignAPIRepo.php(299)MediaWiki\FileRepo\ForeignAPIRepo->fetchImageQuery(array)
#26/srv/mediawiki/php-master/includes/filerepo/ForeignAPIRepo.php(371)MediaWiki\FileRepo\ForeignAPIRepo->getThumbUrl(string, float, int, null, string)
#27/srv/mediawiki/php-master/includes/filerepo/file/ForeignAPIFile.php(148)MediaWiki\FileRepo\ForeignAPIRepo->getThumbUrlFromCache(string, float, int, string)
#28/srv/mediawiki/php-master/includes/linker/Linker.php(904)MediaWiki\FileRepo\File\ForeignAPIFile->transform(array)
#29/srv/mediawiki/php-master/includes/linker/Linker.php(826)MediaWiki\Linker\Linker::processResponsiveImages(MediaWiki\FileRepo\File\ForeignAPIFile, ThumbnailImage, array)
#30/srv/mediawiki/php-master/includes/linker/Linker.php(447)MediaWiki\Linker\Linker::makeThumbLink2(MediaWiki\Title\Title, MediaWiki\FileRepo\File\ForeignAPIFile, array, array, bool, bool, array, MediaWiki\Parser\Parser)
#31/srv/mediawiki/php-master/includes/parser/Parser.php(5664)MediaWiki\Linker\Linker::makeImageLink(MediaWiki\Parser\Parser, MediaWiki\Title\Title, MediaWiki\FileRepo\File\ForeignAPIFile, array, array, bool, bool, int)
#32/srv/mediawiki/php-master/includes/parser/Parser.php(2714)MediaWiki\Parser\Parser->makeImage(MediaWiki\Title\Title, array, MediaWiki\Parser\LinkHolderArray)
#33/srv/mediawiki/php-master/includes/parser/Parser.php(2461)MediaWiki\Parser\Parser->handleInternalLinks2(string)
#34/srv/mediawiki/php-master/includes/parser/Parser.php(1629)MediaWiki\Parser\Parser->handleInternalLinks(string)
#35/srv/mediawiki/php-master/includes/parser/Parser.php(700)MediaWiki\Parser\Parser->internalParse(string)
#36/srv/mediawiki/php-master/includes/content/WikitextContentHandler.php(380)MediaWiki\Parser\Parser->parse(string, MediaWiki\Title\Title, MediaWiki\Parser\ParserOptions, bool, bool, int)
#37/srv/mediawiki/php-master/includes/content/ContentHandler.php(1685)MediaWiki\Content\WikitextContentHandler->fillParserOutput(MediaWiki\Content\WikitextContent, MediaWiki\Content\Renderer\ContentParseParams, MediaWiki\Parser\ParserOutput)
#38/srv/mediawiki/php-master/includes/content/Renderer/ContentRenderer.php(75)MediaWiki\Content\ContentHandler->getParserOutput(MediaWiki\Content\WikitextContent, MediaWiki\Content\Renderer\ContentParseParams)
#39/srv/mediawiki/php-master/includes/Revision/RenderedRevision.php(261)MediaWiki\Content\Renderer\ContentRenderer->getParserOutput(MediaWiki\Content\WikitextContent, MediaWiki\Page\PageIdentityValue, MediaWiki\Revision\RevisionStoreRecord, MediaWiki\Parser\ParserOptions, array)
#40/srv/mediawiki/php-master/includes/Revision/RenderedRevision.php(233)MediaWiki\Revision\RenderedRevision->getSlotParserOutputUncached(MediaWiki\Content\WikitextContent, array)
#41/srv/mediawiki/php-master/includes/Revision/RevisionRenderer.php(236)MediaWiki\Revision\RenderedRevision->getSlotParserOutput(string, array)
#42/srv/mediawiki/php-master/includes/Revision/RevisionRenderer.php(169)MediaWiki\Revision\RevisionRenderer->combineSlotOutput(MediaWiki\Revision\RenderedRevision, MediaWiki\Parser\ParserOptions, array)
#43/srv/mediawiki/php-master/includes/Revision/RenderedRevision.php(196)MediaWiki\Revision\RevisionRenderer->MediaWiki\Revision\{closure}(MediaWiki\Revision\RenderedRevision, array)
#44/srv/mediawiki/php-master/includes/poolcounter/PoolWorkArticleView.php(106)MediaWiki\Revision\RenderedRevision->getRevisionParserOutput()
#45/srv/mediawiki/php-master/includes/poolcounter/PoolWorkArticleViewCurrent.php(123)MediaWiki\PoolCounter\PoolWorkArticleView->renderRevision(null, bool, string)
#46/srv/mediawiki/php-master/includes/poolcounter/PoolCounterWork.php(161)MediaWiki\PoolCounter\PoolWorkArticleViewCurrent->doWork()
#47/srv/mediawiki/php-master/includes/page/ParserOutputAccess.php(369)MediaWiki\PoolCounter\PoolCounterWork->execute()
#48/srv/mediawiki/php-master/includes/page/Article.php(836)MediaWiki\Page\ParserOutputAccess->getParserOutput(MediaWiki\Page\WikiPage, MediaWiki\Parser\ParserOptions, MediaWiki\Revision\RevisionStoreRecord, int)
#49/srv/mediawiki/php-master/includes/page/Article.php(552)MediaWiki\Page\Article->generateContentOutput(MediaWiki\User\User, MediaWiki\Parser\ParserOptions, int, MediaWiki\Output\OutputPage, array)
#50/srv/mediawiki/php-master/includes/actions/ViewAction.php(80)MediaWiki\Page\Article->view()
#51/srv/mediawiki/php-master/includes/actions/ActionEntryPoint.php(728)MediaWiki\Actions\ViewAction->show()
#52/srv/mediawiki/php-master/includes/actions/ActionEntryPoint.php(505)MediaWiki\Actions\ActionEntryPoint->performAction(MediaWiki\Page\Article, MediaWiki\Title\Title)
#53/srv/mediawiki/php-master/includes/actions/ActionEntryPoint.php(143)MediaWiki\Actions\ActionEntryPoint->performRequest()
#54/srv/mediawiki/php-master/includes/MediaWikiEntryPoint.php(202)MediaWiki\Actions\ActionEntryPoint->execute()
#55/srv/mediawiki/php-master/index.php(58)MediaWiki\MediaWikiEntryPoint->run()
#56/srv/mediawiki/w/index.php(3)require(string)
#57{main}
Impact
Notes

Details

Request URL
https://en.wikipedia.beta.wmflabs.org/wiki/Turkey
Related Changes in Gerrit:

Event Timeline

"Too many open files" should be a transient problem. Searching for "Too many open files" in the last 7 days of beta cluster logging (https://beta-logs.wmcloud.org/goto/1a495e8c49d87cef66f0bdecdcd739bf) shows that it happens on deployment-mediawiki14 (the only web request facing MediaWiki in beta right now) in bursts. This could just be a sign of traffic patterns that overload the instance.

It is also reasonable to consider that there is some ulimit tweak that happens for the php-fpm process in production that isn't applied on the deployment-prep instances, but a quick git grep -l LimitNOFILE in ops/puppet.git doesn't turn up any obvious candidates.

Rechecking that happens once per hour.

Prod baremetal had the limit overriden in the systemd unit:

modules/profile/templates/mediawiki/php-fpm-systemd-override.conf.erb
[Service]
...
<%- if @increase_open_files -%>
LimitNOFILE=1024000
LimitNOFILESoft=1024000
<%- end -%>

Which was made True for jobrunners with 764a3d1d23964517eb761d9f2e6d6ccf9efe1f8a / T344428.

For MediaWiki on Kubernetes I have found in operations/deployment-charts:

LimitNOFILE=1048576
LimitNOFILESoft=1048576

The php8.1-fpm.service unit has:

LimitNOFILE=524288
LimitNOFILESoft=1024

That is the systemd default according to /etc/systemd/system.conf: #DefaultLimitNOFILE=1024:524288.

The still existing php7.4-fpm.service one had:

LimitNOFILE=1048576
LimitNOFILESoft=1048576

I don't know why or how it was raised, maybe the system.conf was set differently for MediaWiki app servers.

Anyway the fix is to apply to the deployment-mediawiki Puppet prefix:

profile::mediawiki::php::increase_open_files: True

I ran Puppet on deployment-mediawiki14, the systemd override has been reloaded and:

$ systemctl show php8.1-fpm.service|grep LimitNO
LimitNOFILE=1024000
LimitNOFILESoft=1024000

The LimitNOFILE was thus raised from 524288 to 1024000 which should solve the issue.


Looking at the unit it complains about a non existing LimitNOFILESSoft:

Apr 10 14:17:36 deployment-mediawiki14 systemd[1]: /etc/systemd/system/php8.1-fpm.service.d/puppet-override.conf:7: Unknown key name 'LimitNOFILESoft' in section 'Service', ignoring.

LimitNOFILESoft is in the DBUS specification but systemd uses <soft>:<hard> to define the limits (see https://github.com/systemd/systemd/pull/1994 ) and from systemd.exec(5):

Resource limits may be specified in two formats:

  • either as single value to set a specific soft and hard limit to the same value,

or

  • as colon-separated pair soft:hard to set both limits individually (e.g. "LimitAS=4G:16G").

Use the string infinity to configure no limit on a specific resource.
The multiplicative suffixes K, M, G, T, P and E (to the base 1024) may be used for resource limits measured in bytes (e.g. "LimitAS=16G").

Change #1135743 had a related patch set uploaded (by Hashar; author: Hashar):

[operations/puppet@production] mediawiki: remove unsupported LimitNOFILESoft directive

https://gerrit.wikimedia.org/r/1135743

Change #1135743 merged by Clément Goubert:

[operations/puppet@production] mediawiki: remove unsupported LimitNOFILESoft directive

https://gerrit.wikimedia.org/r/1135743

This can be close in a few days after we have it is confirmed the Too many open files errors are gone: https://beta-logs.wmcloud.org/goto/1a495e8c49d87cef66f0bdecdcd739bf

bd808 changed the task status from Open to In Progress.Apr 10 2025, 5:48 PM
bd808 assigned this task to hashar.
bd808 moved this task from To Triage to Backlog on the Beta-Cluster-Infrastructure board.

Thank you for the verification and I am quite happy we have managed to fix that one!