MediaWiki REL1_28
|
Helper class that detects high-contention DB queries via profiling calls. More...
Public Member Functions | |
__construct () | |
recordConnection ( $server, $db, $isMaster) | |
Mark a DB as having been connected to with a new handle. | |
recordQueryCompletion ( $query, $sTime, $isWrite=false, $n=0) | |
Register the name and time of a method for slow DB trx detection. | |
resetExpectations () | |
Reset performance expectations and hit counters. | |
setExpectation ( $event, $value, $fname) | |
Set performance expectations. | |
setExpectations (array $expects, $fname) | |
Set multiple performance expectations. | |
setLogger (LoggerInterface $logger) | |
setSilenced ( $value) | |
transactionWritingIn ( $server, $db, $id) | |
Mark a DB as in a transaction with one or more writes pending. | |
transactionWritingOut ( $server, $db, $id, $writeTime=0.0) | |
Mark a DB as no longer in a transaction. | |
Protected Member Functions | |
reportExpectationViolated ( $expect, $query, $actual=null) | |
Protected Attributes | |
float | $dbLockThreshold = 3.0 |
Seconds. | |
array | $dbTrxHoldingLocks = [] |
transaction ID => (write start time, list of DBs involved) | |
array | $dbTrxMethodTimes = [] |
transaction ID => list of (query name, start time, end time) | |
float | $eventThreshold = .25 |
Seconds. | |
array | $expect |
array | $expectBy = [] |
array | $hits |
bool | $silenced = false |
Private Attributes | |
LoggerInterface | $logger |
Helper class that detects high-contention DB queries via profiling calls.
This class is meant to work with an IDatabase object, which manages queries
Definition at line 36 of file TransactionProfiler.php.
TransactionProfiler::__construct | ( | ) |
Definition at line 74 of file TransactionProfiler.php.
References setLogger().
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.
string | $server | DB server |
string | $db | DB name |
bool | $isMaster |
Definition at line 154 of file TransactionProfiler.php.
References reportExpectationViolated().
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)
string | $query | Function name or generalized SQL |
float | $sTime | Starting UNIX wall time |
bool | $isWrite | Whether this is a write query |
integer | $n | Number of affected rows |
Definition at line 200 of file TransactionProfiler.php.
References $name, $query, as, and reportExpectationViolated().
|
protected |
string | $expect | |
string | $query | |
string | float | int | $actual | [optional] |
Definition at line 321 of file TransactionProfiler.php.
References $expect.
Referenced by recordConnection(), recordQueryCompletion(), and transactionWritingOut().
TransactionProfiler::resetExpectations | ( | ) |
Reset performance expectations and hit counters.
Definition at line 133 of file TransactionProfiler.php.
References as.
TransactionProfiler::setExpectation | ( | $event, | |
$value, | |||
$fname | |||
) |
Set performance expectations.
With conflicting expectations, the most narrow ones will be used
string | $event | (writes,queries,conns,mConns) |
integer | $value | Maximum count of the event |
string | $fname | Caller |
Definition at line 104 of file TransactionProfiler.php.
References $fname, and $value.
Referenced by setExpectations().
TransactionProfiler::setExpectations | ( | array | $expects, |
$fname | |||
) |
Set multiple performance expectations.
With conflicting expectations, the most narrow ones will be used
array | $expects | Map of (event => limit) |
$fname |
Definition at line 122 of file TransactionProfiler.php.
References $fname, $value, as, and setExpectation().
TransactionProfiler::setLogger | ( | LoggerInterface | $logger | ) |
Definition at line 78 of file TransactionProfiler.php.
References $logger.
Referenced by __construct().
TransactionProfiler::setSilenced | ( | $value | ) |
bool | $value | New value |
Definition at line 87 of file TransactionProfiler.php.
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.
string | $server | DB server |
string | $db | DB name |
string | $id | ID string of transaction |
Definition at line 173 of file TransactionProfiler.php.
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.
string | $server | DB server |
string | $db | DB name |
string | $id | ID string of transaction |
float | $writeTime | Time spent in write queries |
Definition at line 266 of file TransactionProfiler.php.
References $name, $query, as, list, and reportExpectationViolated().
|
protected |
Seconds.
Definition at line 38 of file TransactionProfiler.php.
|
protected |
transaction ID => (write start time, list of DBs involved)
Definition at line 45 of file TransactionProfiler.php.
|
protected |
transaction ID => list of (query name, start time, end time)
Definition at line 47 of file TransactionProfiler.php.
|
protected |
Seconds.
Definition at line 40 of file TransactionProfiler.php.
|
protected |
Definition at line 57 of file TransactionProfiler.php.
Referenced by reportExpectationViolated().
|
protected |
Definition at line 67 of file TransactionProfiler.php.
|
protected |
Definition at line 50 of file TransactionProfiler.php.
|
private |
Definition at line 72 of file TransactionProfiler.php.
Referenced by setLogger().
|
protected |
Definition at line 42 of file TransactionProfiler.php.
Referenced by setSilenced().