Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > Programming Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Work Around: Error SQL server exceeded max questions
Zachariah's Avatar
Zachariah
Join Date: Feb 2002
Posts: 2,125

AS Electronics Experance in PHP, HTML, JavaScript, DHTML, Flash, XML, MySQL, Photoshop, more. Electronics I, II, III, Microprocessors, AC and DC Electronics, Boolean Algebra, Trig / Math Analysis, Chemistry / AP Physics

Canoga Park, CA
Show Printable Version Email this Page Subscription
Zachariah Zachariah is offline 02-09-2009, 10:00 PM

vBulletin: 3.0x / 3.5x / 3.6x / 3.7x / 3.8x

Quote:
"Error: SQL server exceeded 50,000 max questions"
- All mySQL is stopped for like 5 min then all is ok.
- The server it self auto temp bans the mysql account in use.

I am sure others may have ran into this issue. I have ran into many webhosts that because of "server loads" have a cap on max questions mySQL server can be given in a time frame. (1 hour in my case) This becomes a huge problem when doing maintenance of "Update Counters" in the AdminCP.

One workaround is to create multiple mysql users in your hosting account. In config.php you randomly pick one of these users to connect to the database. This will spread the questions between users and since the limit is per user. This is not a perfect solution for if an account maxes out the script will stop, but you can usually overcome the problem.

I set up 7 accounts in mySQL up on 1 database all using the same password.
I ran 236,968 queries without a hiccup.

Edit:
includes/config.php

Find:
PHP Code:
//***** MASTER DATABASE USERNAME & PASSWORD ****** 
//    This is the username and password you use to access MySQL. 
//    These must be obtained through your webhost. 

$config['MasterServer']['username'] = '';
$config['MasterServer']['password'] = ''
Replace with:
PHP Code:
//***** MASTER DATABASE USERNAME & PASSWORD ******
//    This is the username and password you use to access MySQL.
//    These must be obtained through your webhost.
$dblogins = array();

$dblogins['1']['user'] = 'user1';
$dblogins['2']['user'] = 'user2';
$dblogins['3']['user'] = 'user3';
$dblogins['4']['user'] = 'user4';
$dblogins['5']['user'] = 'user5';
$dblogins['6']['user'] = 'user6';
$dblogins['7']['user'] = 'user7';

srand((float) microtime() * 10000000);
$dbloginid array_rand($dblogins);
while (
$dblogins[$dbloginid]['user'] == '')
{
    
$dbloginid array_rand($dblogins);
}
$config['MasterServer']['username'] = $dblogins[$dbloginid]['user'];

unset(
$dblogins$dbloginid);

$config['MasterServer']['password'] = 'password'
1) Make sure and replace user1, user2, user3, user4, user5, user6, user7 with the correct user names made for the database.

2) Also replace password with the correct password.
Reply With Quote
  #2  
Old 03-11-2009, 06:43 PM
Sweeks Sweeks is offline
 
Join Date: Jul 2008
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anyone confirm this to work fine on vbulletin 3.8.1?
________
Lesbian Scissoring
Reply With Quote
  #3  
Old 03-12-2009, 10:50 AM
Zachariah's Avatar
Zachariah Zachariah is offline
 
Join Date: Feb 2002
Location: Canoga Park, CA
Posts: 2,125
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yep, no poblems.

With a few changes the concept should work with any php program that accesses mySql.
Reply With Quote
  #4  
Old 03-12-2009, 06:53 PM
Sweeks Sweeks is offline
 
Join Date: Jul 2008
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can this work around this error?

Code:
User x already has more than 'max_user_connections' active connections
/home/xxx/public_html/includes/class_core.php on line 311

MySQL Error   : 
Error Number  :
Hope it can avoid this if possible.
________
BOX VAPORIZER
Reply With Quote
  #5  
Old 03-13-2009, 10:13 PM
Zachariah's Avatar
Zachariah Zachariah is offline
 
Join Date: Feb 2002
Location: Canoga Park, CA
Posts: 2,125
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It should in theory.

max_user_connections - this limits only the number of simultaneous connections made using a single account.
  • The number of queries that an account can issue per hour
  • The number of updates that an account can issue per hour
  • The number of times an account can connect to the server per hour
  • The number of simultaneous connections to the server an account can have (as of MySQL 5.0.3)

