dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Tweaked BagOStuff::lock() retry times slightly to be faster"
[lhc/web/wiklou.git]
/
includes
/
db
/
DatabaseMysqlBase.php
diff --git
a/includes/db/DatabaseMysqlBase.php
b/includes/db/DatabaseMysqlBase.php
index
7dfae63
..
7b903d6
100644
(file)
--- a/
includes/db/DatabaseMysqlBase.php
+++ b/
includes/db/DatabaseMysqlBase.php
@@
-58,7
+58,6
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
*/
function open( $server, $user, $password, $dbName ) {
global $wgAllDBsAreLocalhost, $wgSQLMode;
*/
function open( $server, $user, $password, $dbName ) {
global $wgAllDBsAreLocalhost, $wgSQLMode;
- wfProfileIn( __METHOD__ );
# Debugging hack -- fake cluster
if ( $wgAllDBsAreLocalhost ) {
# Debugging hack -- fake cluster
if ( $wgAllDBsAreLocalhost ) {
@@
-72,8
+71,6
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
$this->mPassword = $password;
$this->mDBname = $dbName;
$this->mPassword = $password;
$this->mDBname = $dbName;
- wfProfileIn( "dbconnect-$server" );
-
# The kernel's default SYN retransmission period is far too slow for us,
# so we use a short timeout plus a manual retry. Retrying means that a small
# but finite rate of SYN packet loss won't cause user-visible errors.
# The kernel's default SYN retransmission period is far too slow for us,
# so we use a short timeout plus a manual retry. Retrying means that a small
# but finite rate of SYN packet loss won't cause user-visible errors.
@@
-82,15
+79,11
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
try {
$this->mConn = $this->mysqlConnect( $realServer );
} catch ( Exception $ex ) {
try {
$this->mConn = $this->mysqlConnect( $realServer );
} catch ( Exception $ex ) {
- wfProfileOut( "dbconnect-$server" );
- wfProfileOut( __METHOD__ );
$this->restoreErrorHandler();
throw $ex;
}
$error = $this->restoreErrorHandler();
$this->restoreErrorHandler();
throw $ex;
}
$error = $this->restoreErrorHandler();
- wfProfileOut( "dbconnect-$server" );
-
# Always log connection errors
if ( !$this->mConn ) {
if ( !$error ) {
# Always log connection errors
if ( !$this->mConn ) {
if ( !$error ) {
@@
-107,8
+100,6
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
"Server: $server, User: $user, Password: " .
substr( $password, 0, 3 ) . "..., error: " . $error . "\n" );
"Server: $server, User: $user, Password: " .
substr( $password, 0, 3 ) . "..., error: " . $error . "\n" );
- wfProfileOut( __METHOD__ );
-
$this->reportConnectionError( $error );
}
$this->reportConnectionError( $error );
}
@@
-126,8
+117,6
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
wfDebug( "Error selecting database $dbName on server {$this->mServer} " .
"from client host " . wfHostname() . "\n" );
wfDebug( "Error selecting database $dbName on server {$this->mServer} " .
"from client host " . wfHostname() . "\n" );
- wfProfileOut( __METHOD__ );
-
$this->reportConnectionError( "Error selecting database $dbName" );
}
}
$this->reportConnectionError( "Error selecting database $dbName" );
}
}
@@
-137,25
+126,29
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
$this->reportConnectionError( "Error setting character set" );
}
$this->reportConnectionError( "Error setting character set" );
}
+ // Abstract over any insane MySQL defaults
+ $set = array( 'group_concat_max_len = 262144' );
// Set SQL mode, default is turning them all off, can be overridden or skipped with null
if ( is_string( $wgSQLMode ) ) {
// Set SQL mode, default is turning them all off, can be overridden or skipped with null
if ( is_string( $wgSQLMode ) ) {
- $mode = $this->addQuotes( $wgSQLMode );
+ $set[] = 'sql_mode = ' . $this->addQuotes( $wgSQLMode );
+ }
+
+ if ( $set ) {
// Use doQuery() to avoid opening implicit transactions (DBO_TRX)
// Use doQuery() to avoid opening implicit transactions (DBO_TRX)
- $success = $this->doQuery(
"SET sql_mode = $mode"
, __METHOD__ );
+ $success = $this->doQuery(
'SET ' . implode( ', ', $set )
, __METHOD__ );
if ( !$success ) {
wfLogDBError(
if ( !$success ) {
wfLogDBError(
-
"Error setting sql_mode to $mode on server {db_server}"
,
+
'Error setting MySQL variables on server {db_server} (check $wgSQLMode)'
,
$this->getLogContext( array(
'method' => __METHOD__,
) )
);
$this->getLogContext( array(
'method' => __METHOD__,
) )
);
- wfProfileOut( __METHOD__ );
-
$this->reportConnectionError( "Error setting sql_mode to $mode"
);
+ $this->reportConnectionError(
+
'Error setting MySQL variables on server {db_server} (check $wgSQLMode)'
);
}
}
$this->mOpened = true;
}
}
$this->mOpened = true;
- wfProfileOut( __METHOD__ );
return true;
}
return true;
}
@@
-671,7
+664,6
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
return '0'; // http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html
}
return '0'; // http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html
}
- wfProfileIn( __METHOD__ );
# Commit any open transactions
$this->commit( __METHOD__, 'flush' );
# Commit any open transactions
$this->commit( __METHOD__, 'flush' );
@@
-680,18
+672,15
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
if ( $wait > $timeout * 1e6 ) {
wfDebug( "Fake slave timed out waiting for $pos ($wait us)\n" );
if ( $wait > $timeout * 1e6 ) {
wfDebug( "Fake slave timed out waiting for $pos ($wait us)\n" );
- wfProfileOut( __METHOD__ );
return -1;
} elseif ( $wait > 0 ) {
wfDebug( "Fake slave waiting $wait us\n" );
usleep( $wait );
return -1;
} elseif ( $wait > 0 ) {
wfDebug( "Fake slave waiting $wait us\n" );
usleep( $wait );
- wfProfileOut( __METHOD__ );
return 1;
} else {
wfDebug( "Fake slave up to date ($wait us)\n" );
return 1;
} else {
wfDebug( "Fake slave up to date ($wait us)\n" );
- wfProfileOut( __METHOD__ );
return 0;
}
return 0;
}
@@
-711,8
+700,6
@@
abstract class DatabaseMysqlBase extends DatabaseBase {
}
}
}
}
- wfProfileOut( __METHOD__ );
-
return $status;
}
return $status;
}
@@
-1271,13
+1258,15
@@
class MySQLField implements Field {
class MySQLMasterPos implements DBMasterPos {
/** @var string */
public $file;
class MySQLMasterPos implements DBMasterPos {
/** @var string */
public $file;
-
- /** @var int Timestamp */
+ /** @var int Position */
public $pos;
public $pos;
+ /** @var float UNIX timestamp */
+ public $asOfTime = 0.0;
function __construct( $file, $pos ) {
$this->file = $file;
$this->pos = $pos;
function __construct( $file, $pos ) {
$this->file = $file;
$this->pos = $pos;
+ $this->asOfTime = microtime( true );
}
function __toString() {
}
function __toString() {
@@
-1303,4
+1292,8
@@
class MySQLMasterPos implements DBMasterPos {
return ( $thisPos && $thatPos && $thisPos >= $thatPos );
}
return ( $thisPos && $thatPos && $thisPos >= $thatPos );
}
+
+ function asOfTime() {
+ return $this->asOfTime;
+ }
}
}