From cd736291de2bc59c36002691276cb40c06b3fed4 Mon Sep 17 00:00:00 2001 From: freakolowsky Date: Fri, 24 May 2013 16:05:20 +0200 Subject: [PATCH] Oracle: DRCP and persistent connections support Adds $wgDBOracleDRCP, when set to true, enables persistent connection with DRCP on Oracle. Requires Oracle DB 11gR1 or above. More informations about DRCP can be found at: http://www.oracle-base.com/articles/11g/database-resident-connection-pool-11gr1.php Change-Id: I2be7120a2ebec39d866b79be62ac715bbc3738a9 --- RELEASE-NOTES-1.22 | 7 +++++++ includes/DefaultSettings.php | 29 +++++++++++++++++++++++++++++ includes/db/DatabaseOracle.php | 10 +++++++++- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index a26c7d8541..000f6b1709 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -26,6 +26,7 @@ production. * $wgHandheldStyle was removed. * $wgJsMimeType is no longer used by core. Most usage has been removed since HTML output is now exclusively HTML5. +* $wgDBOracleDRCP added. True enables persistent connection with DRCP on Oracle. === New features in 1.22 === * (bug 44525) mediawiki.jqueryMsg can now parse (whitelisted) HTML elements and attributes. @@ -86,6 +87,12 @@ production. HTTP caches when a page is changed. * Changed the patrolling system to always show the link for patrolling in case the current revision is patrollable. This also removed the usage of the rcid URI parameters. +* Oracle DB backend now supports Database Resident Connection Pooling (DRCP). + Can be enabled by setting $wgDBOracleDRCP=true. + Requires Oracle DB 11gR1 or above, enabled DRCP inside the DB itself and a + propper connect string. + More about DRCP can be found at: + http://www.oracle-base.com/articles/11g/database-resident-connection-pool-11gr1.php === Bug fixes in 1.22 === * Disable Special:PasswordReset when $wgEnableEmail is false. Previously one diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 173605cceb..29d3127b02 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1589,6 +1589,35 @@ $wgDBAvgStatusPoll = 2000; */ $wgDBmysql5 = false; +/** + * Set true to enable Oracle DCRP (supported from 11gR1 onward) + * + * To use this feature set to true and use a datasource defined as + * POOLED (i.e. in tnsnames definition set server=pooled in connect_data + * block). + * + * Starting from 11gR1 you can use DCRP (Database Resident Connection + * Pool) that maintains established sessions and reuses them on new + * connections. + * + * Not completely tested, but it should fall back on normal connection + * in case the pool is full or the datasource is not configured as + * pooled. + * And the other way around; using oci_pconnect on a non pooled + * datasource should produce a normal connection. + * + * When it comes to frequent shortlived DB connections like with MW + * Oracle tends to s***. The problem is the driver connects to the + * database reasonably fast, but establishing a session takes time and + * resources. MW does not rely on session state (as it does not use + * features such as package variables) so establishing a valid session + * is in this case an unwanted overhead that just slows things down. + * + * @warning EXPERIMENTAL! + * + */ +$wgDBOracleDRCP = false; + /** * Other wikis on this site, can be administered from a single developer * account. diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index 4fa2397c2c..c0d3805d58 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -249,6 +249,7 @@ class DatabaseOracle extends DatabaseBase { * @return DatabaseBase|null */ function open( $server, $user, $password, $dbName ) { + global $wgDBOracleDRCP; if ( !function_exists( 'oci_connect' ) ) { throw new DBConnectionError( $this, "Oracle functions missing, have you compiled PHP with the --with-oci8 option?\n (Note: if you recently installed PHP, you may need to restart your webserver and database)\n" ); } @@ -276,9 +277,16 @@ class DatabaseOracle extends DatabaseBase { return; } + if ( $wgDBOracleDRCP ) { + $this->setFlag( DBO_PERSISTENT ); + } + $session_mode = $this->mFlags & DBO_SYSDBA ? OCI_SYSDBA : OCI_DEFAULT; + wfSuppressWarnings(); - if ( $this->mFlags & DBO_DEFAULT ) { + if ( $this->mFlags & DBO_PERSISTENT ) { + $this->mConn = oci_pconnect( $this->mUser, $this->mPassword, $this->mServer, $this->defaultCharset, $session_mode ); + } else if ( $this->mFlags & DBO_DEFAULT ) { $this->mConn = oci_new_connect( $this->mUser, $this->mPassword, $this->mServer, $this->defaultCharset, $session_mode ); } else { $this->mConn = oci_connect( $this->mUser, $this->mPassword, $this->mServer, $this->defaultCharset, $session_mode ); -- 2.20.1