This little bit of code takes multiple mysql user accounts (all with the same password) and spread the questions between users at random.
Reply With Quote
  #6  
Old 03-22-2009, 09:35 AM
bokmade bokmade is offline
 
Join Date: Feb 2002
Location: Doha
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Does It Work With web hosting limit connection ?If the limit 25 we can get 100 if four user ?

Does It Speed Up the Forum and Increase the server load ?

Thanks.
Reply With Quote
  #7  
Old 03-23-2009, 05:16 PM
Zachariah's Avatar
Zachariah Zachariah is offline
 
Join Date: Feb 2002
Location: Canoga Park, CA
Posts: 2,125
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There is no harm in trying. I have not ran into this problem to test for an answer.

The number of simultaneous connections to the server an account can have are limits per account. If there are multi accounts, I would think each account has a limit of 25 vs. each database with a max limit.

Try it out and see if your problem goes away. Report back findings please .
Reply With Quote
  #8  
Old 03-30-2009, 09:39 AM
Frondy's Avatar
Frondy Frondy is offline
 
Join Date: Feb 2009
Location: Zagreb, Croatia
Posts: 62
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
1. Create additional user(s)
Create more MySQL user/password's and give these full permissions to your database.

2. Edit you config.php, and locate the following lines (they should alerady contain the user/password for your current setup):

PHP Code:
 // ****** MASTER DATABASE USERNAME & PASSWORD ******
// This is the username and password you use to access MySQL.
// These must be obtained through your webhost.
$config['MasterServer']['username'] = 'root';
$config['MasterServer']['password'] = ''
After the first 3 comment lines, add the following:

PHP Code:
$dbusers = array(
array(
'user' => 'mysql_username_1''password' => 'mysql_password_1'// First MySQL user/password combination
, array('user' => 'mysql_username_2''password' => 'mysql_password_2'// Second MySQL user/password combination
, array('user' => 'mysql_username_3''password' => 'mysql_password_3'// Third MySQL user/password combination
);
$mysql_user $dbusers[rand(0count($dbusers) - 1)]; 
Edit mysql_username_X and mysql_password_X to have valid MySQL username/password combinations. If you need more then 3 combination, just duplicate the third line. If you are only using 2 combinations, remove the third combination.

3. Now edit the lines that configure your username password (they will probably already contain the info for the first MySQL user).
find:

PHP Code:
$config['MasterServer']['username'] = 'root';
$config['MasterServer']['password'] = ''
and replace them with:

PHP Code:
$config['MasterServer']['username'] = $mysql_user['user'];
$config['MasterServer']['password'] = $mysql_user['password']; 
4. Check your edits, the complete block should look something like:

PHP Code:
 // ****** MASTER DATABASE USERNAME & PASSWORD ******
// This is the username and password you use to access MySQL.
// These must be obtained through your webhost.
$dbusers = array(
array(
'user' => 'mysql_username_1''password' => 'mysql_password_1'// First MySQL user/password combination
, array('user' => 'mysql_username_2''password' => 'mysql_password_2'// Second MySQL user/password combination
, array('user' => 'mysql_username_3''password' => 'mysql_password_3'// Third MySQL user/password combination
);
$mysql_user $dbusers[rand(0count($dbusers) - 1)];
$config['MasterServer']['username'] = $mysql_user['user'];
$config['MasterServer']['password'] = $mysql_user['password']; 
5. Save and upload your config.php. Finished.

Everytime a page is opened, 1 of the defined username/password combinations will be choosen at random, and by this reducing the number of connections for each user.
I found this quoted article on vb.com site, is it the same purpose variant? ('max_user_connections' issue)


.
Reply With Quote
  #9  
Old 04-21-2009, 05:58 PM
MyChemicalSelf's Avatar
MyChemicalSelf MyChemicalSelf is offline
 
Join Date: Oct 2008
Posts: 160
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks dude im using this
Reply With Quote
  #10  
Old 04-26-2010, 03:53 AM
thinkfast thinkfast is offline
 
Join Date: Mar 2010
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

is this work for vbulletin 4?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:53 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04394 seconds
  • Memory Usage 2,328KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (7)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete