[betalabs] Fatal exception when clicking on deleted topics in View history (Flow\Model\AbstractRevision::getRecentChange)
Closed, ResolvedPublic

Description

Found when checking T180607: Nuke does not list hidden Flow topics.

  1. User A created three topics on SD board.
  2. User B hides those three topics.
  3. User Administrator deletes those three hidden topics via Special:Nuke .
  4. User Administrator checks 'View history' on the SD board and clicks on the cross-out link, see the screenshot below.

<span class="mw-changeslist-date history-deleted"><a href="https://en.wikipedia.beta.wmflabs.org/w/index.php?title=Topic:U3lv6guxmjfr7gun&amp;topic_revId=u3lvlowjils63kg9&amp;action=single-view" title="topic revision">21:51, 11 December 2017</a></span>

After the click, the page loads:
https://en.wikipedia.beta.wmflabs.org/w/index.php?title=Topic:U3lv6guxmjfr7gun&topic_revId=u3lvlowjils63kg9&action=single-view

The following error is displayed:

[Wi8BIgpEE4AAAAN19mUAAAAE] 2017-12-11 22:05:23: Fatal exception of type "Wikimedia\Rdbms\DBQueryError"
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptDec 11 2017, 10:35 PM

The same type of error - from https://logstash-beta.wmflabs.org

[WjBAxApEE4AAAGjZ72sAAAAB] 2017-12-12 20:49:08: Fatal exception of type "Wikimedia\Rdbms\DBQueryError"
[WjBAxApEE4AAAGjZ72sAAAAB] /w/index.php?title=Topic:U3lv6tfk22npdczz&topic_revId=u3lvimxzcxwnsw0f&action=single-view   Wikimedia\Rdbms\DBQueryError from line 1179 of /srv/mediawiki/php-master/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?
exception.message	       	A database query error has occurred. Did you forget to run your application's database schema updater after upgrading? 
Query: SELECT  rc_id,rc_timestamp,rc_user,rc_user_text,rc_namespace,rc_title,rc_minor,rc_bot,rc_new,rc_cur_id,rc_this_oldid,rc_last_oldid,rc_type,rc_source,rc_patrolled,rc_ip,rc_old_len,rc_new_len,rc_deleted,rc_logid,rc_log_type,rc_log_action,rc_params,COALESCE( comment_rc_comment.comment_text, rc_comment ) AS `rc_comment_text`,comment_rc_comment.comment_data AS `rc_comment_data`,comment_rc_comment.comment_id AS `rc_comment_cid`  FROM `recentchanges` LEFT JOIN `comment` `comment_rc_comment` ON ((comment_rc_comment.comment_id = rc_comment_id)) FORCE INDEX (rc_timestamp)  WHERE rc_title = 'U3lv6tfk22npdczz' AND rc_timestamp = '20171211215014' AND rc_namespace = '2600'  
Function: Flow\Model\AbstractRevision::getRecentChange
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 'FORCE INDEX (rc_timestamp)  WHERE rc_title = 'U3lv6tfk22npdczz' AND rc_timestamp' at line 1 (10.68.18.35:3306)
t  exception.trace	       	#0 /srv/mediawiki/php-master/includes/libs/rdbms/database/Database.php(991): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)
#1 /srv/mediawiki/php-master/includes/libs/rdbms/database/Database.php(1374): Wikimedia\Rdbms\Database->query(string, string)
#2 /srv/mediawiki/php-master/extensions/Flow/includes/Model/AbstractRevision.php(861): Wikimedia\Rdbms\Database->select(array, array, array, string, array, array)
#3 /srv/mediawiki/php-master/extensions/Flow/includes/Formatter/RevisionViewFormatter.php(133): Flow\Model\AbstractRevision->getRecentChange()
#4 /srv/mediawiki/php-master/extensions/Flow/includes/Formatter/RevisionViewFormatter.php(44): Flow\Formatter\RevisionViewFormatter->buildLinks(Flow\Formatter\FormatterRow, Flow\View)
#5 /srv/mediawiki/php-master/extensions/Flow/includes/Block/Topic.php(609): Flow\Formatter\RevisionViewFormatter->formatApi(Flow\Formatter\FormatterRow, Flow\View)
#6 /srv/mediawiki/php-master/extensions/Flow/includes/Block/Topic.php(511): Flow\Block\TopicBlock->renderSingleViewApi(string)
#7 /srv/mediawiki/php-master/extensions/Flow/includes/View.php(190): Flow\Block\TopicBlock->renderApi(array)
#8 /srv/mediawiki/php-master/extensions/Flow/includes/View.php(67): Flow\View->buildApiResponse(Flow\WorkflowLoader, array, string, array)
#9 /srv/mediawiki/php-master/extensions/Flow/includes/Actions/Action.php(112): Flow\View->show(Flow\WorkflowLoader, string)
#10 /srv/mediawiki/php-master/extensions/Flow/includes/Actions/Action.php(50): Flow\Actions\FlowAction->showForAction(string)
#11 /srv/mediawiki/php-master/includes/MediaWiki.php(499): Flow\Actions\FlowAction->show()
#12 /srv/mediawiki/php-master/includes/MediaWiki.php(293): MediaWiki->performAction(Article, Title)
#13 /srv/mediawiki/php-master/includes/MediaWiki.php(851): MediaWiki->performRequest()
#14 /srv/mediawiki/php-master/includes/MediaWiki.php(523): MediaWiki->main()
#15 /srv/mediawiki/php-master/index.php(43): MediaWiki->run()
#16 /srv/mediawiki/w/index.php(3): include(string)
#17 {main}
  exception_id	       	WjBAxApEE4AAAGjZ72sAAAAB
  exception_url	       	/w/index.php?title=Topic:U3lv6tfk22npdczz&topic_revId=u3lvimxzcxwnsw0f&action=single-view
Aklapper renamed this task from [betalabs] [Wi8BIgpEE4AAAAN19mUAAAAE] Fatal exception of type "Wikimedia\Rdbms\DBQueryError" when clicking on deleted topics in View history to [betalabs] Fatal exception when clicking on deleted topics in View history (Flow\Model\AbstractRevision::getRecentChange).Dec 13 2017, 10:00 AM
SBisson added a subscriber: SBisson.Jan 5 2018, 8:58 PM

tl;dr I was not able to reproduce this issue locally or in production. ( @Etonkovidova Please let me know if you can )

Viewing any specific recent[1] Flow revision in betalabs produces this error, no need to hide and Nuke.

It appears to be cause by Flow/includes/Model/AbstractRevision.php:850 ($options = [ 'USE INDEX' => 'rc_timestamp' ];) which contributes to the following SQL

SELECT rc_id,rc_timestamp,rc_user,rc_user_text,rc_namespace,rc_title,rc_minor,rc_bot,rc_new,rc_cur_id,rc_this_oldid,rc_last_oldid,rc_type,rc_source,rc_patrolled,rc_ip,rc_old_len,rc_new_len,rc_deleted,rc_logid,rc_log_type,rc_log_action,rc_params,COALESCE( comment_rc_comment.comment_text, rc_comment ) AS `rc_comment_text`,comment_rc_comment.comment_data AS `rc_comment_data`,comment_rc_comment.comment_id AS `rc_comment_cid`  
FROM `recentchanges` LEFT JOIN `comment` `comment_rc_comment` ON ((comment_rc_comment.comment_id = rc_comment_id)) 
FORCE INDEX (rc_timestamp)  
WHERE rc_title = 'U55be9hj5vbrllov' AND rc_timestamp = '20180105191040' AND rc_namespace = '2600';

It works when I remove FORCE INDEX (rc_timestamp)

[1] Viewing a revision that is older than the recent changes window works because it doesn't enter that code path.

@SBisson - regarding

Viewing any specific recent[1] Flow revision in betalabs produces this error, no need to hide and Nuke.

Interesting - when I am trying to view any change on https://en.wikipedia.beta.wmflabs.org/w/index.php?title=Talk:ET8&action=history** after Mass delete **- I see the error

And I do not have Administrator rights to Delete topics (or Mass delete) in production - only to Hide which seems to work without errors.

Etonkovidova closed this task as Resolved.Feb 10 2018, 1:16 AM