Page MenuHomePhabricator

LoadBalancer.php: PHP Warning: Invalid argument supplied for foreach()
Closed, DuplicatePublicPRODUCTION ERROR

Description

Error

MediaWiki version: 1.35.0-wmf.37

message
PHP Warning: Invalid argument supplied for foreach()

Impact

Doesn't seem to happen deterministically for this url at any rate

Notes

  • Spike at 2020-06-17T17:09:44
  • Commonswiki only
  • One server (mw1281) only
  • Unable to reproduce

Details

Request ID
5cf9da30-ecbe-49b3-8ee3-261aec03124a
Request URL
https://commons.wikimedia.org/w/api.php?action=query&generator=allimages&gaisort=timestamp&gaidir=newer&gailimit=500&prop=imageinfo%7Cglobalusage&iiprop=url%7Cuser%7Cdimensions%7Cextmetadata&gulimit=500&gunamespace=0&format=json&gaistart=1350691200&gaiend=1350777600&gaicontinue=20121020083758%7CThe_New_Orleans_Bee_1848_July_0082.pdf&continue=gaicontinue%7C%7C
Stack Trace
exception.trace
#0 /srv/mediawiki/php-1.35.0-wmf.37/includes/libs/rdbms/loadbalancer/LoadBalancer.php(2149): MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.35.0-wmf.37/includes/libs/rdbms/loadbalancer/LoadBalancer.php(1835): Wikimedia\Rdbms\LoadBalancer->forEachOpenMasterConnection(Closure)
#2 /srv/mediawiki/php-1.35.0-wmf.37/includes/libs/rdbms/lbfactory/LBFactory.php(349): Wikimedia\Rdbms\LoadBalancer->runMasterTransactionListenerCallbacks(string, integer)
#3 /srv/mediawiki/php-1.35.0-wmf.37/includes/libs/rdbms/lbfactory/LBFactoryMulti.php(222): Wikimedia\Rdbms\LBFactory->Wikimedia\Rdbms\{closure}(Wikimedia\Rdbms\LoadBalancer)
#4 /srv/mediawiki/php-1.35.0-wmf.37/includes/libs/rdbms/lbfactory/LBFactory.php(351): Wikimedia\Rdbms\LBFactoryMulti->forEachLB(Closure)
#5 /srv/mediawiki/php-1.35.0-wmf.37/includes/libs/rdbms/lbfactory/LBFactory.php(312): Wikimedia\Rdbms\LBFactory->executePostTransactionCallbacks()
#6 /srv/mediawiki/php-1.35.0-wmf.37/includes/libs/rdbms/lbfactory/LBFactory.php(232): Wikimedia\Rdbms\LBFactory->commitMasterChanges(string)
#7 /srv/mediawiki/php-1.35.0-wmf.37/includes/MediaWiki.php(1079): Wikimedia\Rdbms\LBFactory->shutdown(integer)
#8 /srv/mediawiki/php-1.35.0-wmf.37/includes/MediaWiki.php(849): MediaWiki->restInPeace()
#9 /srv/mediawiki/php-1.35.0-wmf.37/includes/MediaWiki.php(861): MediaWiki->{closure}()
#10 /srv/mediawiki/php-1.35.0-wmf.37/api.php(119): MediaWiki->doPostOutputShutdown()
#11 /srv/mediawiki/w/api.php(3): require(string)
#12 {main}

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Source: https://github.com/wikimedia/mediawiki/blob/b3fd21918701c599bff8319aa8db29a730e99386/includes/libs/rdbms/loadbalancer/LoadBalancer.php#L2146

	public function forEachOpenMasterConnection( $callback, array $params = [] ) {
		$masterIndex = $this->getWriterIndex();
		foreach ( $this->conns as $connsByServer ) {

	}

conns is declared without value, and assigned from two places. Presumably it is called too early by something before it is possible/allowed to have a connection yet. Unclear whether that is a bad caller or whether it needs to be supported. Depends on intent and required behaviour.

If investigation concludes that this condition is impossible, then this might be a case of T245183 / T253673, which I expect in part because it happened onced only and on one server only.

Krinkle triaged this task as High priority.Jun 17 2020, 6:50 PM
Krinkle moved this task from Untriaged to Jun 2020 on the Wikimedia-production-error board.