XF 2.2 Error: Too many files open

djbaxter

in memoriam 1947-2022
I've been getting these errors while/after trying to upgrade to XenForo 2.2.8 Patch 1:

Code:
Server error log

    ErrorException: Fatal Error: Uncaught ErrorException: [E_WARNING] Unknown: failed to open stream: Too many open files in Unknown:0 Stack trace: #0 [internal function]: XF::handlePhpError(2, '[E_WARNING] Unk...', 'Unknown', 0, NULL) #1 {main} thrown Unknown:0 

    Generated by: djbaxter Apr 7, 2022 at 6:04 PM 

Stack trace

#0 [internal function]: XF::handleFatalError()
#1 {main}

Request state

array(4) {
  ["url"] => string(30) "/forum/admin.php?tools/run-job"
  ["referrer"] => string(53) "https://{DOMAIN}/forum/admin.php?tools/run-job"
  ["_GET"] => array(1) {
    ["tools/run-job"] => string(0) ""
  }
  ["_POST"] => array(3) {
    ["_xfRedirect"] => string(16) "/forum/admin.php"
    ["_xfToken"] => string(8) "********"
    ["only_ids"] => string(0) ""
  }
}

Code:
Server error log

    ErrorException: [E_WARNING] include(/home/customer/www/{DOMAIN}/public_html/forum/src/XF/Mvc/Reply/Reroute.php): failed to open stream: Too many open files src/vendor/composer/ClassLoader.php:571 

    Generated by: djbaxter Apr 7, 2022 at 6:04 PM 

Stack trace

#0 src/vendor/composer/ClassLoader.php(571): XF::handlePhpError(2, '[E_WARNING] inc...', '/home/customer/...', 571, Array)
#1 src/vendor/composer/ClassLoader.php(571): include()
#2 src/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/home/customer/...')
#3 [internal function]: Composer\Autoload\ClassLoader->loadClass('XF\\Mvc\\Reply\\Re...')
#4 src/XF/Mvc/Dispatcher.php(234): spl_autoload_call('XF\\Mvc\\Reply\\Re...')
#5 src/XF/Mvc/Dispatcher.php(123): XF\Mvc\Dispatcher->handleControllerError(Object(ErrorException), true, Object(Hampel\WhatsNewDigest\XF\Admin\Controller\Tools), Array)
#6 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#7 src/XF/App.php(2351): XF\Mvc\Dispatcher->run()
#8 src/XF.php(517): XF\App->run()
#9 admin.php(13): XF::runApp('XF\\Admin\\App')
#10 {main}

Request state

array(4) {
  ["url"] => string(30) "/forum/admin.php?tools/run-job"
  ["referrer"] => string(53) "https://{DOMAIN}/forum/admin.php?tools/run-job"
  ["_GET"] => array(1) {
    ["tools/run-job"] => string(0) ""
  }
  ["_POST"] => array(3) {
    ["_xfRedirect"] => string(16) "/forum/admin.php"
    ["_xfToken"] => string(8) "********"
    ["only_ids"] => string(0) ""
  }
}

Code:
Server error log

    ErrorException: [E_WARNING] file_put_contents(/home/customer/www/{DOMAIN}/public_html/forum/internal_data/code_cache/templates/l1/s26/public/push_resource_rating_pre_reg.php): failed to open stream: Too many open files src/vendor/league/flysystem/src/Adapter/Local.php:199 

    Generated by: djbaxter Apr 7, 2022 at 6:04 PM 

Stack trace

#0 [internal function]: XF::handlePhpError(2, '[E_WARNING] fil...', '/home/customer/...', 199, Array)
#1 src/vendor/league/flysystem/src/Adapter/Local.php(199): file_put_contents('/home/customer/...', '<?php
// FROM H...', 2)
#2 src/vendor/league/flysystem/src/Filesystem.php(99): League\Flysystem\Adapter\Local->update('templates/l1/s2...', '<?php
// FROM H...', Object(League\Flysystem\Config))
#3 [internal function]: League\Flysystem\Filesystem->put('templates/l1/s2...', '<?php
// FROM H...', Object(League\Flysystem\Config))
#4 src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php(431): call_user_func_array('parent::put', Array)
#5 src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php(395): League\Flysystem\EventableFilesystem\EventableFilesystem->callFilesystemMethod('put', Array)
#6 src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php(57): League\Flysystem\EventableFilesystem\EventableFilesystem->delegateMethodCall('put', Array)
#7 src/vendor/league/flysystem/src/MountManager.php(597): League\Flysystem\EventableFilesystem\EventableFilesystem->put('templates/l1/s2...', '<?php
// FROM H...', Array)
#8 src/XF/Util/File.php(199): League\Flysystem\MountManager->put('templates/l1/s2...', '<?php
// FROM H...', Array)
#9 src/XF/Service/Template/Compile.php(146): XF\Util\File::writeToAbstractedPath('code-cache://te...', '<?php
// FROM H...')
#10 src/XF/Service/Template/Compile.php(43): XF\Service\Template\Compile->writeCompiled(Object(XF\Entity\Template), 'code-cache://te...', 'return array(
'...')
#11 src/XF/Job/TemplateRebuild.php(87): XF\Service\Template\Compile->recompile(Object(XF\Entity\Template))
#12 src/XF/Job/Atomic.php(40): XF\Job\TemplateRebuild->run(1.19726)
#13 src/XF/Job/Manager.php(260): XF\Job\Atomic->run(8)
#14 src/XF/Job/Manager.php(202): XF\Job\Manager->runJobInternal(Array, 8)
#15 src/XF/Job/Manager.php(86): XF\Job\Manager->runJobEntry(Array, 8)
#16 src/XF/Admin/Controller/Tools.php(141): XF\Job\Manager->runQueue(true, 8)
#17 src/XF/Mvc/Dispatcher.php(352): XF\Admin\Controller\Tools->actionRunJob(Object(XF\Mvc\ParameterBag))
#18 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XF:Tools', 'RunJob', Object(XF\Mvc\RouteMatch), Object(Hampel\WhatsNewDigest\XF\Admin\Controller\Tools), NULL)
#19 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(Hampel\WhatsNewDigest\XF\Admin\Controller\Tools), NULL)
#20 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#21 src/XF/App.php(2351): XF\Mvc\Dispatcher->run()
#22 src/XF.php(517): XF\App->run()
#23 admin.php(13): XF::runApp('XF\\Admin\\App')
#24 {main}

Request state

array(4) {
  ["url"] => string(30) "/forum/admin.php?tools/run-job"
  ["referrer"] => string(53) "https://{DOMAIN}/forum/admin.php?tools/run-job"
  ["_GET"] => array(1) {
    ["tools/run-job"] => string(0) ""
  }
  ["_POST"] => array(3) {
    ["_xfRedirect"] => string(16) "/forum/admin.php"
    ["_xfToken"] => string(8) "********"
    ["only_ids"] => string(0) ""
  }
}

How do I fix this so that the Xenforo update can complete? Or what's the best way to resolve this?
 
Turned out to be exactly what is suggested: number of open files set too low.

RLIMIT_OFILE

Previously set to about 1024. Reset to 4096. Still too many open files.

Reset to 8192. No errors.
 
Back
Top Bottom