Page MenuHomePhabricator

ActiveUsersPager's new query logic breaks PostgreSQL compatibility
Closed, ResolvedPublic

Description

The Active Users page and corresponding jobs are broken on 1.33. Likely introduced by 262fd585d0e6d7e821461cc7f191c8d2f5644c4c. The error seems to trigger on both attempting to view the Active Users page, and on certain jobs.

Expected behaviour
Active users page is displayed.

Actual results

A database query error has occurred. This may indicate a bug in the software.

[fd408b5db10bfa95933a7bed] 2019-08-16 11:10:59: Fatal exception of type "Wikimedia\Rdbms\DBQueryError"

Logs

Aug 14 04:51:11 db postgres[50750]: [8-1] ERROR:  column "qcc_users.user_id" must appear in the GROUP BY clause or be used in an aggregate function at character 103
Aug 14 04:51:11 db postgres[50750]: [8-2] STATEMENT:  SELECT /* ActiveUsersPager::buildQueryInfo (ActiveUsersPager)  */  qcc_title,qcc_title AS "user_name",user_id,COUNT(rc_id) AS "recentedits"  FROM (SELECT  qcc_title,user_id,actor_id  FROM "querycachetwo" JOIN "mwuser" ON ((user_name = qcc_title)) JOIN "actor" ON ((actor_user = user_id))   WHERE qcc_type = 'activeusers' AND qcc_namespace = '2' AND (NOT EXISTS (SELECT  1  FROM "ipblocks"    WHERE (ipb_user=user_id) AND ipb_deleted = '1'  ))  ORDER BY qcc_title ASC LIMIT 1001  ) "qcc_users" LEFT JOIN "recentchanges" ON ((rc_actor = actor_id) AND (rc_type != '5') AND (rc_type != '6') AND (rc_log_type IS NULL OR rc_log_type != 'newusers') AND (rc_timestamp >= '2019-07-14 19:51:11+00'))    GROUP BY qcc_title ORDER BY qcc_title
Aug 13 15:00:02 db postgres[5685]: [13-1] ERROR:  column "actor_rc_user.actor_name" must appear in the GRO
UP BY clause or be used in an aggregate function at character 76
Aug 13 15:00:02 db postgres[5685]: [13-2] STATEMENT:  SELECT /* RecentChangesUpdateJob::updateActiveUsers wiki@hosting */  actor_rc_user.actor_name AS "rc_user_text",MAX(rc_timestamp) AS "lastedittime"  FROM "recentchanges" JOIN "actor" "actor_rc_user" ON ((actor_rc_user.actor_id = rc_actor))   WHERE (actor_rc_user.actor_user > 0) AND (rc_type != '5') AND (rc_log_type IS NULL OR rc_log_type != 'newusers') AND (rc_timestamp >= '2019-07-14 06:00:02+00') AND (rc_timestamp <= '2019-08-13 06:00:02+00')  GROUP BY rc_user_text

I can provide detailed backtrace if needed.

Event Timeline

Restricted Application added a project: Core Platform Team. · View Herald TranscriptAug 16 2019, 3:45 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 530619 had a related patch set uploaded (by Anomie; owner: Anomie):
[mediawiki/core@master] ActiveUsersPager: Fix outer GROUP BY

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

Change 530620 had a related patch set uploaded (by Anomie; owner: Anomie):
[mediawiki/core@master] RecentChangesUpdateJob: Fix GROUP BY

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

Anomie claimed this task.Aug 16 2019, 6:27 PM

Change 530619 merged by Ppchelko:
[mediawiki/core@master] ActiveUsersPager: Fix outer GROUP BY

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

Change 530620 merged by Ppchelko:
[mediawiki/core@master] RecentChangesUpdateJob: Fix GROUP BY

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

Thank you, the patches seem to fix the issue: the Active Users page is now working as intended on all my MediaWiki instances.

Umherirrender closed this task as Resolved.Mon, Aug 19, 7:20 PM
Umherirrender triaged this task as Normal priority.

Change 536776 had a related patch set uploaded (by Reedy; owner: Anomie):
[mediawiki/core@REL1_33] RecentChangesUpdateJob: Fix GROUP BY

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

Change 536777 had a related patch set uploaded (by Reedy; owner: Anomie):
[mediawiki/core@REL1_33] ActiveUsersPager: Fix outer GROUP BY

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

Change 536776 merged by jenkins-bot:
[mediawiki/core@REL1_33] RecentChangesUpdateJob: Fix GROUP BY

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

Change 536777 merged by jenkins-bot:
[mediawiki/core@REL1_33] ActiveUsersPager: Fix outer GROUP BY

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