Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

SQL-error: "more than 'max_user_connections' active"

SheriffenSheriffen
edited May 2010 in Vanilla 2.0 - 2.8
Hey!
I've been building a site on vanilla now for a couple of months (Yep, v2, I know I'm stupid)
I have been developing on a local machine but now as I push up to server I get:

SQLSTATE[42000] [1203] User [MYUSERNAME] already has more than 'max_user_connections' active connections

I know this might be limited by the host but is there any chance that vanilla2 is not closing connections or something like that? Something that vanilla does that contributes to the connections?

Thanks in advance, it's suuuuch a pleasure developing apps for vanilla with the m-v-c pattern, great job guys!

//The Sheriff

Comments

  • Php will automatically close any connections at the end of the scripts execution anyway. How many people are trying to access this page?
  • The thing is that it appers that it doesn't close. I have it on a temporary server that only I know of (temp url) and if I reload a page, say /discussions about 20-25 times I get the max_user_connections error. Seems like my host has a limit of 20-25 and that vanilla doesnt close. Weird!
  • Having talked to the host again and uploaded to another host we concluded that it must be the host which is strange since its one of the biggest host-companies here in sweden. Thanks anyways :)
  • Ok I need help on this one. The difference between my 2 hosts is that the one that its working on has the MySQL on localhost and the one that gets the MAX_USER_CONNECTIONS has MySQL on a separate server. I have backtraced and tested to echo "close" on the database class CloseConnection() function and it always does which means it successfully closes the connection. I have noticed that its always the same class that triggers the error, it's the session class on UserModel->GetSession();

    Here is the complete errorpage:
    An error occurred while attempting to connect to the database
    SQLSTATE[42000] [1203] User USERNAME already has more than 'max_user_connections' active connections
    The error occurred on or near: /www/webvol8/gd/35tgdqhp95a6udj/jesuspeople.se/public_html/library/database/class.database.php

    56: $this->_Connection = new PDO(strtolower($this->Engine) . ':' . $this->Dsn, $this->User, $this->Password, $this->ConnectionOptions);
    57: if($this->ConnectionOptions[1002])
    58: $this->Query($this->ConnectionOptions[1002]);
    59: } catch (Exception $ex) {
    60: trigger_error(ErrorMessage('An error occurred while attempting to connect to the database', $this->ClassName, 'Connection', $ex->getMessage()), E_USER_ERROR);
    61: }
    62: }
    63:
    64: return $this->_Connection;

    Backtrace
    /www/webvol8/gd/35tgdqhp95a6udj/jesuspeople.se/public_html/library/database/class.database.phpPHP::Gdn_ErrorHandler();
    [/www/webvol8/gd/35tgdqhp95a6udj/jesuspeople.se/public_html/library/database/class.database.php:60] PHP::trigger_error();
    [/www/webvol8/gd/35tgdqhp95a6udj/jesuspeople.se/public_html/library/database/class.database.php:226] Gdn_Database->Connection();
    [/www/webvol8/gd/35tgdqhp95a6udj/jesuspeople.se/public_html/plugins/Debugger/class.database.debug.php:90] Gdn_Database->Query();
    [/www/webvol8/gd/35tgdqhp95a6udj/jesuspeople.se/public_html/library/database/class.sqldriver.php:1495] Gdn_DatabaseDebug->Query();
    [/www/webvol8/gd/35tgdqhp95a6udj/jesuspeople.se/public_html/library/database/class.sqldriver.php:609] Gdn_SQLDriver->Query();
    [/www/webvol8/gd/35tgdqhp95a6udj/jesuspeople.se/public_html/applications/dashboard/models/class.usermodel.php:202] Gdn_SQLDriver->Get();
    [/www/webvol8/gd/35tgdqhp95a6udj/jesuspeople.se/public_html/library/core/class.session.php:239] UserModel->GetSession();
    [/www/webvol8/gd/35tgdqhp95a6udj/jesuspeople.se/public_html/index.php:30] Gdn_Session->Start();
    Is there some kind of garbage collection that has to be done? Cause even though they close it seems that alot of old connections are floating aroung somehow. Please help, I'm getting sick and tired of this problem!
  • If anyone else comes across this problem try changing the PDO::ATTR_PERSISTENT => FALSE to TRUE instead. My webhosts didn't support persistent connections which caused the MySQL error
  • I recently encountered the same problem. I noticed that it only occurred when there where two or more users logged into my site. adding PDO::ATTR_PERSISTENT => TRUE fixed it right up.
    So thanks for sharing that.

  • Hello,

    Could you tell me where (on which file) can I change this ? : FALSE to TRUE ?
    Thank you very much

  • jackjitsujackjitsu ✭✭
    edited September 2013

    Edit the file /conf/config-defaults.php
    Line: 16

    Change

    12 => FLASE, //PDO::ATTR_PERSISTENT => FALSE,

    to:

    12 => TRUE, //PDO::ATTR_PERSISTENT => FALSE,

    Huuuuge improvement

  • Also check mysql config param: max_user_connections

  • DOH.... thought the title said "max_connections". Ignore previous post :)

  • @Sheriffen said:
    If anyone else comes across this problem try changing the PDO::ATTR_PERSISTENT => FALSE to TRUE instead. My webhosts didn't support persistent connections which caused the MySQL error

    Well, I recommend x10hosting.com


    Free, and it has never given me problems with MySQL

Sign In or Register to comment.