Page MenuHomePhabricator

Wikimedia\Rdbms\DBQueryError: Error 1054: Unknown column 'timestamp' in 'where clause
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
labels.normalized_message
[{reqId}] {exception_url}   Wikimedia\Rdbms\DBQueryError: Error 1054: Unknown column 'timestamp' in 'where clause'
Function: IndexPager::buildQueryInfo (MediaWiki\CheckUser\CheckUser\Pagers\CheckUserGetEditsPager)
Query: SELECT  cuc_namespace AS `namespac
error.stack_trace
from /srv/mediawiki/php-1.41.0-wmf.11/includes/libs/rdbms/database/Database.php(1298)
#0 /srv/mediawiki/php-1.41.0-wmf.11/includes/libs/rdbms/database/Database.php(1282): Wikimedia\Rdbms\Database->getQueryException(string, integer, string, string)
#1 /srv/mediawiki/php-1.41.0-wmf.11/includes/libs/rdbms/database/Database.php(1256): Wikimedia\Rdbms\Database->getQueryExceptionAndLog(string, integer, string, string)
#2 /srv/mediawiki/php-1.41.0-wmf.11/includes/libs/rdbms/database/Database.php(743): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)
#3 /srv/mediawiki/php-1.41.0-wmf.11/includes/libs/rdbms/database/Database.php(1425): Wikimedia\Rdbms\Database->query(Wikimedia\Rdbms\Query, string)
#4 /srv/mediawiki/php-1.41.0-wmf.11/includes/libs/rdbms/database/DBConnRef.php(119): Wikimedia\Rdbms\Database->select(array, array, array, string, array, array)
#5 /srv/mediawiki/php-1.41.0-wmf.11/includes/libs/rdbms/database/DBConnRef.php(341): Wikimedia\Rdbms\DBConnRef->__call(string, array)
#6 /srv/mediawiki/php-1.41.0-wmf.11/includes/pager/IndexPager.php(459): Wikimedia\Rdbms\DBConnRef->select(array, array, array, string, array, array)
#7 /srv/mediawiki/php-1.41.0-wmf.11/includes/pager/IndexPager.php(276): IndexPager->reallyDoQuery(string, integer, boolean)
#8 /srv/mediawiki/php-1.41.0-wmf.11/includes/pager/IndexPager.php(563): IndexPager->doQuery()
#9 /srv/mediawiki/php-1.41.0-wmf.11/extensions/CheckUser/src/CheckUser/SpecialCheckUser.php(396): IndexPager->getBody()
#10 /srv/mediawiki/php-1.41.0-wmf.11/includes/specialpage/SpecialPage.php(701): MediaWiki\CheckUser\CheckUser\SpecialCheckUser->execute(NULL)
#11 /srv/mediawiki/php-1.41.0-wmf.11/includes/specialpage/SpecialPageFactory.php(1554): SpecialPage->run(NULL)
#12 /srv/mediawiki/php-1.41.0-wmf.11/includes/MediaWiki.php(328): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
#13 /srv/mediawiki/php-1.41.0-wmf.11/includes/MediaWiki.php(925): MediaWiki->performRequest()
#14 /srv/mediawiki/php-1.41.0-wmf.11/includes/MediaWiki.php(579): MediaWiki->main()
#15 /srv/mediawiki/php-1.41.0-wmf.11/index.php(50): MediaWiki->run()
#16 /srv/mediawiki/php-1.41.0-wmf.11/index.php(46): wfIndexMain()
#17 /srv/mediawiki/w/index.php(3): require(string)
#18 {main}
Impact
Notes

Event Timeline

Hmm. I thought this was fixed. Are there any more details surrounding the check that caused this error? Also is the full query available?

Reedy renamed this task from Wikimedia\Rdbms\DBQueryError: Error 1054: Unknown column 'timestamp' in 'where clause'Function: IndexPager::buildQueryInfo (MediaWiki\CheckUser\CheckUser\Pagers\CheckUserGetEditsPager)Query: SELECT cuc_namespace AS `namespac to Wikimedia\Rdbms\DBQueryError: Error 1054: Unknown column 'timestamp' in 'where clause.Jun 7 2023, 12:17 AM

