Page MenuHomePhabricator

Duplicate entry for key 'cx_translation_ref' in ContentTranslation\Translation::createQuery
Open, MediumPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   Wikimedia\Rdbms\DBQueryError: Error 1062: Duplicate entry … for key 'cx_translation_ref'
Function: ContentTranslation\Translation::create
Query: INSERT INTO `cx_translations` (translation_source_title,
exception.trace
from /srv/mediawiki/php-1.39.0-wmf.15/includes/libs/rdbms/database/Database.php(1767)
#0 /srv/mediawiki/php-1.39.0-wmf.15/includes/libs/rdbms/database/Database.php(1751): Wikimedia\Rdbms\Database->getQueryException(string, integer, string, string)
#1 /srv/mediawiki/php-1.39.0-wmf.15/includes/libs/rdbms/database/Database.php(1725): Wikimedia\Rdbms\Database->getQueryExceptionAndLog(string, integer, string, string)
#2 /srv/mediawiki/php-1.39.0-wmf.15/includes/libs/rdbms/database/Database.php(1226): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)
#3 /srv/mediawiki/php-1.39.0-wmf.15/includes/libs/rdbms/database/Database.php(2274): Wikimedia\Rdbms\Database->query(string, string, integer)
#4 /srv/mediawiki/php-1.39.0-wmf.15/includes/libs/rdbms/database/Database.php(2254): Wikimedia\Rdbms\Database->doInsert(string, array, string)
#5 /srv/mediawiki/php-1.39.0-wmf.15/includes/libs/rdbms/database/DBConnRef.php(68): Wikimedia\Rdbms\Database->insert(string, array, string)
#6 /srv/mediawiki/php-1.39.0-wmf.15/includes/libs/rdbms/database/DBConnRef.php(333): Wikimedia\Rdbms\DBConnRef->__call(string, array)
#7 /srv/mediawiki/php-1.39.0-wmf.15/extensions/ContentTranslation/includes/Translation.php(55): Wikimedia\Rdbms\DBConnRef->insert(string, array, string)
#8 /srv/mediawiki/php-1.39.0-wmf.15/extensions/ContentTranslation/includes/Translation.php(116): ContentTranslation\Translation->create(ContentTranslation\Translator)
#9 /srv/mediawiki/php-1.39.0-wmf.15/extensions/ContentTranslation/includes/ActionApi/ApiContentTranslationSave.php(172): ContentTranslation\Translation->save(ContentTranslation\Translator)
#10 /srv/mediawiki/php-1.39.0-wmf.15/extensions/ContentTranslation/includes/ActionApi/ApiContentTranslationSave.php(95): ContentTranslation\ActionApi\ApiContentTranslationSave->saveTranslation(array, ContentTranslation\Translator)
#11 /srv/mediawiki/php-1.39.0-wmf.15/includes/api/ApiMain.php(1901): ContentTranslation\ActionApi\ApiContentTranslationSave->execute()
#12 /srv/mediawiki/php-1.39.0-wmf.15/includes/api/ApiMain.php(875): ApiMain->executeAction()
#13 /srv/mediawiki/php-1.39.0-wmf.15/includes/api/ApiMain.php(846): ApiMain->executeActionWithErrorHandling()
#14 /srv/mediawiki/php-1.39.0-wmf.15/api.php(90): ApiMain->execute()
#15 /srv/mediawiki/php-1.39.0-wmf.15/api.php(45): wfApiMain()
#16 /srv/mediawiki/w/api.php(3): require(string)
#17 {main}
Impact

Seems to happen about a dozen times a day when attempting to save an edit from Special:ContentTranslation, presumably resulting a generic "Internal server error" in the editor frontend.

Notes

There is another deadlock report for CX about its storage saving function at T256229, which might be related or share a common cause.

Event Timeline

Nikerabbit triaged this task as Medium priority.Aug 1 2022, 11:27 AM
Nikerabbit moved this task from Needs Triage to Bugs on the ContentTranslation board.
UNIQUE INDEX cx_translation_ref (
  translation_source_title, translation_source_language,
  translation_target_language, translation_started_by
),

The refered unique index contains a user id, so this could be a double-click or something which is trying to store the same thing twice over the api (ApiContentTranslationSave)

When the full, non redacted, sql exists, maybe just look if that refered page exists and was created around the time of the exception.

But the backend should handle that nice by giving a conflict warning or ignore the request. The backend already checks if a row exists, but on replica. Maybe a INSERT IGNORE is okay in that case or checking against primary is needed.

brennen subscribed.

Still seeing these in 1.41.0-wmf.27 (T345888).