r59755 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59754‎ | r59755 | r59756 >
Date:10:33, 5 December 2009
Author:maxsem
Status:ok (Comments)
Tags:
Comment:
Eliminated deadlock during parser tests on SQLite
Modified paths:
  • /trunk/phase3/includes/BagOStuff.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/BagOStuff.php
@@ -221,10 +221,19 @@
222222 var $lastExpireAll = 0;
223223
224224 protected function getDB() {
225 - if ( !isset( $this->lb ) ) {
226 - $this->lb = wfGetLBFactory()->newMainLB();
227 - $this->db = $this->lb->getConnection( DB_MASTER );
228 - $this->db->clearFlag( DBO_TRX );
 225+ global $wgDBtype;
 226+ if ( !isset( $this->db ) ) {
 227+ /* We must keep a separate connection to MySQL in order to avoid deadlocks
 228+ * However, SQLite has an opposite behaviour.
 229+ * @todo Investigate behaviour for other databases
 230+ */
 231+ if ( $wgDBtype == 'sqlite' ) {
 232+ $this->db = wfGetDB( DB_MASTER );
 233+ } else {
 234+ $this->lb = wfGetLBFactory()->newMainLB();
 235+ $this->db = $this->lb->getConnection( DB_MASTER );
 236+ $this->db->clearFlag( DBO_TRX );
 237+ }
229238 }
230239 return $this->db;
231240 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r63730* (bug 22828) Fixed deletion on SQLite in 1.15 - backportage of r59755maxsem05:42, 14 March 2010

Comments

#Comment by Simetrical (talk | contribs)   18:01, 16 March 2010

Shouldn't you be using $this->db->getType() instead of $wgDBtype?

#Comment by MaxSem (talk | contribs)   17:19, 22 March 2010

Err, what, call object's member functions before creating it?

#Comment by Simetrical (talk | contribs)   18:07, 22 March 2010

Um, right, never mind me. Not sure if this is the best way to do it, but I don't understand what's happening here well enough to propose a different way.

Status & tagging log