Page MenuHomePhabricator

list=contenttranslationtrend sometimes uses invalid query
Open, LowPublic

Description

I noticed in the logs a bunch of errors like:

 	[W-0zjQpAAK4AADXi4rAAAAAA] /w/api.php?action=query&format=json&list=contenttranslationlangtrend&target=rn   Wikimedia\Rdbms\DBQueryError from line 1506 of /srv/mediawiki/php-1.33.0-wmf.4/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  ar_timestamp,count(ar_page_id) as count  FROM `change_tag`,`archive`    WHERE (ar_rev_id = ct_rev_id) AND ()  GROUP BY YEARWEEK(ar_timestamp, 3) 
Function: ContentTranslation\Translation::getDeletionTrend
Error: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')  GROUP BY YEARWEEK(ar_timestamp, 3)' at line 1 (10.64.32.136)

I suspect this is related to $conditions[] = false; in "includes/Translation.php" line 356 (Its a numeric parameter, so its treated as a raw sql string. false converted to string is the empty string.

Event Timeline

@Ladsgroup Any idea what could cause NameTableAccessException. In my understanding it should not happen. I think that is the real issue here. false could probably be replaced with 'false' or early return.

@Ladsgroup Any idea what could cause NameTableAccessException. In my understanding it should not happen. I think that is the real issue here. false could probably be replaced with 'false' or early return.

When the change tag for content translation doesn't exist in change_tag_def (or its cache). This should help reloading the cache more often: https://gerrit.wikimedia.org/r/c/mediawiki/core/+/477609
Regarding the false part. I think you're right. We put 1=0 in other places: https://gerrit.wikimedia.org/g/mediawiki/core/+/f50be0b03be500b2f33eae8b7b20957963024d44/includes/api/ApiQueryAllDeletedRevisions.php

When the change tag for content translation doesn't exist in change_tag_def (or its cache).

Is there a known issue with the cache? The tag contenttranslation has been defined since 2015 (be1dd871f28dd).

When the change tag for content translation doesn't exist in change_tag_def (or its cache).

Is there a known issue with the cache? The tag contenttranslation has been defined since 2015 (be1dd871f28dd).

It's not about its definition in the code, it's about the definition in prod (change_tag_def table). For example, you want to see translations for a bran-new wiki that doesn't have any translations made in it. Where does this happen?

Thanks, that explains. So tag gets defined only after it has been used?

The url has target=rn and https://rn.wikipedia.org/wiki/Special:Tags shows zero use of that tag.

Nikerabbit triaged this task as Low priority.
Nikerabbit moved this task from Needs Triage to Check & Move on the ContentTranslation board.

Did not find this error in Logstash for past 2 months, but it would only happen on wikis without any CX translations so hard to tell.