26use Psr\Log\LoggerInterface;
27use Psr\Log\LoggerAwareInterface;
28use Psr\Log\NullLogger;
65 'readQueryRows' => INF,
66 'readQueryTime' => INF,
67 'writeQueryTime' => INF
108 $this->expect[$event] = isset( $this->expect[$event] )
109 ? min( $this->expect[$event],
$value )
111 if ( $this->expect[$event] ==
$value ) {
112 $this->expectBy[$event] =
$fname;
128 foreach ( $expects
as $event =>
$value ) {
143 foreach ( $this->hits
as &$val ) {
147 foreach ( $this->expect
as &$val ) {
151 $this->expectBy = [];
180 if ( $this->hits[
'conns']++ >= $this->expect[
'conns'] ) {
182 'conns',
"[connect to $server ($db)]", $this->hits[
'conns'] );
184 if ( $isMaster && $this->hits[
'masterConns']++ >= $this->expect[
'masterConns'] ) {
186 'masterConns',
"[connect to $server ($db)]", $this->hits[
'masterConns'] );
200 $name =
"{$server} ({$db}) (TRX#$id)";
201 if ( isset( $this->dbTrxHoldingLocks[
$name] ) ) {
202 $this->logger->warning(
"Nested transaction for '$name' - out of sync." );
204 $this->dbTrxHoldingLocks[
$name] = [
205 'start' => microtime(
true ),
208 $this->dbTrxMethodTimes[
$name] = [];
210 foreach ( $this->dbTrxHoldingLocks
as $name => &$info ) {
212 $info[
'conns'][
$name] = 1;
227 $eTime = microtime(
true );
228 $elapsed = ( $eTime - $sTime );
230 if ( $isWrite && $n > $this->expect[
'maxAffected'] ) {
231 $this->logger->warning(
232 "Query affected $n row(s):\n" .
$query .
"\n" .
233 (
new RuntimeException() )->getTraceAsString() );
234 } elseif ( !$isWrite && $n > $this->expect[
'readQueryRows'] ) {
235 $this->logger->warning(
236 "Query returned $n row(s):\n" .
$query .
"\n" .
237 (
new RuntimeException() )->getTraceAsString() );
241 if ( $this->hits[
'queries']++ >= $this->expect[
'queries'] ) {
244 if ( $isWrite && $this->hits[
'writes']++ >= $this->expect[
'writes'] ) {
248 if ( !$isWrite && $elapsed > $this->expect[
'readQueryTime'] ) {
251 if ( $isWrite && $elapsed > $this->expect[
'writeQueryTime'] ) {
255 if ( !$this->dbTrxHoldingLocks ) {
258 } elseif ( !$isWrite && $elapsed < $this->eventThreshold ) {
263 foreach ( $this->dbTrxHoldingLocks
as $name => $info ) {
264 $lastQuery = end( $this->dbTrxMethodTimes[
$name] );
267 $lastEnd = $lastQuery[2];
268 if ( $sTime >= $lastEnd ) {
269 if ( ( $sTime - $lastEnd ) > $this->eventThreshold ) {
271 $this->dbTrxMethodTimes[
$name][] = [
'...delay...', $lastEnd, $sTime ];
273 $this->dbTrxMethodTimes[
$name][] = [
$query, $sTime, $eTime ];
277 if ( $sTime >= $info[
'start'] ) {
278 $this->dbTrxMethodTimes[
$name][] = [
$query, $sTime, $eTime ];
298 $name =
"{$server} ({$db}) (TRX#$id)";
299 if ( !isset( $this->dbTrxMethodTimes[
$name] ) ) {
300 $this->logger->warning(
"Detected no transaction for '$name' - out of sync." );
307 if ( $writeTime > $this->expect[
'writeQueryTime'] ) {
310 "[transaction $id writes to {$server} ({$db})]",
316 if ( $affected > $this->expect[
'maxAffected'] ) {
319 "[transaction $id writes to {$server} ({$db})]",
324 $lastQuery = end( $this->dbTrxMethodTimes[
$name] );
326 $now = microtime(
true );
327 $lastEnd = $lastQuery[2];
328 if ( ( $now - $lastEnd ) > $this->eventThreshold ) {
329 $this->dbTrxMethodTimes[
$name][] = [
'...delay...', $lastEnd, $now ];
333 foreach ( $this->dbTrxMethodTimes[
$name]
as $info ) {
334 $elapsed = ( $info[2] - $info[1] );
335 if ( $elapsed >= $this->dbLockThreshold ) {
342 foreach ( $this->dbTrxMethodTimes[
$name]
as $i => $info ) {
344 $trace .= sprintf(
"%d\t%.6f\t%s\n", $i, ( $end - $sTime ),
$query );
346 $this->logger->warning(
"Sub-optimal transaction on DB(s) [{dbs}]: \n{trace}", [
347 'dbs' => implode(
', ', array_keys( $this->dbTrxHoldingLocks[
$name][
'conns'] ) ),
351 unset( $this->dbTrxHoldingLocks[
$name] );
352 unset( $this->dbTrxMethodTimes[
$name] );
361 if ( $this->silenced ) {
365 $this->logger->warning(
366 "Expectation ({measure} <= {max}) by {by} not met (actual: {actual}):\n{query}\n" .
367 (
new RuntimeException() )->getTraceAsString(),
370 'max' => $this->expect[
$expect],
371 'by' => $this->expectBy[
$expect],
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Allows to change the fields on the form that will be generated $name
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))