Page MenuHomePhabricator

RenderTranslationPageJob: Sessions can only be imported when none is active.
Closed, ResolvedPublic4 Estimated Story PointsBUG REPORT

Description

When making a translation to a translatable page, an error from job queue appears:

Sessions can only be imported when none is active. at /srv/mediawiki/tags/2025-09-10_14:36:16/includes/context/RequestContext.php:686)
[stacktrace]
#0 /srv/mediawiki/tags/2025-09-10_14:36:16/extensions/Translate/src/PageTranslation/RenderTranslationPageJob.php(86): MediaWiki\\Context\\RequestContext::importScopedSession()
#1 /srv/mediawiki/tags/2025-09-10_14:36:16/includes/jobqueue/JobRunner.php(381): MediaWiki\\Extension\\Translate\\PageTranslation\\RenderTranslationPageJob->run()
#2 /srv/mediawiki/tags/2025-09-10_14:36:16/includes/jobqueue/JobRunner.php(339): MediaWiki\\JobQueue\\JobRunner->doExecuteJob()
#3 /srv/mediawiki/tags/2025-09-10_14:36:16/includes/jobqueue/JobRunner.php(234): MediaWiki\\JobQueue\\JobRunner->executeJob()
#4 /srv/mediawiki/tags/2025-09-10_14:36:16/maintenance/runJobs.php(107): MediaWiki\\JobQueue\\JobRunner->run()
#5 /srv/mediawiki/tags/2025-09-10_14:36:16/maintenance/includes/MaintenanceRunner.php(696): RunJobs->execute()
#6 /srv/mediawiki/tags/2025-09-10_14:36:16/maintenance/run.php(53): MediaWiki\\Maintenance\\MaintenanceRunner->run()
#7 {main}

This seems to be accompanied with:

Container disabled! at /srv/mediawiki/tags/2025-09-10_14:36:16/vendor/wikimedia/services/src/ServiceContainer.php:398)
[stacktrace]
#0 /srv/mediawiki/tags/2025-09-10_14:36:16/includes/MediaWikiServices.php(381): Wikimedia\\Services\\ServiceContainer->getService()
#1 /srv/mediawiki/tags/2025-09-10_14:36:16/vendor/wikimedia/services/src/ServiceContainer.php(414): MediaWiki\\MediaWikiServices->getService()
#2 /srv/mediawiki/tags/2025-09-10_14:36:16/vendor/wikimedia/object-factory/src/ObjectFactory.php(204): Wikimedia\\Services\\ServiceContainer->get()
#3 /srv/mediawiki/tags/2025-09-10_14:36:16/vendor/wikimedia/object-factory/src/ObjectFactory.php(149): Wikimedia\\ObjectFactory\\ObjectFactory::getObjectFromSpec()
#4 /srv/mediawiki/tags/2025-09-10_14:36:16/includes/session/SessionManager.php(537): Wikimedia\\ObjectFactory\\ObjectFactory->createObject()
#5 /srv/mediawiki/tags/2025-09-10_14:36:16/includes/session/SessionManager.php(569): MediaWiki\\Session\\SessionManager->getProviders()
#6 /srv/mediawiki/tags/2025-09-10_14:36:16/includes/session/SessionManager.php(738): MediaWiki\\Session\\SessionManager->getProvider()
#7 /srv/mediawiki/tags/2025-09-10_14:36:16/includes/session/SessionManager.php(202): MediaWiki\\Session\\SessionManager->loadSessionInfoFromStore()
#8 /srv/mediawiki/tags/2025-09-10_14:36:16/includes/session/PHPSessionHandler.php(216): MediaWiki\\Session\\SessionManager->getSessionById()
#9 [internal function]: MediaWiki\\Session\\PHPSessionHandler->read()
#10 /srv/mediawiki/tags/2025-09-10_14:36:16/vendor/wikimedia/at-ease/src/AtEase.php(88): session_start()
#11 /srv/mediawiki/tags/2025-09-10_14:36:16/includes/context/RequestContext.php(737): Wikimedia\\AtEase\\AtEase::quietCall()
#12 /srv/mediawiki/tags/2025-09-10_14:36:16/includes/context/RequestContext.php(754): MediaWiki\\Context\\RequestContext::MediaWiki\\Context\\{closure}()
#13 /srv/mediawiki/tags/2025-09-10_14:36:16/extensions/Translate/src/PageTranslation/RenderTranslationPageJob.php(86): MediaWiki\\Context\\RequestContext::importScopedSession()
#14 /srv/mediawiki/tags/2025-09-10_14:36:16/includes/jobqueue/JobRunner.php(381): MediaWiki\\Extension\\Translate\\PageTranslation\\RenderTranslationPageJob->run()
#15 /srv/mediawiki/tags/2025-09-10_14:36:16/includes/jobqueue/JobRunner.php(339): MediaWiki\\JobQueue\\JobRunner->doExecuteJob()
#16 /srv/mediawiki/tags/2025-09-10_14:36:16/includes/jobqueue/JobRunner.php(234): MediaWiki\\JobQueue\\JobRunner->executeJob()
#17 /srv/mediawiki/tags/2025-09-10_14:36:16/maintenance/runJobs.php(107): MediaWiki\\JobQueue\\JobRunner->run()
#18 /srv/mediawiki/tags/2025-09-10_14:36:16/maintenance/includes/MaintenanceRunner.php(696): RunJobs->execute()
#19 /srv/mediawiki/tags/2025-09-10_14:36:16/maintenance/run.php(53): MediaWiki\\Maintenance\\MaintenanceRunner->run()
#20 {main}

