Page MenuHomePhabricator

CX2: Saving fails the first time with DBQueryError
Closed, ResolvedPublic

Description

Any time "Use source text" option is applied, first save fails with DBQueryError. Translating to English is a good way to test, as machine translation providers are disabled. In the following example, article from German Wikipedia is used, but the bug is reproducible with any combination when "Use source text" is chosen.

While translating de:Burg_Ziesar to English, in production, translate infobox and a leading paragraph. Press Ctrl+S or wait for save to see save failure with server response:

{
    "error": {
        "code": "internal_api_error_DBQueryError",
        "info": "[W9cIwQpAAE4AAIYf9ZgAAAAN] Caught exception of type Wikimedia\\Rdbms\\DBQueryError"
    },
    "servedby": "mw1283"
}

Next attempt at saving, after one minute, succeeds. If you go back to the dashboard, delete saved draft and try reproducing with the same article one more time, saving succeeds right away, the first time.

Testing in localhost with de:Burg_Ziesar, gives trace:

{
    "error": {
        "code": "internal_api_error_DBQueryError",
        "info": "[f8c06885368639a7d077938d] Exception caught: A database query error has occurred. This may indicate a bug in the software.",
        "*": "Wikimedia\\Rdbms\\DBQueryError at core\\includes\\libs\rdbms\\database\\Database.php(1506)\n#0
		core\\includes\\libs\rdbms\\database\\Database.php(1476): Wikimedia\\Rdbms\\Database->makeQueryException(string, integer, string, string)\n#1
		core\\includes\\libs\rdbms\\database\\Database.php(1236): Wikimedia\\Rdbms\\Database->reportQueryError(string, integer, string, string, boolean)\n#2
		core\\includes\\libs\rdbms\\database\\Database.php(2078): Wikimedia\\Rdbms\\Database->query(string, string)\n#3
		core\\extensions\\ContentTranslation\\includes\\TranslationStorageManager.php(64): Wikimedia\\Rdbms\\Database->insert(string, array, string)\n#4
		core\\extensions\\ContentTranslation\\includes\\TranslationStorageManager.php(151):		ContentTranslation\\TranslationStorageManager::create(Wikimedia\\Rdbms\\DatabaseMysqli, ContentTranslation\\TranslationUnit)\n#5
		core\\includes\\libs\rdbms\\database\\Database.php(3815): ContentTranslation\\TranslationStorageManager::ContentTranslation\\{closure}(Wikimedia\\Rdbms\\DatabaseMysqli, string)\n#6
		core\\includes\\libs\rdbms\\database\\DBConnRef.php(49): Wikimedia\\Rdbms\\Database->doAtomicSection(string, Closure)\n#7
		core\\includes\\libs\rdbms\\database\\DBConnRef.php(538): Wikimedia\\Rdbms\\DBConnRef->__call(string, array)\n#8
		core\\extensions\\ContentTranslation\\includes\\TranslationStorageManager.php(153): Wikimedia\\Rdbms\\DBConnRef->doAtomicSection(string, Closure)\n#9
		core\\extensions\\ContentTranslation\\api\\ApiContentTranslationSave.php(225): ContentTranslation\\TranslationStorageManager::save(ContentTranslation\\TranslationUnit, boolean)\n#10
		core\\extensions\\ContentTranslation\\api\\ApiContentTranslationSave.php(72): ApiContentTranslationSave->saveTranslationUnits(array, ContentTranslation\\Translation)\n#11
		core\\includes\\api\\ApiMain.php(1570): ApiContentTranslationSave->execute()\n#12
		core\\includes\\api\\ApiMain.php(531): ApiMain->executeAction()\n#13
		core\\includes\\api\\ApiMain.php(502): ApiMain->executeActionWithErrorHandling()\n#14
		core\\api.php(87): ApiMain->execute()\n#15 {main}"
    }
}

Event Timeline

Pginer-WMF triaged this task as Medium priority.Oct 29 2018, 2:13 PM
Pginer-WMF moved this task from Needs Triage to CX2 on the ContentTranslation board.

Logstash link https://logstash.wikimedia.org/goto/283793d30db4b1fb906c83aa339be9e3

Error: 1062 Duplicate entry '553685-source-0-20181029131857' for key 'cx_corpora_unique' (10.64.0.108)

To investigate: Why are we trying to save the source multiple times?

Change 471661 had a related patch set uploaded (by Petar.petkovic; owner: Petar.petkovic):
[mediawiki/extensions/ContentTranslation@master] Revert "Save: Don't miss unmodified MT while there is modified content"

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

Change 471715 had a related patch set uploaded (by Petar.petkovic; owner: Petar.petkovic):
[mediawiki/extensions/ContentTranslation@master] Don't save translation unit with "origin: source" twice

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

Change 471661 abandoned by Petar.petkovic:
Revert "Save: Don't miss unmodified MT while there is modified content"

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

Change 471715 merged by Santhosh:
[mediawiki/extensions/ContentTranslation@master] Don't save translation unit with "origin: source" twice

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

Checked in cx2 - no errors. Will re-check after wmf.4 deployment to group2. the recent wmf.3 still produce the error in the logstash:
[W@zLgApAIDgAAJjhqU0AAADM] /w/api.php Wikimedia\Rdbms\DBQueryError from line 1506 [...]

@timestamp 2018-11-15T01:27:29:
Error: 1062 Duplicate entry '561065-source-0-20181115012729' for key 'cx_corpora_unique' (10.64.0.108)

Checked in enwiki wmf.4 - no errors.