Changeset:
9afad0b9a784
https://sourceforge.net/p/mrbs/hg-code/ci/9afad0b9a784bf8b3de2daf5d1037bc46537ef75
Author:
Campbell Morrison <[email protected]>
Date:
Tue Dec 22 14:46:42 2015 +0000
Log message:
Changed MRBS default behaviour to be *not* to use persistent database
connections, as they can cause problems with transactions and locks. At the
same time changed the config variable to be $db_persist instead of
$db_nopersist.
diffstat:
INSTALL | 17 +++++++++--------
README.sqlapi | 12 ++++++------
tables.my.sql | 2 +-
tables.pg.sql | 2 +-
web/config.inc.php | 9 +++++++--
web/dbsys.inc | 2 +-
web/internalconfig.inc.php | 9 +++++++++
web/mysqli.inc | 8 ++------
web/pgsql.inc | 9 ++-------
web/systemdefaults.inc.php | 9 +++++++--
web/upgrade/48/mysql.sql | 1 +
web/upgrade/48/post.inc | 15 +++++++++++++++
12 files changed, 61 insertions(+), 34 deletions(-)
diffs (219 lines):
diff -r 7bca8a61c4c3 -r 9afad0b9a784 INSTALL
--- a/INSTALL Sat Dec 19 16:19:15 2015 +0000
+++ b/INSTALL Tue Dec 22 14:46:42 2015 +0000
@@ -368,14 +368,15 @@
$db_host="localhost". Or, with PostgreSQL only, you can use $db_host="" to
use Unix Domain Sockets to connect to the database server on the same machine.
-By default, MRBS will use PHP persistent (pooled) database connections,
-for better performance. Depending on your web server and database server
-configuration, it is possible that this will cause MRBS to reach the maximum
-number of connections allowed to your database, since each Apache child
-process may keep a connection open. Then, users will randomly get errors
-when trying connecting to MRBS. If you would rather use non-persistent
-database connections, uncomment the line in "config.inc.php" which sets the
-$db_nopersist variable.
+By default, MRBS will not use PHP persistent (pooled) database connections.
+Persistent connections can sometimes give better performance, but they can
+also cause problems with transactions and locks. For more details see
+http://php.net/manual/en/features.persistent-connections.php Although
+MRBS is designed to work with persistent connections we recommend that you
+don't use them unless they give a significant performance boost. To use
+persistent connections set
+
+ $db_persist = TRUE;
If you want to install multiple sets of mrbs tables when only one
SQL database is available, or resolve table name conflicts, you have
diff -r 7bca8a61c4c3 -r 9afad0b9a784 README.sqlapi
--- a/README.sqlapi Sat Dec 19 16:19:15 2015 +0000
+++ b/README.sqlapi Tue Dec 22 14:46:42 2015 +0000
@@ -19,8 +19,8 @@
of unique persistent connection strings (PostgreSQL conninfo's, unique
combinations of user/password/database) implemented on your site. Note that
the default for PostgreSQL is a maximum of 32 connections, and the default
-for Apache MaxClients is 150. If you do not want to use persistent
-connections, set $db_nopersist as described below.
+for Apache MaxClients is 150. If you want to use persistent connections,
+see the $persist parameter to sql_connect() below.
-----------------------------------------------------------------------------
@@ -227,11 +227,11 @@
sql_version()
Return a string identifying the database system and version.
-sql_connect($host, $username, $password, $db_name, $persist)
+sql_connect($host, $username, $password, $db_name, $persist, $db_port)
Connects to the specified database using the specified credentials,
- optionally using persistent database connections. Returns an MRBS
- specific database handle, which can be passed as the last argument of
- all the other sql_*() functions.
+ optionally using persistent database connections and a port number.
+ Returns an MRBS specific database handle, which can be passed as the
+ last argument of all the other sql_*() functions.
-----------------------------------------------------------------------------
diff -r 7bca8a61c4c3 -r 9afad0b9a784 tables.my.sql
--- a/tables.my.sql Sat Dec 19 16:19:15 2015 +0000
+++ b/tables.my.sql Tue Dec 22 14:46:42 2015 +0000
@@ -190,6 +190,6 @@
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO mrbs_variables (variable_name, variable_content)
- VALUES ( 'db_version', '47');
+ VALUES ( 'db_version', '48');
INSERT INTO mrbs_variables (variable_name, variable_content)
VALUES ( 'local_db_version', '1');
diff -r 7bca8a61c4c3 -r 9afad0b9a784 tables.pg.sql
--- a/tables.pg.sql Sat Dec 19 16:19:15 2015 +0000
+++ b/tables.pg.sql Tue Dec 22 14:46:42 2015 +0000
@@ -181,6 +181,6 @@
);
INSERT INTO mrbs_variables (variable_name, variable_content)
- VALUES ('db_version', '47');
+ VALUES ('db_version', '48');
INSERT INTO mrbs_variables (variable_name, variable_content)
VALUES ('local_db_version', '1');
diff -r 7bca8a61c4c3 -r 9afad0b9a784 web/config.inc.php
--- a/web/config.inc.php Sat Dec 19 16:19:15 2015 +0000
+++ b/web/config.inc.php Tue Dec 22 14:46:42 2015 +0000
@@ -62,8 +62,13 @@
// Prefix for table names. This will allow multiple installations where only
// one database is available
$db_tbl_prefix = "mrbs_";
-// Uncomment this to NOT use PHP persistent (pooled) database connections:
-// $db_nopersist = 1;
+// Set $db_persist to TRUE to use PHP persistent (pooled) database
connections. Note
+// that persistent connections are not recommended unless your system suffers
significant
+// performance problems without them. They can cause problems with
transactions and
+// locks (see http://php.net/manual/en/features.persistent-connections.php)
and although
+// MRBS tries to avoid those problems, it is generally better not to use
persistent
+// connections if you can.
+$db_persist = FALSE;
/* Add lines from systemdefaults.inc.php and areadefaults.inc.php below here
diff -r 7bca8a61c4c3 -r 9afad0b9a784 web/dbsys.inc
--- a/web/dbsys.inc Sat Dec 19 16:19:15 2015 +0000
+++ b/web/dbsys.inc Tue Dec 22 14:46:42 2015 +0000
@@ -23,7 +23,7 @@
}
-$db_schema_version = 47;
+$db_schema_version = 48;
$local_db_schema_version = 1;
// Include the abstraction configured to be used for the default MRBS
diff -r 7bca8a61c4c3 -r 9afad0b9a784 web/internalconfig.inc.php
--- a/web/internalconfig.inc.php Sat Dec 19 16:19:15 2015 +0000
+++ b/web/internalconfig.inc.php Tue Dec 22 14:46:42 2015 +0000
@@ -129,6 +129,15 @@
trigger_error($message, E_USER_NOTICE);
}
+// Variables no longer used in versions of MRBS > 1.5.0
+if (isset($db_nopersist))
+{
+ $db_persist = !$db_nopersist;
+ $message = 'Please check your config file. The $db_nopersist config
variable ' .
+ 'has been replaced by $db_persist';
+ trigger_error($message, E_USER_NOTICE);
+}
+
/********************************************************
* Checking
diff -r 7bca8a61c4c3 -r 9afad0b9a784 web/mysqli.inc
--- a/web/mysqli.inc Sat Dec 19 16:19:15 2015 +0000
+++ b/web/mysqli.inc Tue Dec 22 14:46:42 2015 +0000
@@ -602,17 +602,13 @@
//
function sql_mysqli_default_connect()
{
- global $sql_mysqli_conn, $db_nopersist, $db_host, $db_login, $db_password,
+ global $sql_mysqli_conn, $db_persist, $db_host, $db_login, $db_password,
$db_database, $db_port;
/////////////////////////////////////////////
// Open the standard MRBS database connection
- $persist = 1;
- if (!empty($db_nopersist) && $db_nopersist)
- {
- $persist = 0;
- }
+ $persist = !empty($db_persist);
$port = NULL;
// If a port is specified, cast it to int as mysqli doesn't accept
diff -r 7bca8a61c4c3 -r 9afad0b9a784 web/pgsql.inc
--- a/web/pgsql.inc Sat Dec 19 16:19:15 2015 +0000
+++ b/web/pgsql.inc Tue Dec 22 14:46:42 2015 +0000
@@ -621,18 +621,13 @@
//
function sql_pgsql_default_connect()
{
- global $sql_pgsql_conn, $db_nopersist, $db_host, $db_login, $db_password,
+ global $sql_pgsql_conn, $db_persist, $db_host, $db_login, $db_password,
$db_database, $db_port;
/////////////////////////////////////////////
// Open the standard MRBS database connection
- $persist = 1;
- if (!empty($db_nopersist) && $db_nopersist)
- {
- $persist = 0;
- }
- global $sql_pgsql_conn;
+ $persist = !empty($db_persist);
$port = null;
// If a port is specified, cast it to int for safety
diff -r 7bca8a61c4c3 -r 9afad0b9a784 web/systemdefaults.inc.php
--- a/web/systemdefaults.inc.php Sat Dec 19 16:19:15 2015 +0000
+++ b/web/systemdefaults.inc.php Tue Dec 22 14:46:42 2015 +0000
@@ -79,8 +79,13 @@
// Prefix for table names. This will allow multiple installations where only
// one database is available
$db_tbl_prefix = "mrbs_";
-// Uncomment this to NOT use PHP persistent (pooled) database connections:
-// $db_nopersist = 1;
+// Set $db_persist to TRUE to use PHP persistent (pooled) database
connections. Note
+// that persistent connections are not recommended unless your system suffers
significant
+// performance problems without them. They can cause problems with
transactions and
+// locks (see http://php.net/manual/en/features.persistent-connections.php)
and although
+// MRBS tries to avoid those problems, it is generally better not to use
persistent
+// connections if you can.
+$db_persist = FALSE;
/*********************************
diff -r 7bca8a61c4c3 -r 9afad0b9a784 web/upgrade/48/mysql.sql
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/upgrade/48/mysql.sql Tue Dec 22 14:46:42 2015 +0000
@@ -0,0 +1,1 @@
+#
diff -r 7bca8a61c4c3 -r 9afad0b9a784 web/upgrade/48/post.inc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/upgrade/48/post.inc Tue Dec 22 14:46:42 2015 +0000
@@ -0,0 +1,15 @@
+<?php
+
+$message = "If you have just upgraded to MRBS 1.5.1 or later please " .
+ "note that the config setting '" . '$db_nopersist' . "' has been
replaced " .
+ "by '" . '$db_persist' . "'. The default setting for MRBS is now
*not* to " .
+ "use persistent connections.";
+?>
+
+<script type="text/javascript">
+//<![CDATA[
+ alert("<?php echo $message?>");
+//]];
+</script>
+
+<?php
------------------------------------------------------------------------------
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits