Page MenuHomePhabricator

One file in HuWiki cannot be reviewed (error 500)
Open, Needs TriagePublicPRODUCTION ERROR

Description

Error
  • service.version: 1.45.0-wmf.14
  • timestamp: 2025-08-15T11:34:23.151Z
  • labels.phpversion: 8.1.33
  • trace.id: 528a09b4-e3ad-4454-8f91-082cfaf7c84b
  • Find trace.id in Logstash
labels.normalized_message
[{reqId}] {exception_url}   UnexpectedValueException: Flagged revision with ID 26797030 exists with unexpected fr_page_id, error: duplicate review
FrameLocationCall
from/srv/mediawiki/php-1.45.0-wmf.14/extensions/FlaggedRevs/includes/business/RevisionReviewForm.php(492)
#0/srv/mediawiki/php-1.45.0-wmf.14/extensions/FlaggedRevs/includes/business/RevisionReviewForm.php(315)RevisionReviewForm->approveRevision(MediaWiki\Revision\RevisionStoreRecord, null)
#1/srv/mediawiki/php-1.45.0-wmf.14/extensions/FlaggedRevs/includes/business/FRGenericSubmitForm.php(194)RevisionReviewForm->doSubmit()
#2/srv/mediawiki/php-1.45.0-wmf.14/extensions/FlaggedRevs/includes/frontend/specialpages/actions/RevisionReview.php(322)FRGenericSubmitForm->submit()
#3/srv/mediawiki/php-1.45.0-wmf.14/extensions/FlaggedRevs/includes/rest/ReviewHandler.php(23)RevisionReview::doReview(array)
#4/srv/mediawiki/php-1.45.0-wmf.14/includes/Rest/SimpleHandler.php(41)MediaWiki\Extension\FlaggedRevs\Rest\ReviewHandler->run(string)
#5/srv/mediawiki/php-1.45.0-wmf.14/includes/Rest/Module/Module.php(418)MediaWiki\Rest\SimpleHandler->execute()
#6/srv/mediawiki/php-1.45.0-wmf.14/includes/Rest/Module/Module.php(301)MediaWiki\Rest\Module\Module->executeHandler(MediaWiki\Extension\FlaggedRevs\Rest\ReviewHandler)
#7/srv/mediawiki/php-1.45.0-wmf.14/includes/Rest/Router.php(485)MediaWiki\Rest\Module\Module->execute(string, MediaWiki\Rest\RequestFromGlobals)
#8/srv/mediawiki/php-1.45.0-wmf.14/includes/Rest/Router.php(444)MediaWiki\Rest\Router->doExecute(string, MediaWiki\Rest\RequestFromGlobals)
#9/srv/mediawiki/php-1.45.0-wmf.14/includes/Rest/EntryPoint.php(209)MediaWiki\Rest\Router->execute(MediaWiki\Rest\RequestFromGlobals)
#10/srv/mediawiki/php-1.45.0-wmf.14/includes/MediaWikiEntryPoint.php(198)MediaWiki\Rest\EntryPoint->execute()
#11/srv/mediawiki/php-1.45.0-wmf.14/rest.php(39)MediaWiki\MediaWikiEntryPoint->run()
#12/srv/mediawiki/w/rest.php(3)require(string)
#13{main}
Impact
Notes

Steps to replicate the issue:

Failed to load resource: the server responded with a status of 500 () –  /w/rest.php/flaggedrevs/internal/review/F%C3%A1jl%3AMagyar_Cserk%C3%A9szsz%C3%B6vets%C3%A9g_logo.svg:1

OR

POST https://hu.wikipedia.org/w/rest.php/flaggedrevs/internal/review/F%C3%A1jl%3AMagyar_Cserk%C3%A9szsz%C3%B6vets%C3%A9g_logo.svg 500 (Internal Server Error)  – jquery.js:9940

What should have happened instead?:
Review gets saved and file becomes reviewed.

Software version: %%%huwiki, 1.45.0-wmf.14 (012​f5a9) – FlaggedRevs: (352​2234)

Details

MediaWiki Version
1.45.0-wmf.14
Request URL
https://hu.wikipedia.org/w/rest.php/flaggedrevs/internal/review/F%C3%A1jl:Magyar_Cserk%C3%A9szsz%C3%B6vets%C3%A9g_logo.svg

Event Timeline

taavi changed the subtype of this task from "Bug Report" to "Production Error".Aug 15 2025, 11:47 AM
taavi set Request URL to https://hu.wikipedia.org/w/rest.php/flaggedrevs/internal/review/F%C3%A1jl:Magyar_Cserk%C3%A9szsz%C3%B6vets%C3%A9g_logo.svg.Aug 15 2025, 11:47 AM
taavi updated the task description. (Show Details)
taavi set Release Version to 1.45.0-wmf.14.

I was able to review the file with a reviewed edit I made. So the ticket can be closed, I'm just not sure whether you want to keep it open to check the cause or not.

