Made TransactionProfiler affected-row warnings not trigger for JobRunner
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 18 Feb 2015 00:50:12 +0000 (16:50 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 18 Feb 2015 00:50:12 +0000 (16:50 -0800)
* The CLI check did not work since jobs can work via HTTP requests

Change-Id: I524e79fd51275777c1505e29ecf0725b998eabcc

includes/MediaWiki.php
includes/profiler/TransactionProfiler.php

index 2a0a405..c21f5e9 100644 (file)
@@ -497,6 +497,7 @@ class MediaWiki {
                        $trxProfiler = Profiler::instance()->getTransactionProfiler();
                        $trxProfiler->setExpectation( 'masterConns', 0, __METHOD__ );
                        $trxProfiler->setExpectation( 'writes', 0, __METHOD__ );
+                       $trxProfiler->setExpectation( 'maxAffected', 500, __METHOD__ );
                }
 
                // If the user has forceHTTPS set to true, or if the user
index 9609bd3..b313558 100644 (file)
@@ -34,8 +34,6 @@ class TransactionProfiler {
        protected $dbLockThreshold = 3.0;
        /** @var float Seconds */
        protected $eventThreshold = .25;
-       /** @var integer */
-       protected $affectedThreshold = 500;
 
        /** @var array transaction ID => (write start time, list of DBs involved) */
        protected $dbTrxHoldingLocks = array();
@@ -54,7 +52,8 @@ class TransactionProfiler {
                'writes'      => INF,
                'queries'     => INF,
                'conns'       => INF,
-               'masterConns' => INF
+               'masterConns' => INF,
+               'maxAffected' => INF
        );
        /** @var array */
        protected $expectBy = array();
@@ -154,9 +153,9 @@ class TransactionProfiler {
                $eTime = microtime( true );
                $elapsed = ( $eTime - $sTime );
 
-               if ( $isWrite && $n > $this->affectedThreshold && PHP_SAPI !== 'cli' ) {
+               if ( $isWrite && $n > $this->expect['maxAffected'] ) {
                        wfDebugLog( 'DBPerformance',
-                               "Query affected $n rows:\n" . $query . "\n" . wfBacktrace( true ) );
+                               "Query affected $n row(s):\n" . $query . "\n" . wfBacktrace( true ) );
                }
 
                // Report when too many writes/queries happen...