Package: phpbb2 Version: 2.0.21-6 Severity: important When using phpbb2 with MySQL, it is generally recommended that the session table be type HEAP to reduce disk activity and increase performance. This however has the disadvantage of eventually filling up the session table, making it impossible to create new sessions, and thereby allowing new users to log in.
The attached patch will, provided that mysql or mysql4 is used as SQL Layer, expand MAX_ROWS of the session table by 50 when encountering this problem, until it reaches 2500. At that point it will delete the oldest sessions from the session table, which will by then have expired. This effectively prevents the problem from occuring, and is IMHO a better solution than having to empty the session table manually or automatically, which will also throw out logged in users. The patch was grabbed from the phpbb.com knowledge base, available on their site before the redesign. It can still be viewed here: http://web.archive.org/web/20060110233238/http://www.phpbb.com/kb/article.php?article_id=42 where it is also described as the recommended approach to this problem. Why it has not been applied upstream I do not know, but in my experience it seems to work well, although it should probably be tested slightly more extensively before applying in Debian. Thanks. -- System Information: Debian Release: lenny/sid APT prefers testing APT policy: (500, 'testing') Architecture: i386 (i686) Kernel: Linux 2.6.18-3-686 (SMP w/1 CPU core) Locale: LANG=en_US, LC_CTYPE=en_US (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages phpbb2 depends on: ii apache [httpd] 1.3.34-4.1 versatile, high-performance HTTP s ii apache2-mpm-prefork [httpd] 2.2.3-4 Traditional model for Apache HTTPD ii debconf [debconf-2.0] 1.5.13 Debian configuration management sy ii libapache-mod-php5 5.2.0-10 server-side, HTML-embedded scripti ii libapache2-mod-php5 5.2.0-10 server-side, HTML-embedded scripti ii php5 5.2.0-10 server-side, HTML-embedded scripti ii php5-mysql 5.2.0-10 MySQL module for php5 Versions of packages phpbb2 recommends: ii phpbb2-conf-mysql 2.0.21-6 Automatic configurator for phpbb2 ii qmail [mail-transport-agent] 1.0 Dummy Qmail package to avoid dependency warnings -- debconf information: * phpbb2/httpd: apache
--- sessions.old 2007-01-18 00:35:40.000000000 +0100 +++ sessions.php 2007-04-15 18:54:09.000000000 +0200 @@ -186,7 +186,36 @@ VALUES ('$session_id', $user_id, $current_time, $current_time, '$user_ip', $page_id, $login)"; if ( !$db->sql_query($sql) ) { - message_die(CRITICAL_ERROR, 'Error creating new session', '', __LINE__, __FILE__, $sql); + $error = TRUE; + if (SQL_LAYER == "mysql" || SQL_LAYER == "mysql4") + { + $sql_error = $db->sql_error($result); + if ($sql_error["code"] == 1114) + { + $result = $db->sql_query('SHOW TABLE STATUS LIKE "'.SESSIONS_TABLE.'"'); + $row = $db->sql_fetchrow($result); + if ($row["Type"] == "HEAP") + { + if ($row["Rows"] > 2500) + { + $delete_order = (SQL_LAYER=="mysql4") ? " ORDER BY session_time ASC" : ""; + $db->sql_query("DELETE QUICK FROM ".SESSIONS_TABLE."$delete_order LIMIT 50"); + } + else + { + $db->sql_query("ALTER TABLE ".SESSIONS_TABLE." MAX_ROWS=".($row["Rows"]+50)); + } + if ($db->sql_query($sql)) + { + $error = FALSE; + } + } + } + } + if ($error) + { + message_die(CRITICAL_ERROR, "Error creating new session", "", __LINE__, __FILE__, $sql); + } } } @@ -573,4 +602,4 @@ return $url; } -?> \ No newline at end of file +?>