Page MenuHomePhabricator

Block::purgeExpired giving "Lock wait timeout exceeded;"/"Deadlock"
Closed, DeclinedPublic

Description

"Block::purgeExpired". Database returned error "1205: Lock wait timeout exceeded; try restarting transaction"

Getting more common

Needs dealing with.

<domas> reedy: open another connection with a separate transaction for the actual purge DELETE statement
<domas> reedy: you have to create new LoadBalancer object for that I hear
<domas> Tim once showed me how, was something really simple
<domas> but this is a good thing to do both for ipblocks purges and recentchanges ones


Version: 1.17.x
Severity: normal

Details

Reference
bz28485

Event Timeline

bzimport raised the priority of this task from to High.Nov 21 2014, 11:37 PM
bzimport set Reference to bz28485.
bzimport added a subscriber: Unknown Object (MLST).

Created attachment 8390
Patch...

attachment bug 28485.patch ignored as obsolete

Tim, is this simply what is needed to fix this issue?

No, wfGetLB() does not create a new load balancer, it gets a cached one. You want:

$lb = wfGetLBFactory()->newMainLB();
$db = $lb->getConnection( DB_MASTER );
...
$lb->commitMasterChanges();
$lb->closeAll();

Comment on attachment 8390
Patch...

Index: Block.php

  • Block.php (revision 85768)

+++ Block.php (working copy)
@@ -889,7 +889,9 @@

    • Purge expired blocks from the ipblocks table */ public static function purgeExpired() {
  • $dbw = wfGetDB( DB_MASTER );

+ global $wgDbBname;
+ $lb = wfGetLb( $wgDbBname );
+ $dbw = $lb->getConnection( DB_MASTER, array(), $wgDbBname );

		$dbw->delete( 'ipblocks', array( 'ipb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), __METHOD__ );
	}

Reverted in r85916, pending a better solution

Mon Apr 18 20:01:46 UTC 2011 srv279 enwiki Block::purgeExpired 10.0.6.46 1213 Deadlock found when trying to get lock; try restarting transaction (10.0.6.46) DELETE FROM ipblocks WHERE (ipb_expiry < '20110418200055')

Expanding and assigning bug

Sam, is this still an issue, and is it still getting more frequent? If so, we can figure out which one of us will deal with this sometime after Wikimania.

For all of July, and august so far, picking up all the errors > 500 we have the below

So This is still the most common DB error on wikimedia wikis

Totals:
Deadlock total count:8278
Lock wait timeout total count:4979
Dupe entry total count:1656

Block::purgeExpired 4147
Job::pop_type 3940
Article::updateCategoryCounts 1490
User::invalidateCache 1091
SimpleSurvey::save 770
Title::invalidateCache 759
Job::pop 757
GlobalUsage::insertLinks 700

Could you update the stats for September so we can see relative frequency?

<binasher> yeah, just looked at the last month of db error logs, no issues from Block::purgeExpired

sumanah wrote:

<binasher> Block::purgeExpired is not hitting lock timeouts.
<sumanah> binasher: so we can close as no repro, correct?
<binasher> yeah, just looked at the last month of db error logs, no issues from Block::purgeExpired

So this isn't happening anymore and I'm closing this bug.