Oracle: DRCP and persistent connections support
authorfreakolowsky <freak@drajv.si>
Fri, 24 May 2013 14:05:20 +0000 (16:05 +0200)
committerAntoine Musso <hashar@free.fr>
Wed, 29 May 2013 19:46:36 +0000 (21:46 +0200)
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
includes/DefaultSettings.php
includes/db/DatabaseOracle.php

index a26c7d8..000f6b1 100644 (file)
@@ -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
index 173605c..29d3127 100644 (file)
@@ -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.
index 4fa2397..c0d3805 100644 (file)
@@ -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 );