Page MenuHomePhabricator

CI jobs on REL1_27 fails with: updatelog: Duplicate entry 'updatelist-1.27.5-XXXXXy for key 'PRIMARY'
Closed, ResolvedPublic

Description

https://integration.wikimedia.org/ci/job/release-quibble-vendor-mysql-php70-docker/130/console

00:24:31 Error: 1062 Duplicate entry 'updatelist-1.27.5-15397322710' for key 'PRIMARY' (localhost:/workspace/db/quibble-mysql-u59t5tcn/socket)

Not sure if AbuseFilter specific

Event Timeline

I have hit that one a few times during the summer. To the best I can tell, it is a time based race condition when running install.php immediately followed by update.php. Both track updates via an entry in the updatelog database, the primary key is forged using PHP time() which is not precise enough when updates are made in the same second.

The code path is no more in recent versions of MediaWiki iirc.

I went with microtime( true ) in the fundraising/REL1_27 branch and that seems to have fixed it ( https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/467685/ ). So probably we can pick that patch for REL1_27 as well.

Change 467685 had a related patch set uploaded (by Hashar; owner: Hashar):
[mediawiki/core@fundraising/REL1_27] Augment precision of updatelist time

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

Change 467895 had a related patch set uploaded (by Hashar; owner: Hashar):
[mediawiki/core@REL1_27] Augment precision of updatelist time

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

hashar renamed this task from release-quibble-vendor-mysql-php*-docker failing on REL1_27 AbuseFilter to CI jobs on REL1_27 fails with: updatelog: Duplicate entry 'updatelist-1.27.5-XXXXXy for key 'PRIMARY'.Oct 17 2018, 7:12 AM

The explanation was on T197861#4305139

The duplicate key for the update log is supposedly fixed by ccd051bc44974ba32749c845bf5d9aa0ca96aa24 which does roughly:

abstract class DatabaseUpdater {
    protected static $updateCounter = 0;

    protected function setAppliedUpdates( $version, $updates = [] ) {
        $key = "updatelist-$version-" . time() . self::$updateCounter;
        self::$updateCounter++;
        $this->db->insert( 'updatelog',
            [ 'ul_key' => $key, 'ul_value' => serialize( $updates ) ],
            __METHOD__ );
    }
}

The trace shows a key of updatelist-1.27.4-15295832440 with 15295832440 == 2018-06-21T12:48:45+00:00.

Maybe self::$updateCounter is not properly initialized due to some behavior different in php7.

A second run worked just fine on the dummy change https://gerrit.wikimedia.org/r/c/mediawiki/extensions/BlueSpiceFoundation/+/441382

Change 467895 merged by jenkins-bot:
[mediawiki/core@REL1_27] Augment precision of updatelist time

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

Reedy assigned this task to hashar.
Reedy removed a project: Patch-For-Review.

Change 467685 abandoned by Jforrester:
Augment precision of updatelist time

Reason:
FR is running on REL1_31 now.

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