Active
Project:
Automatic Updates
Version:
3.0.x-dev
Component:
Code
Priority:
Critical
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
2 May 2023 at 12:08 UTC
Updated:
3 May 2023 at 16:27 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
wim leersHigh-level observation
🤔 Is it really safe to do the whole stage life cycle in a single request during cron updates, but using multiple requests (because batch) while using the UI?
Crash in real world
Thanks for creating this issue, @tedbow. Earlier today, while pairing with @Omkar.Podey, I actually SAW IT CRASH MID-REQUEST, and then it was impossible to delete the stage using the UI, because it was presumed to still be applying! (see
\Drupal\package_manager\StageBase::isApplying()) 😨(To be fair, XDebug was on, but even without XDebug, we have to assume at least the network could be slow. Fetching a Drupal core update is multiple megabytes.)
PHP's
max_execution_timeandset_time_limit()PHP's
max_execution_timedefaults to 30s, which is really risky/close. 😱 Even for batch processing this is risky; for this very reason e.g. the migration system has special measures in place:\Drupal\migrate_drupal_ui\Batch\MigrateUpgradeImportBatch::run()— introduced by #2281691: User interface for migration-based upgrades.The issue summary says:
But I was unable to find it doing anything relating to
max_execution_time. I dug deeper. Apparently\Drupal\Core\Cron::runcalls\Drupal\Component\Utility\Environment::setTimeLimit()with$time_limit = 240, which in turn calls PHP'sset_time_limit()(so: 4 minutes instead of the default of 0.5).TIL!
php-tuf/composer-stagerAnd not only Drupal core's
Cronclass uses it, so do\PhpTuf\ComposerStager\Infrastructure\Service\FileSyncer\PhpFileSyncer::sync()and\PhpTuf\ComposerStager\Infrastructure\Service\FileSyncer\RsyncFileSyncer::sync().Limitations of
set_time_limit()But …
set_time_limit()may be disabled by the site administrator — see the docblock on\Drupal\Component\Utility\Environment::setTimeLimit()mod_fastcgi,mod_fcgid,php-fpmetc. all have their own time limits too!Conclusion
So I think we need:
set_time_limit()is availablelocale_cron()which only callslocale_cron_fill_queue()and then has a corrresponding@QueueWorkerplugin:\Drupal\locale\Plugin\QueueWorker\LocaleTranslationMore investigation needed. But given how this will very likely result in problems on real-world test sites, bumping to .
Comment #3
wim leersIn addition to the 2 issues above:
FailureMarkergets created if the PHP execution time is exceeded — without that, there's just a silent failure which is nearly impossible to debug. That's what @Omkar.Podey ran into over at #3355446: [PP-1] Implement experimental cron updates for contrib in automatic_updates_extensions.Comment #4
omkar.podey commentedfor reference to the
in #2

Comment #5
wim leersIssue for the third follow-up: #3357941: Write helpful message to FailureMarker if script execution time was exceeded during stage life cycle.
I think we should convert this to a meta, since it's not clear how to document all this until the follow-ups are done? 🤔 Tentatively retitling to and recategorizing as .
Comment #6
tedbowcreated #3357969: For web server dependent unattended updates run the entire life cycle in a separate process that will not be affected by hosting time limits
See the issue for detail but I am not positive we should be using cron at all