From 834d6618ac5d1f83972967eb6fe28d13754908c7 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Mon, 11 Apr 2011 12:56:23 +0000 Subject: [PATCH] * (bug 20468) User::invalidateCache throws 1205: Lock wait timeout exceeded --- RELEASE-NOTES | 1 + includes/User.php | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 4a7e9c7cd5..c8ac6873bc 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -237,6 +237,7 @@ PHP if you have not done so prior to upgrading MediaWiki. * (bug 28444) Fix regression: edit-on-doubleclick retains revision id again * (bug 28485) Block::purgeExpired Database returned error "1205: Lock wait timeout exceeded;" +* (bug 20468) User::invalidateCache throws 1205: Lock wait timeout exceeded === API changes in 1.18 === * (bug 26339) Throw warning when truncating an overlarge API result diff --git a/includes/User.php b/includes/User.php index 3ffd4a9276..c9ce405b1a 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1729,12 +1729,18 @@ class User { if( $this->mId ) { $this->mTouched = self::newTouchedTimestamp(); - $dbw = wfGetDB( DB_MASTER ); + // https://bugzilla.wikimedia.org/show_bug.cgi?id=20468 + // Create and use a new loadBalancer object, to prevent "1205: Lock wait timeout exceeded;" + $lb = wfGetLBFactory()->newMainLB(); + $dbw = $lb->getConnection( DB_MASTER ); + $dbw->update( 'user', array( 'user_touched' => $dbw->timestamp( $this->mTouched ) ), array( 'user_id' => $this->mId ), __METHOD__ ); + $lb->commitMasterChanges(); + $lb->closeAll(); $this->clearSharedCache(); } } -- 2.20.1