Page MenuHomePhabricator

TypeError using runJobs.php with PostgreSQL
Open, Needs TriagePublicBUG REPORT

Description

Using the runJobs.php as php maintenance/run runJobs throws an TypeError:

[36db2e985b042a9cddf6e60e] [no req] TypeError: Argument 1 passed to Wikimedia\Rdbms\Platform\PostgresPlatform::setCoreSchema() must be of the type string, null given, called in /srv/www/production/REL1_41/includes/libs/rdbms/database/DatabasePostgres.php on line 805
Backtrace:
from /srv/www/production/REL1_41/includes/libs/rdbms/platform/PostgresPlatform.php(60)
#0 /srv/www/production/REL1_41/includes/libs/rdbms/database/DatabasePostgres.php(805): Wikimedia\Rdbms\Platform\PostgresPlatform->setCoreSchema()
#1 /srv/www/production/REL1_41/includes/libs/rdbms/database/DatabasePostgres.php(131): Wikimedia\Rdbms\DatabasePostgres->determineCoreSchema()
#2 /srv/www/production/REL1_41/includes/libs/rdbms/database/Database.php(268): Wikimedia\Rdbms\DatabasePostgres->open()
#3 /srv/www/production/REL1_41/includes/libs/rdbms/loadbalancer/LoadBalancer.php(1075): Wikimedia\Rdbms\Database->initConnection()
#4 /srv/www/production/REL1_41/includes/libs/rdbms/loadbalancer/LoadBalancer.php(934): Wikimedia\Rdbms\LoadBalancer->reallyOpenConnection()
#5 /srv/www/production/REL1_41/includes/libs/rdbms/loadbalancer/LoadBalancer.php(801): Wikimedia\Rdbms\LoadBalancer->reuseOrOpenConnectionForNewRef()
#6 /srv/www/production/REL1_41/includes/libs/rdbms/loadbalancer/LoadBalancer.php(1792): Wikimedia\Rdbms\LoadBalancer->getServerConnection()
#7 /srv/www/production/REL1_41/includes/libs/objectcache/wancache/WANObjectCache.php(1726): Wikimedia\Rdbms\LoadBalancer->Wikimedia\Rdbms\{closure}()
#8 /srv/www/production/REL1_41/includes/libs/objectcache/wancache/WANObjectCache.php(1556): WANObjectCache->fetchOrRegenerate()
#9 /srv/www/production/REL1_41/includes/libs/rdbms/loadbalancer/LoadBalancer.php(1808): WANObjectCache->getWithSetCallback()
#10 /srv/www/production/REL1_41/includes/libs/rdbms/loadbalancer/LoadBalancer.php(1766): Wikimedia\Rdbms\LoadBalancer->isPrimaryRunningReadOnly()
#11 /srv/www/production/REL1_41/includes/libs/rdbms/ReadOnlyMode.php(55): Wikimedia\Rdbms\LoadBalancer->getReadOnlyReason()
#12 /srv/www/production/REL1_41/includes/libs/rdbms/ReadOnlyMode.php(36): Wikimedia\Rdbms\ReadOnlyMode->getReason()
#13 /srv/www/production/REL1_41/includes/jobqueue/JobRunner.php(168): Wikimedia\Rdbms\ReadOnlyMode->isReadOnly()
#14 /srv/www/production/REL1_41/maintenance/runJobs.php(98): JobRunner->run()
#15 /srv/www/production/REL1_41/maintenance/includes/MaintenanceRunner.php(703): RunJobs->execute()
#16 /srv/www/production/REL1_41/maintenance/run.php(51): MediaWiki\Maintenance\MaintenanceRunner->run()
#17 /srv/www/production/REL1_41/maintenance/run(3): require(string)
#18 {main}

More Information
$wgDBtype = "postgres" and $wgDBserver, $wgDBport, $wgDBname same as $wgDBmwschema are set and working since MW 1.35.
Other tasks like update, showJobs, refreshLinks, ... and Cargo extension are working as expected.
Running SELECT current_schema() directly in PostgreSQL works and returns the right schema, which is the same as set in $wgDBmwschema.
Change $wgDBmwschema to a wrong string in LocalSettings.php for testing, set Cargo and tasks like update, showJobs, refreshLinks, ... out of work.
Remove $wgDBmwschema or set it to NULL in LocalSettings.php, Cargo and tasks like update, showJobs, refreshLinks, ... still work!

Out of testing: Setting (698) return $row[0]; in the PostgresPlatform::setCoreSchema() to return "<theRightSchemaName>"; and running the runJobs.php works as intended!

What happens?:
runJobs.php throws an TypeError. Seems like only runJobs.php is affected.

What should have happened instead?:
runJobs.php should work as expected. There wasn't a problem with MW Version 1.40.

Software version:

  • MediaWiki 1.41.0 (da6b459)
  • PHP 7.4.33 (apache2handler)
  • PostgreSQL 12.18 (Debian 12.18-1.pgdg100+1)

Event Timeline

Backlink: https://www.mediawiki.org/w/index.php?title=Topic:Y0czy4fz9y11amzi&topic_showPostId=y0j9snncs06wekp0&fromnotif=1#flow-post-y0j9snncs06wekp0

Suspicion is that there is something different in the runjobs php entry point (order of operations ? different config context?) compared to the other entrypoints that allows this to be triggered only in this situation.

This comment was removed by Reedy.