Page MenuHomePhabricator

Run jobs async does not honor $wgServerName
Closed, ResolvedPublic

Description

I am using MW 1.25.1, and our server is available at a URL like https://mywikidnsalias.mydomain.com. I cannot enable async run jobs because the async request is sent to a URL different than the value in $wgServerName.

Our server uses an httpd VirtualServer using DNS aliases to differentiate different applications on the server, and the entire server runs under https. Looking at the httpd logs, I see POST requests to http://myservername.mydomain.com/Special:JobQueue instead of https://mywikidnsalias.mydomain.com/Special:JobQueue.

Looking at includes/MediaWiki.php for RunJobs (about line 642), I see that there is a call to fsockopen() with the name of the host. There are a couple of problems here.

  1. $info['host'] is the name of the host, not the name of the wiki from $wgServer. On servers that use virtual hosting, the hostname and $wgServer may be different, so fsockopen() may result in a request that routes to the wrong virtual server.
  2. The call to fsockopen() does not account for $info['scheme'], which may be https.

I believe the solution is to rework the call the fsockopen() to either use a different method (i.e. not fsockopen()), or at least to use the info from $wgServer more correctly.

Event Timeline

chiefgeek157 raised the priority of this task from to Needs Triage.
chiefgeek157 updated the task description. (Show Details)
chiefgeek157 subscribed.
chiefgeek157 renamed this task from Run obs async does not honor $wgServerName to Run jobs async does not honor $wgServerName.Jul 29 2015, 3:03 PM
chiefgeek157 set Security to None.

I am having the save problem with a wiki that is HTTPS only. All HTTP requests are routed to HTTPS with a permanent redirect. When I turn on debug logging, I see the following in the MediaWiki log:

[runJobs] Running 1 job(s) via '/tw4/index.php?title=Special%3ARunJobs&tasks=jobs&maxjobs=1&sigexpiry=1457630287&signature=1d654861dc344e044f663aa5fdc2e256e95e8401'
[runJobs] Failed to start cron API: received 'HTTP/1.1 301 Moved Permanently

Change 277267 had a related patch set uploaded (by Cicalese):
Handle HTTPS when running jobs asynchronously

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

Change 277267 merged by jenkins-bot:
Handle HTTPS when running jobs asynchronously

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

Change 278459 had a related patch set uploaded (by MarkAHershberger):
Handle HTTPS when running jobs asynchronously

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

Change 278459 merged by jenkins-bot:
Handle HTTPS when running jobs asynchronously

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

If this helps at all

this is a log from a user coming into MediaWiki-General with the issue with job queue's not executing properly just at 7/31/16

Statistics [callback] completed in 0.01s
Ancientpages [QueryPage] got 30 rows in 0.02s
BrokenRedirects [QueryPage] got 0 rows in 0.00s
Deadendpages [QueryPage] got 29 rows in 0.01s
DoubleRedirects [QueryPage] got 0 rows in 0.00s
FileDuplicateSearch [QueryPage] cheap, skipped
ListDuplicatedFiles [QueryPage] got 0 rows in 0.01s
LinkSearch [QueryPage] cheap, skipped
Listredirects [QueryPage] got 5 rows in 0.01s
Lonelypages [QueryPage] got 29 rows in 0.01s
Longpages [QueryPage] cheap, skipped
MediaStatistics [QueryPage] got 1 rows in 0.01s
MIMEsearch [QueryPage] got 0 rows in 0.00s
Mostcategories [QueryPage] got 0 rows in 0.01s
Mostimages [QueryPage] got 0 rows in 0.00s
Mostinterwikis [QueryPage] got 0 rows in 0.00s
Mostlinkedcategories [QueryPage] cheap, skipped
Mostlinkedtemplates [QueryPage] got 0 rows in 0.00s
Mostlinked [QueryPage] got 0 rows in 0.00s
Mostrevisions [QueryPage] got 16 rows in 0.01s
Fewestrevisions [QueryPage] got 16 rows in 0.01s
Shortpages [QueryPage] cheap, skipped
Uncategorizedcategories [QueryPage] got 0 rows in 0.00s
Uncategorizedpages [QueryPage] got 30 rows in 0.01s
Uncategorizedimages [QueryPage] got 5 rows in 0.01s
Uncategorizedtemplates [QueryPage] got 87 rows in 0.01s
Unusedcategories [QueryPage] got 0 rows in 0.00s
Unusedimages [QueryPage] got 5 rows in 0.01s
Wantedcategories [QueryPage] got 0 rows in 0.00s
Wantedfiles [QueryPage] got 0 rows in 0.00s
Wantedpages [QueryPage] got 0 rows in 0.00s
Wantedtemplates [QueryPage] got 0 rows in 0.00s
Unwatchedpages [QueryPage] got 121 rows in 0.01s
Unusedtemplates [QueryPage] got 87 rows in 0.01s
Withoutinterwiki [QueryPage] got 30 rows in 0.01s

Zppix triaged this task as High priority.Jul 31 2016, 8:38 PM

Change 306154 had a related patch set uploaded (by Aaron Schulz):
Reduce problems caused by $wgRunJobsAsync

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

Change 306154 merged by jenkins-bot:
Reduce problems caused by $wgRunJobsAsync

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

aaron claimed this task.
aaron subscribed.

This should be fixed now.

Change 307798 had a related patch set uploaded (by Aaron Schulz):
Always fail over to sync jobs when Special:RunJobs fails

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

Change 307798 merged by jenkins-bot:
Always fail over to sync jobs when Special:RunJobs fails

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