r104069 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104068‎ | r104069 | r104070 >
Date:19:25, 23 November 2011
Author:aaron
Status:resolved
Tags:
Comment:
Factored setTimeout() into setSessionOptions() and deprecated the former. In the future we can batch the queries perhaps. Also added a lock wait timeout option.
Modified paths:
  • /trunk/phase3/includes/db/Database.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseMysql.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabaseMysql.php
@@ -602,9 +602,17 @@
603603 return false;
604604 }
605605
606 - public function setTimeout( $timeout ) {
607 - $this->query( "SET net_read_timeout=$timeout" );
608 - $this->query( "SET net_write_timeout=$timeout" );
 606+ public function setSessionOptions( array $options ) {
 607+ if ( isset( $options['connTimeout'] ) ) {
 608+ $timeout = (int)$options['connTimeout'];
 609+ $this->query( "SET net_read_timeout=$timeout" );
 610+ $this->query( "SET net_write_timeout=$timeout" );
 611+ }
 612+ if ( isset( $options['lockTimeout'] ) ) {
 613+ $timeout = (int)$options['lockTimeout'];
 614+ $this->query( "SET table_lock_wait_timeout=$timeout" ); // table level
 615+ $this->query( "SET innodb_lock_wait_timeout=$timeout" ); // row level
 616+ }
609617 }
610618
611619 public function lock( $lockName, $method, $timeout = 5 ) {
Index: trunk/phase3/includes/db/Database.php
@@ -2994,16 +2994,30 @@
29952995 }
29962996
29972997 /**
2998 - * Override database's default connection timeout. May be useful for very
2999 - * long batch queries such as full-wiki dumps, where a single query reads
3000 - * out over hours or days. May or may not be necessary for non-MySQL
3001 - * databases. For most purposes, leaving it as a no-op should be fine.
 2998+ * Override database's default connection timeout
30022999 *
30033000 * @param $timeout Integer in seconds
 3001+ * @return void
 3002+ * @deprecated since 1.19; use setSessionOptions()
30043003 */
3005 - public function setTimeout( $timeout ) {}
 3004+ public function setTimeout( $timeout ) {
 3005+ $this->setSessionOptions( array( 'connTimeout' => $timeout ) );
 3006+ }
30063007
30073008 /**
 3009+ * Override database's default behavior. $options include:
 3010+ * 'connTimeout' : Set the connection timeout value in seconds.
 3011+ * May be useful for very long batch queries such as
 3012+ * full-wiki dumps, where a single query reads out over
 3013+ * hours or days.
 3014+ * 'lockTimeout' : Set the lock wait timeout value in seconds.
 3015+ *
 3016+ * @param $options Array
 3017+ * @return void
 3018+ */
 3019+ public function setSessionOptions( array $options ) {}
 3020+
 3021+ /**
30083022 * Read and execute SQL commands from a file.
30093023 *
30103024 * Returns true on success, error string or exception on failure (depending

Follow-up revisions

RevisionCommit summaryAuthorDate
r104087Reverted 'lockTimeout' option from r104069: table_lock_wait_timeout is GLOBAL...aaron21:03, 23 November 2011

Status & tagging log