BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
TransactionProfiler Class Reference
Inheritance diagram for TransactionProfiler:
Collaboration diagram for TransactionProfiler:

Public Member Functions

 setLogger (LoggerInterface $logger)
 
 setExpectation ($event, $value, $fname)
 
 setExpectations (array $expects, $fname)
 
 resetExpectations ()
 
 recordConnection ($server, $db, $isMaster)
 
 transactionWritingIn ($server, $db, $id)
 
 recordQueryCompletion ($query, $sTime, $isWrite=false, $n=0)
 
 transactionWritingOut ($server, $db, $id, $writeTime=0.0)
 

Protected Member Functions

 reportExpectationViolated ($expect, $query, $actual=null)
 

Protected Attributes

 $dbLockThreshold = 3.0
 
 $eventThreshold = .25
 
 $dbTrxHoldingLocks = []
 
 $dbTrxMethodTimes = []
 
 $hits
 
 $expect
 
 $expectBy = []
 

Detailed Description

Helper class that detects high-contention DB queries via profiling calls

This class is meant to work with a DatabaseBase object, which manages queries

Since
1.24

Member Function Documentation

TransactionProfiler::recordConnection (   $server,
  $db,
  $isMaster 
)

Mark a DB as having been connected to with a new handle

Note that there can be multiple connections to a single DB.

Parameters
string$serverDB server
string$dbDB name
bool$isMaster
TransactionProfiler::recordQueryCompletion (   $query,
  $sTime,
  $isWrite = false,
  $n = 0 
)

Register the name and time of a method for slow DB trx detection

This assumes that all queries are synchronous (non-overlapping)

Parameters
string$queryFunction name or generalized SQL
float$sTimeStarting UNIX wall time
bool$isWriteWhether this is a write query
integer$nNumber of affected rows
TransactionProfiler::reportExpectationViolated (   $expect,
  $query,
  $actual = null 
)
protected
Parameters
string$expect
string$query
string | float | int$actual[optional]
TransactionProfiler::resetExpectations ( )

Reset performance expectations and hit counters

Since
1.25
TransactionProfiler::setExpectation (   $event,
  $value,
  $fname 
)

Set performance expectations

With conflicting expectations, the most narrow ones will be used

Parameters
string$event(writes,queries,conns,mConns)
integer$valueMaximum count of the event
string$fnameCaller
Since
1.25
TransactionProfiler::setExpectations ( array  $expects,
  $fname 
)

Set multiple performance expectations

With conflicting expectations, the most narrow ones will be used

Parameters
array$expectsMap of (event => limit)
$fname
Since
1.26
TransactionProfiler::setLogger ( LoggerInterface  $logger)

Sets a logger instance on the object

Parameters
LoggerInterface$logger
Returns
null

Implements Psr\Log\LoggerAwareInterface.

TransactionProfiler::transactionWritingIn (   $server,
  $db,
  $id 
)

Mark a DB as in a transaction with one or more writes pending

Note that there can be multiple connections to a single DB.

Parameters
string$serverDB server
string$dbDB name
string$idID string of transaction
TransactionProfiler::transactionWritingOut (   $server,
  $db,
  $id,
  $writeTime = 0.0 
)

Mark a DB as no longer in a transaction

This will check if locks are possibly held for longer than needed and log any affected transactions to a special DB log. Note that there can be multiple connections to a single DB.

Parameters
string$serverDB server
string$dbDB name
string$idID string of transaction
float$writeTimeTime spent in write queries

Member Data Documentation

TransactionProfiler::$expect
protected
Initial value:
= [
'writes' => INF
TransactionProfiler::$hits
protected
Initial value:
= [
'writes' => 0

The documentation for this class was generated from the following file: