Page MenuHomePhabricator

Update from 1.37.2 to 1.39.2 fails on MariaDB with "Error 1062: Duplicate entry for key 'PRIMARY'" on templatelinks
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Fork wiki from fandom
  • Upgrade to 1.37.6 successfully
  • Switch to 1.39.2 installation files and run update.php

What happens?:

Modifying tl_namespace field of table templatelinks...Wikimedia\Rdbms\DBQueryError from line 1618 of w/includes/libs/rdbms/database/Database.php: Error 1062: Duplicate entry '62841-575' for key 'PRIMARY'
Function: Wikimedia\Rdbms\Database::sourceFile( w/maintenance/archives/patch-templatelinks-tl_title-nullable.sql )
Query: ALTER TABLE  `templatelinks`
 ADD  PRIMARY KEY (tl_from, tl_target_id)
select * from templatelinks where tl_from='62841' and tl_target_id='575';
+---------+--------------+----------+-------------------+--------------+
| tl_from | tl_namespace | tl_title | tl_from_namespace | tl_target_id |
+---------+--------------+----------+-------------------+--------------+
|   62841 |            0 |          |                 6 |          575 |
|   62841 |           10 | FileInfo |                 6 |          575 |
+---------+--------------+----------+-------------------+--------------+

Rows with tl_namespace='0' and tl_title='' are created in the database. Found a total of 12 of these entries in the database. After deleting them, and recreating a PRIMARY KEY (to avoid T324646), the rerunning the update completed successfully.

Software version (skip for WMF-hosted wikis like Wikipedia):

  • PHP 7.4.3
  • MariaDB 10.3.38

Seems similar to T324516, but this is MariaDB.

Event Timeline

Umherirrender renamed this task from Update from 1.37.2 to 1.39.2 fails on MariaDB with "Error 1062: Duplicate entry for key 'PRIMARY'" to Update from 1.37.2 to 1.39.2 fails on MariaDB with "Error 1062: Duplicate entry for key 'PRIMARY'" on templatelinks.Mar 16 2023, 8:38 PM

I noticed the same bug!

  • Mediawiki 1.35.6 environment
  • Upgrading to 1.39.3
  • PHP 8.0.23
  • MariaDB 10.4.26

removing the duplicate entries with empty titles worked for me as well. Thanks @Prod ! You saved our production deployment