Page MenuHomePhabricator

Special:ActiveUsers fails with "Error: 1054 Unknown column 'rc_actor' in 'on clause' (10.192.32.110)"
Closed, ResolvedPublicPRODUCTION ERROR

Description

https://test.wikipedia.org/wiki/Special:ActiveUsers?username=&groups[]=sysop&wpFormIdentifier=specialactiveusers

Original exception: [W6FfhQrAADcAACyHZdUAAAAB] /wiki/Special:ActiveUsers?username=&groups[]=sysop&wpFormIdentifier=specialactiveusers Wikimedia\Rdbms\DBQueryError from line 1458 of /srv/mediawiki/php-1.32.0-wmf.22/includes/libs/rdbms/database/Database.php: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading?
Query: SELECT qcc_title,qcc_title AS `user_name`,MAX(user_id) AS `user_id`,COUNT(*) AS `recentedits` FROM `querycachetwo`,`user`,`recentchanges`,`user_groups` LEFT JOIN `actor` `actor_rc_user` ON ((actor_rc_user.actor_id = rc_actor)) WHERE qcc_type = 'activeusers' AND qcc_namespace = '2' AND (user_name = qcc_title) AND (COALESCE( actor_rc_user.actor_name, rc_user_text ) = qcc_title) AND (rc_type != '5') AND (rc_type != '6') AND (rc_log_type IS NULL OR rc_log_type != 'newusers') AND (rc_timestamp >= '20180819202645') AND (ug_user = user_id) AND ug_group = 'sysop' AND (ug_expiry IS NULL OR ug_expiry >= '20180918202645') AND (NOT EXISTS (SELECT 1 FROM `ipblocks` WHERE (ipb_user=user_id) AND ipb_deleted = '1' )) GROUP BY qcc_title ORDER BY qcc_title LIMIT 51
Function: IndexPager::buildQueryInfo (ActiveUsersPager)
Error: 1054 Unknown column 'rc_actor' in 'on clause' (10.192.32.110)

Backtrace:
#0 /srv/mediawiki/php-1.32.0-wmf.22/includes/libs/rdbms/database/Database.php(1428): Wikimedia\Rdbms\Database->makeQueryException(string, integer, string, string)
#1 /srv/mediawiki/php-1.32.0-wmf.22/includes/libs/rdbms/database/Database.php(1198): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)
#2 /srv/mediawiki/php-1.32.0-wmf.22/includes/libs/rdbms/database/Database.php(1655): Wikimedia\Rdbms\Database->query(string, string)
#3 /srv/mediawiki/php-1.32.0-wmf.22/includes/pager/IndexPager.php(368): Wikimedia\Rdbms\Database->select(array, array, array, string, array, array)
#4 /srv/mediawiki/php-1.32.0-wmf.22/includes/pager/IndexPager.php(225): IndexPager->reallyDoQuery(string, integer, boolean)
#5 /srv/mediawiki/php-1.32.0-wmf.22/includes/pager/IndexPager.php(422): IndexPager->doQuery()
#6 /srv/mediawiki/php-1.32.0-wmf.22/includes/specials/SpecialActiveusers.php(62): IndexPager->getBody()
#7 /srv/mediawiki/php-1.32.0-wmf.22/includes/specialpage/SpecialPage.php(569): SpecialActiveUsers->execute(NULL)
#8 /srv/mediawiki/php-1.32.0-wmf.22/includes/specialpage/SpecialPageFactory.php(581): SpecialPage->run(NULL)
#9 /srv/mediawiki/php-1.32.0-wmf.22/includes/MediaWiki.php(288): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext)
#10 /srv/mediawiki/php-1.32.0-wmf.22/includes/MediaWiki.php(868): MediaWiki->performRequest()
#11 /srv/mediawiki/php-1.32.0-wmf.22/includes/MediaWiki.php(525): MediaWiki->main()
#12 /srv/mediawiki/php-1.32.0-wmf.22/index.php(42): MediaWiki->run()
#13 /srv/mediawiki/w/index.php(3): include(string)
#14 {main}

See also: T204669#4593646

Event Timeline

This either needs the order of the tables to be changed so that 'recentchanges' comes after 'user_groups' (not super easy to do with how the code is now), or this needs the implicit joins between user_groups, user, querycachetwo and recentchanges to be made explicit INNER JOINs.

...but making the joins explicit won't work, because you can't make COALESCE( actor_rc_user.actor_name, rc_user_text ) = qcc_title a join condition.

Making the joins explicit should work fine. There's no reason that couldn't be a join condition (although it is kind of ugly and may be not performant, cf. T204669).

Krinkle renamed this task from Error: 1054 Unknown column 'rc_actor' in 'on clause' (10.192.32.110) to Special:ActiveUsers fails with "Error: 1054 Unknown column 'rc_actor' in 'on clause' (10.192.32.110)".Sep 18 2018, 9:00 PM
Krinkle moved this task from Untriaged to Nov2019/1.35.wmf.5+ on the Wikimedia-production-error board.

The error no more show up, ActorTableSchemaMigrationStage deployed on 09/17 has been rolledback:

Change 461209 merged by jenkins-bot:
[operations/mediawiki-config@master] Set ActorTableSchemaMigrationStage => OLD on test wikis, mw.org

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

Making the joins explicit should work fine. There's no reason that couldn't be a join condition (although it is kind of ugly and may be not performant, cf. T204669).

Ah. You do need to use a parenthesized join to make it work, without that it's a bit non-obvious. Or rearrange the query to left join actor against user before joining recentchanges against a different condition.

Change 462010 had a related patch set uploaded (by Anomie; owner: Anomie):
[mediawiki/core@master] Add join conditions to ActiveUsersPager

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

Oops, closed the wrong task. But isn't this one done?

The error is no longer being generated in WMF production, but the patch to fix it when we try to redeploy it isn't merged yet.

Change 462010 merged by jenkins-bot:
[mediawiki/core@master] Add join conditions to ActiveUsersPager

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

Anomie claimed this task.

Change 480822 had a related patch set uploaded (by Paladox; owner: Anomie):
[mediawiki/core@REL1_31] Add join conditions to ActiveUsersPager

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

Change 480822 merged by jenkins-bot:
[mediawiki/core@REL1_31] Add join conditions to ActiveUsersPager

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

mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:08 PM