[go: up one dir, main page]

Page MenuHomePhabricator

DBQueryError: Deadlock found when trying to get lock; try restarting transaction Function: LocalFileRestoreBatch::execute (from Special:Undelete)
Open, Needs TriagePublicPRODUCTION ERROR

Description

[7d056718-a02b-49e7-835f-d77e86a8996f] 2023-04-28 14:53:33: Fatal exception of type "Wikimedia\Rdbms\DBQueryError"
[7c972457-3458-4323-b341-aaa8d92ba2eb] 2023-04-28 14:53:34: Fatal exception of type "Wikimedia\Rdbms\DBTransactionSizeError"
[a1246752-cca1-4c52-ba0f-03178c9e7ff6] 2023-04-28 14:53:33: Fatal exception of type "Wikimedia\Rdbms\DBQueryError"

while undeleting files

Event Timeline

I can’t find the second request ID in logstash, but the first and third are deadlocks on INSERT INTO image:

Error 1213: Deadlock found when trying to get lock; try restarting transaction
Function: LocalFileRestoreBatch::execute

#6 /srv/mediawiki/php-1.41.0-wmf.6/includes/filerepo/file/LocalFileRestoreBatch.php(322): Wikimedia\Rdbms\DBConnRef->insert(string, array, string)
#7 /srv/mediawiki/php-1.41.0-wmf.6/includes/filerepo/file/LocalFile.php(2407): LocalFileRestoreBatch->execute()
		// Run the DB updates
		// Because we have locked the image row, key conflicts should be rare.
		// If they do occur, we can roll back the transaction at this time with
		// no data loss, but leaving unregistered files scattered throughout the
		// public zone.
		// This is not ideal, which is why it's important to lock the image row.
		if ( $insertCurrent ) {
			$dbw->insert( 'image', $insertCurrent, __METHOD__ );
		}

That means undeleting similiar named images in different tabs can result in deadlock as the same "gap" on the database needs locking.
Try to undelete the second file when the first file is finish.

The code can try to reduce the time of lock, but the really fix would be T28741

Krinkle renamed this task from Fatal exception of type "Wikimedia\Rdbms\DBQueryError" while undeleting files to DBQueryError: Deadlock found when trying to get lock; try restarting transaction Function: LocalFileRestoreBatch::execute (from Special:Undelete).Jul 13 2023, 3:11 PM
Krinkle moved this task from Untriaged to Apr 2023 on the Wikimedia-production-error board.