Last modified: 2014-02-05 18:20:21 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T62231, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 60231 - on-request job queue running change to shell, still executing synchronously, blocking the request
on-request job queue running change to shell, still executing synchronously, ...
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
JobQueue (Other open bugs)
1.22.0
All Linux
: High major (vote)
: 1.22.x release
Assigned To: Aaron Schulz
: performance
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-01-19 15:55 UTC by Jesús Martínez Novo (Ciencia Al Poder)
Modified: 2014-02-05 18:20 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---
aklapper: Backport_to_Stable+


Attachments

Description Jesús Martínez Novo (Ciencia Al Poder) 2014-01-19 15:55:51 UTC
https://gerrit.wikimedia.org/r/#/c/59797/ changed the way jobs are executed on page loads, starting a new php shell to launch runJobs.php. The idea was to execute it asynchronously, so the server can send the page to the client and end the request without waiting for runJobs.php to end. However, this doesn't work.

I've just tested it, changing $wgPhpCli to a shell script with only a sleep command, and no other page would load until the sleep command ends.


According to http://php.net/manual/en/function.passthru.php

  *Note:* If a program is started with this function, in order for it to
  continue running in the background, the output of the program must be
  redirected to a file or another output stream. Failing to do so will cause
  PHP to hang until the execution of the program ends (!).

It does this:

$cmd = wfShellWikiCmd( "$IP/maintenance/runJobs.php", array( '--maxjobs', $n ) );
wfShellExec( "$cmd &", $retVal );

But it isn't redirecting stdout nor stderr to another stream (/dev/null for example), so PHP gets stuck on that command until it finishes.

This could cause issues like bug 47375 comment 9


The odd thing is that it apparently causes the entire server to hang. For example, in the test shell script I wrote, i put "sleep 5", and then I open 3 different links of the wiki consecutively, and in a top command there's only one script executing at a time. The last page loads at about 15 seconds after I open the first link (5 + 5 + 5). My environment is PHP 5.3.15 (apache2handler)

If this is really happening, that's not something desirable, even if the process is executed in the background, not blocking the request.
Comment 1 Brad Jorsch 2014-01-19 19:30:46 UTC
(In reply to comment #0)
> According to http://php.net/manual/en/function.passthru.php

Note that that's entirely irrelevant since wfShellExec doesn't use passthru. It uses proc_open.

Now, whether proc_open has a similar issue when directed to use php://stdin and/or php://stderr in certain configurations, I have no idea. It seems to background fine in my local setup (Apache 2.4.7, PHP 5.5.8, using mod_php).
Comment 2 Jesús Martínez Novo (Ciencia Al Poder) 2014-01-19 19:45:36 UTC
(In reply to comment #1)
> Note that that's entirely irrelevant since wfShellExec doesn't use passthru.
> It uses proc_open.

I see a shiny passthru call on that function :P

http://git.wikimedia.org/blob/mediawiki%2Fcore.git/REL1_22/includes%2FGlobalFunctions.php#L2807
Comment 3 Brad Jorsch 2014-01-19 19:58:47 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > Note that that's entirely irrelevant since wfShellExec doesn't use passthru.
> > It uses proc_open.
> 
> I see a shiny passthru call on that function :P
> 
> http://git.wikimedia.org/blob/mediawiki%2Fcore.git/REL1_22/
> includes%2FGlobalFunctions.php#L2807

Sorry, I didn't notice you were reporting a bug against 1.22. The passthru call has already been removed from later versions in Gerrit change #91115.
Comment 4 Jesús Martínez Novo (Ciencia Al Poder) 2014-01-19 20:19:50 UTC
Glad to hear it was fixed on master.

Would it be possible to backport to 1.22? It wrecks havoc in some installations

https://www.mediawiki.org/wiki/Thread:Project:Support_desk/Mediawiki_1.22%2B_Causes_two_of_my_servers_to_hang_indefinitely%2E
Comment 5 Gerrit Notification Bot 2014-01-21 19:46:56 UTC
Change 108740 had a related patch set uploaded by Aaron Schulz:
Various fixes to job running code in Wiki.php

https://gerrit.wikimedia.org/r/108740
Comment 6 Gerrit Notification Bot 2014-01-29 23:01:10 UTC
Change 108740 merged by jenkins-bot:
Various fixes to job running code in Wiki.php

https://gerrit.wikimedia.org/r/108740
Comment 7 Gerrit Notification Bot 2014-02-03 08:32:48 UTC
Change 110923 had a related patch set uploaded by Nemo bis:
Various fixes to job running code in Wiki.php

https://gerrit.wikimedia.org/r/110923
Comment 8 Gerrit Notification Bot 2014-02-03 16:12:23 UTC
Change 110923 abandoned by Nemo bis:
Various fixes to job running code in Wiki.php

https://gerrit.wikimedia.org/r/110923
Comment 9 Jesús Martínez Novo (Ciencia Al Poder) 2014-02-03 20:08:22 UTC
backport still pending, but no patch to review
Comment 10 Gerrit Notification Bot 2014-02-05 17:26:43 UTC
Change 110923 restored by MarkAHershberger:
Various fixes to job running code in Wiki.php

Reason:
I want it.

https://gerrit.wikimedia.org/r/110923
Comment 11 Gerrit Notification Bot 2014-02-05 17:30:39 UTC
Change 110923 merged by jenkins-bot:
Various fixes to job running code in Wiki.php

https://gerrit.wikimedia.org/r/110923
Comment 12 Andre Klapper 2014-02-05 18:20:21 UTC
Backported as per comment 10 & comment 11 to 1.22.3 - setting flag from ? to +.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links