I cannot seem to reproduce this locally or on the English Wikipedia. I will need some more info before I can find a cause.

Found the issue. It looks like for some reason the IndexPager uses the index field instead of the timestamp field for paging the results?

This is because the IndexPager uses the ::getIndexField method to determine the field to use for paging the results instead of ::getTimestampField. I don't see why the ::getIndexField method is used over ::getTimestampField, as the ::getTimestampField doc says "Returns the name of the timestamp field. Subclass can override this to provide the timestamp field if they are using a aliased field for getIndexField()", which is exactly this case.

As such this isn't the direct fault of a change in CheckUser and seems to instead be code in core using the wrong field name. However, I think it would be simpler to revert the change 3796b99e430914bac904e6109c8beda964979b58 in the CheckUser extension and use a better method. I should have tested that patch more...

On the other hand, this issue needs fixing as this issue in core will block T315612.

As for the alternative method, I'm thinking of inspecting the schema migration stage for the correct index and timestamp field. This would leave the query unaltered for read old, which should avoid this issue.

Change 927985 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/CheckUser@master] Use cuc_timestamp as index field when reading old

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

Instead of reverting 3796b99e430914bac904e6109c8beda964979b58, I've gone with changing the index and timestamp field to be cuc_timestamp when wgCheckUserEventTablesMigrationStage is read old and timestamp when wgCheckUserEventTablesMigrationStage is read new. This fixes this issue in my testing.

Change 927985 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@master] Use cuc_timestamp as index field when reading old

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

Dreamy_Jazz triaged this task as High priority.EditedJun 7 2023, 6:35 PM

If this is a candidate for backporting to wmf.11, I can help test if it was applied on the English Wikipedia.

Change 928147 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/CheckUser@wmf/1.41.0-wmf.11] Use cuc_timestamp as index field when reading old

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

Change 928147 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@wmf/1.41.0-wmf.11] Use cuc_timestamp as index field when reading old

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

Mentioned in SAL (#wikimedia-operations) [2023-06-07T21:53:23Z] <zabe@deploy1002> Started scap: Backport for [[gerrit:928147|Use cuc_timestamp as index field when reading old (T338287)]]

Mentioned in SAL (#wikimedia-operations) [2023-06-07T21:55:01Z] <zabe@deploy1002> dreamyjazz and zabe: Backport for [[gerrit:928147|Use cuc_timestamp as index field when reading old (T338287)]] synced to the testservers: mwdebug1001.eqiad.wmnet, mwdebug2002.codfw.wmnet, mwdebug2001.codfw.wmnet, mwdebug1002.eqiad.wmnet

Mentioned in SAL (#wikimedia-operations) [2023-06-07T22:05:11Z] <zabe@deploy1002> Finished scap: Backport for [[gerrit:928147|Use cuc_timestamp as index field when reading old (T338287)]] (duration: 11m 48s)

Change 928148 had a related patch set uploaded (by Zabe; author: Dreamy Jazz):

[mediawiki/extensions/CheckUser@wmf/1.41.0-wmf.12] Use cuc_timestamp as index field when reading old

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

Change 928148 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@wmf/1.41.0-wmf.12] Use cuc_timestamp as index field when reading old

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

Mentioned in SAL (#wikimedia-operations) [2023-06-07T22:32:55Z] <zabe@deploy1002> Started scap: Backport for [[gerrit:928148|Use cuc_timestamp as index field when reading old (T338287)]]

Mentioned in SAL (#wikimedia-operations) [2023-06-07T22:34:31Z] <zabe@deploy1002> zabe: Backport for [[gerrit:928148|Use cuc_timestamp as index field when reading old (T338287)]] synced to the testservers: mwdebug1002.eqiad.wmnet, mwdebug2002.codfw.wmnet, mwdebug2001.codfw.wmnet, mwdebug1001.eqiad.wmnet

Mentioned in SAL (#wikimedia-operations) [2023-06-07T22:45:30Z] <zabe@deploy1002> Finished scap: T338287 (duration: 07m 30s)

Fix has been merged and backported to wmf.11 and wmf.12. Therefore, this can be resolved.