Page MenuHomePhabricator

redirect table key violation
Closed, ResolvedPublic

Description

Author: aaron

Description:
r33133 certainly fixed the previous redirect problem but it appears to have enabled this error to occur:

internal_api_error_DBQueryError, Exception Caught: A database error has occurred
Query: INSERT INTO redirect (rd_from,rd_namespace,rd_title) VALUES ('57666','0','Vientiane')
Function: Database::insert
Error: 1062 Duplicate entry '57666' for key 1 (10.0.0.235)
, for "Vientiane, Laos"!


Version: unspecified
Severity: normal

Details

Reference
bz13745

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:06 PM
bzimport set Reference to bz13745.

Is that error reproducible? I strongly suspect that's a race condition. I, for one, can't reproduce this at http://en.wikipedia.org/w/api.php?action=query&titles=Vientiane,_Laos&redirects Marking as WONTFIX, please REOPEN if you get this error message more frequently.

What probably happened here is that two people ran the above query more or less simultaneously, and that query 1 inserted a row into the redirect table *after* query 2 had discovered the row wasn't there. When query 2 (you) tries to add a row that's already there, it dies. This condition is very rare, however (two people querying an ancient redirect that hasn't been queried before at the same time), so I'll just mark this as WONTFIX. The odds of this error occurring again after today (r33133 went live today) are astronomical, since it can only occur once for every ancient redirect, and only if the first query run on it since today is run by two people at the same time.

That's the sort of thing that INSERT IGNORE is for.

aaron wrote:

I did also get this error on "Antananarivo, Madagascar" (funny that it'd be limited happening on capitals of poor-ass countries), but I haven't seen it since yesterday. Thanks guys.

ayg wrote:

(In reply to comment #2)

That's the sort of thing that INSERT IGNORE is for.

REPLACE is probably better in this case.

(In reply to comment #4)

(In reply to comment #2)

That's the sort of thing that INSERT IGNORE is for.

REPLACE is probably better in this case.

It doesn't really matter, because they're supposed to add the exact same row. I'll use REPLACE just be sure, though.