What is the fiwiki page? (I don’t have access to Logstash.) The huwiki page has been deleted and undeleted between @Boro's recent edit and the previous one, so I think it suffered from T162778: If reviewed page was deleted and then undeleted, page is marked both as reviewed and unreviewed; maybe it’s the same on fiwiki?

That’s a special page, not exactly helpful. ☹ Any chance we can find the actual article? For example using the revision ID included in the message (at least the message in the task description contains it)?

Oh, sorry. Try https://fi.wikipedia.org/w/index.php?oldid=23590538

exception.file = /srv/mediawiki/php-1.45.0-wmf.22/extensions/FlaggedRevs/includes/business/RevisionReviewForm.php:490

exception.message = Flagged revision with ID 23590538 exists with unexpected fr_page_id, error: duplicate review

exception_url = /w/api.php

Looks like this exception happened via the API, via RevisionReviewForm. So the steps to reproduce probably involves using the RevisionReviewForm.

Are there any SQL queries that we can run to see if the database is in a corrupted state for this one page? T162778 seems to me like it could be caused by having weird or contradictory values in the database.

Thanks! This page hasn’t been deleted ever. Maybe here what happened is simply what the end of the error message says, a duplicate review, caused by a race condition?

SELECT fr_timestamp FROM flaggedrevs WHERE fr_rev_id = 23590538;

returns 20251010073231 (2025-10-10 07:32:31). When was the exception logged? (If I understand correctly, the FlaggedRevs backend checks if there is already a review, so the race condition window should be a few milliseconds.)

Are there any SQL queries that we can run to see if the database is in a corrupted state for this one page? T162778 seems to me like it could be caused by having weird or contradictory values in the database.

If my theory is correct, and any page deletion/restore causes this, it’s

SELECT fr_page_id, rev_page FROM flaggedrevs JOIN revision ON fr_rev_id = rev_id WHERE fr_rev_id = <revision ID mentioned in the exception>;

and compare the two columns. For huwiki 26797030 it’s indeed different (fr_page_id = 1044748, rev_page = 1993106); for fiwiki 23590538, both columns are 326 (which is why I really wonder if it was just a simple race condition).

By the way, you may try to find all contradictory entries using

SELECT * FROM flaggedrevs JOIN revision ON fr_rev_id = rev_id WHERE fr_page_id <> rev_page;

but it’s slow; I killed it after a few seconds on huwiki. (It did complete in 218 ms on test2wiki, though, yielding five results on three pages: Asia, Strona testowa and 1234.)

I realized that there’s something common in the three test2wiki pages and the huwiki page: they weren’t just deleted and restored, but something more complicated happened: the test2wiki pages were deleted, recreated and then restored (inserting the once-deleted revisions at the end of the revision history), while the huwiki page was split (if I understand the log messages correctly, the logo now visible at Fájl:Magyar Cserkészszövetség logo 2.svg was once uploaded over Fájl:Magyar Cserkészszövetség logo.svg, and then subsequently split out). I guess this is why MediaWiki assigns a new page ID, and FlaggedRevs gets confused by this.

SELECT fr_timestamp FROM flaggedrevs WHERE fr_rev_id = 23590538;

returns 20251010073231 (2025-10-10 07:32:31). When was the exception logged? (If I understand correctly, the FlaggedRevs backend checks if there is already a review, so the race condition window should be a few milliseconds.)

Logstash says Oct 10, 2025 @ 07:32:31.457, matching your timestamp.


Also, there is now an additional Logstash entry from plwiki: RevisionReviewForm.php:490. Flagged revision with ID 77883529 exists with unexpected fr_page_id, error: duplicate review

https://pl.wikipedia.org/w/index.php?oldid=77883529

Also, there is now an additional Logstash entry from plwiki: RevisionReviewForm.php:490. Flagged revision with ID 77883529 exists with unexpected fr_page_id, error: duplicate review

https://pl.wikipedia.org/w/index.php?oldid=77883529

Which is also a page split.

Actually, why do we have fr_page_id? It can be inferred from fr_rev_id by joining with the revision table (except when things go wrong, like in these cases). As far as I see, the only place where removing the column would need new joins (we query by fr_page_id only, without including fr_rev_id in the condition; and revision isn’t already joined) is the FlaggedRevsStats class – which is run from scheduled jobs (and maintenance scripts) only, so it isn’t very performance-sensitive, nor can it put too much load on the DB servers. (It was added in rSVN20695 without much explanation. Its very first two usages – in that revision – were already such that could have been solved without the new column, by using the existing joins with revision.)

By the way, the same goes for fr_rev_timestamp (which was added in rSVN86179 / rEFLR1bbd5fa1cd681ee0221e45945234476826f142ed).

@Ladsgroup, as someone who knows both FlaggedRevs and DB performance, what do you think about dropping the column?