From: Aaron Schulz Date: Wed, 23 Nov 2011 19:25:59 +0000 (+0000) Subject: Factored setTimeout() into setSessionOptions() and deprecated the former. In the... X-Git-Tag: 1.31.0-rc.0~26318 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%7B%7B%20url_for%28%27admin_users%27%29%20%7D%7D?a=commitdiff_plain;h=12f430217fdf1ff53f64557c3a390049e8c6f0c9;p=lhc%2Fweb%2Fwiklou.git Factored setTimeout() into setSessionOptions() and deprecated the former. In the future we can batch the queries perhaps. Also added a lock wait timeout option. --- diff --git a/includes/db/Database.php b/includes/db/Database.php index 8dc2a9edee..ac2f159f72 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -2994,14 +2994,28 @@ abstract class DatabaseBase implements DatabaseType { } /** - * Override database's default connection timeout. May be useful for very - * long batch queries such as full-wiki dumps, where a single query reads - * out over hours or days. May or may not be necessary for non-MySQL - * databases. For most purposes, leaving it as a no-op should be fine. + * Override database's default connection timeout * * @param $timeout Integer in seconds + * @return void + * @deprecated since 1.19; use setSessionOptions() */ - public function setTimeout( $timeout ) {} + public function setTimeout( $timeout ) { + $this->setSessionOptions( array( 'connTimeout' => $timeout ) ); + } + + /** + * Override database's default behavior. $options include: + * 'connTimeout' : Set the connection timeout value in seconds. + * May be useful for very long batch queries such as + * full-wiki dumps, where a single query reads out over + * hours or days. + * 'lockTimeout' : Set the lock wait timeout value in seconds. + * + * @param $options Array + * @return void + */ + public function setSessionOptions( array $options ) {} /** * Read and execute SQL commands from a file. diff --git a/includes/db/DatabaseMysql.php b/includes/db/DatabaseMysql.php index 22810abdc9..3a93e0f198 100644 --- a/includes/db/DatabaseMysql.php +++ b/includes/db/DatabaseMysql.php @@ -602,9 +602,17 @@ class DatabaseMysql extends DatabaseBase { return false; } - public function setTimeout( $timeout ) { - $this->query( "SET net_read_timeout=$timeout" ); - $this->query( "SET net_write_timeout=$timeout" ); + public function setSessionOptions( array $options ) { + if ( isset( $options['connTimeout'] ) ) { + $timeout = (int)$options['connTimeout']; + $this->query( "SET net_read_timeout=$timeout" ); + $this->query( "SET net_write_timeout=$timeout" ); + } + if ( isset( $options['lockTimeout'] ) ) { + $timeout = (int)$options['lockTimeout']; + $this->query( "SET table_lock_wait_timeout=$timeout" ); // table level + $this->query( "SET innodb_lock_wait_timeout=$timeout" ); // row level + } } public function lock( $lockName, $method, $timeout = 5 ) {