Event Timeline

Nikerabbit set the point value for this task to 4.

Very spammy in the logs. Potentially breaks all translatable page updating on translatewiki.net

We had a couple session handling changes, none of them obviously related:

RequestContext::importScopedSession() should be called when there is no current session, and the imported session is cleaned up at the end of the scope. Maybe that doesn't work and the session bleeds from one job into the other?

RenderTranslationPageJob does

if ( isset( $this->params['session'] ) ) {
	$scope = RequestContext::importScopedSession( $this->params['session'] );
	$this->addTeardownCallback( static function () use ( &$scope ) {
		ScopedCallback::consume( $scope );
	} );
}

which means the session won't be cleared until the teardown callback (seems pointless, why not just let it happen at the end of the method when local variables go out of scope?), so maybe the teardown callback is not called due to some kind of cascading failure and the session imports overlap? Seems implausible that it would happen a lot, though.

No clue about the container thing or how it's connected.

I think a good first step would be to just log it when sesson IDs are imported and cleaned up, and log the conflicting session ID, and try to establish what's going on there (overlap with the previous job? Some kind of recursion in run()?)

Thanks for the tips. Based on my investigation the root cause is actually the Container disabled! exception. This seems to leave the session on regardless whether we have the teardown callback or not.

Conditions to reproduce:

  • Translate an item of a translatable page (or create any kind of job that uses importScopedSession)
  • Execute job queue with --procs=2 (or higher)

Container disabled! exception appears because --procs parameter causes forking using ForkController, which calls \MediaWiki\Maintenance\ForkController::prepareEnvironment, which resets service container.

This is a problem because SessionManager(537) hold a reference to ObjectFactory that is now disabled.

Currently using a workaround that requires carrying a local patch on the config repo. Waiting for a fix in core.

Nikerabbit changed the task status from Stalled to Open.Nov 6 2025, 7:26 AM
Nikerabbit removed Nikerabbit as the assignee of this task.
Nikerabbit moved this task from Backlog to Ready for dev on the LPL Essential (FY2025-26 Q2) board.

Subtask is ready for testing.

Nikerabbit lowered the priority of this task from High to Medium.Nov 11 2025, 8:28 AM
abi_ subscribed.

Currently using a workaround that requires carrying a local patch on the config repo. Waiting for a fix in core.

Dropped this local patch. Don't see any logspam.

Currently using a workaround that requires carrying a local patch on the config repo. Waiting for a fix in core.

Dropped this local patch. Don't see any logspam.

The logspam started again after a couple of hours.

Nikerabbit raised the priority of this task from Medium to High.Nov 13 2025, 7:55 AM

The logspam started again after a couple of hours.

This can be tested by making translations to translatable pages. There is no need to wait.

Nikerabbit lowered the priority of this task from High to Medium.Nov 13 2025, 7:55 AM
Nikerabbit changed the task status from Open to Stalled.Nov 17 2025, 7:43 AM
Nikerabbit moved this task from In Progress to Backlog on the LPL Essential (FY2025-26 Q2) board.
Nikerabbit claimed this task.
Nikerabbit moved this task from Backlog to Done on the LPL Essential (FY2025-26 Q2) board.