Formalising live performance hack
authorTim Starling <tstarling@users.mediawiki.org>
Mon, 25 Jul 2005 06:57:12 +0000 (06:57 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Mon, 25 Jul 2005 06:57:12 +0000 (06:57 +0000)
includes/Block.php
includes/DefaultSettings.php
includes/Defines.php

index f97cabc..0763133 100644 (file)
@@ -63,7 +63,7 @@ class Block
         */
        function load( $address = '', $user = 0, $killExpired = true ) 
        {
-               global $wgDBmysql4 ;
+               global $wgDBmysql4, $wgAntiLockFlags;
                $fname = 'Block::load';
                wfDebug( "Block::load: '$address', '$user', $killExpired\n" );
 
@@ -71,7 +71,11 @@ class Block
                $killed = false;
                if ( $this->forUpdate() ) {
                        $db =& wfGetDB( DB_MASTER );
-                       $options = 'FOR UPDATE';
+                       if ( $wgAntiLockFlags & ALF_NO_BLOCK_LOCK ) {
+                               $options = '';
+                       } else {
+                               $options = 'FOR UPDATE';
+                       }
                } else {
                        $db =& wfGetDB( DB_SLAVE );
                        $options = '';
@@ -169,10 +173,16 @@ class Block
         */
        /*static*/ function enumBlocks( $callback, $tag, $flags = 0 ) 
        {
+               global $wgAntiLockFlags;
+
                $block = new Block();
                if ( $flags & EB_FOR_UPDATE ) {
                        $db =& wfGetDB( DB_MASTER );
-                       $options = 'FOR UPDATE';
+                       if ( $wgAntiLockFlags & ALF_NO_BLOCK_LOCK ) {
+                               $options = '';
+                       } else {
+                               $options = 'FOR UPDATE';
+                       }
                        $block->forUpdate( true );
                } else {
                        $db =& wfGetDB( DB_SLAVE );
index cacbf1d..f2f4836 100644 (file)
@@ -959,6 +959,13 @@ $wgUseDumbLinkUpdate = false;
  *       Preload links during link update for save
  *   ALF_PRELOAD_EXISTENCE
  *       Preload cur_id during replaceLinkHolders
+ *   ALF_NO_LINK_LOCK
+ *       Don't use locking reads when updating the link table. This is 
+ *       necessary for wikis with a high edit rate for performance 
+ *       reasons, but may cause link table inconsistency
+ *   ALF_NO_BLOCK_LOCK
+ *       As for ALF_LINK_LOCK, this flag is a necessity for high-traffic
+ *       wikis.
  */
 $wgAntiLockFlags = 0;
 
index 34231bf..67789ec 100644 (file)
@@ -126,6 +126,7 @@ define( 'AV_SCAN_FAILED', false );  #scan failed (scanner not found or error in
 define( 'ALF_PRELOAD_LINKS', 1 );
 define( 'ALF_PRELOAD_EXISTENCE', 2 );
 define( 'ALF_NO_LINK_LOCK', 4 );
+define( 'ALF_NO_BLOCK_LOCK', 8 );
 /**#@-*/
 
 ?>