|
You last visited: Today at 16:00
Advertisement
[Release] Simple MySql Pool handler
Discussion on [Release] Simple MySql Pool handler within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.
07/08/2011, 23:07
|
#16
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
|
Quote:
Originally Posted by marlyandedsel
my MysqlComman
Mysql REader
and part of the DataHolder
can you tell me if this is good or not?
|
Sleeping connections are bad. You'll have them with that code because you're using MySql 6.3.7 (or whatever)'s pool.
|
|
|
07/12/2011, 09:40
|
#17
|
elite*gold: 0
Join Date: Aug 2010
Posts: 343
Received Thanks: 21
|
Fang what Version of MySql should I used so that Sleeping Connection wont happen
|
|
|
07/12/2011, 09:50
|
#18
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
|
Quote:
Originally Posted by marlyandedsel
Fang what Version of MySql should I used so that Sleeping Connection wont happen
|
It happens in every version.
|
|
|
07/12/2011, 10:42
|
#19
|
elite*gold: 0
Join Date: Aug 2010
Posts: 343
Received Thanks: 21
|
Quote:
using System.Data.Odbc;
using System.Data;
/// <summary>
/// This function checks for any sleeping connections beyond a reasonable time and kills them.
/// Since .NET appears to have a bug with how pooling MySQL connections are handled and leaves
/// too many sleeping connections without closing them, we will kill them here.
/// </summary>
/// iMinSecondsToExpire - all connections sleeping more than this amount in seconds will be killed.
/// <returns>integer - number of connections killed</returns>
static public int KillSleepingConnections(int iMinSecondsToExpire)
{
string strSQL = "show processlist";
System.Collections.ArrayList m_ProcessesToKill = new ArrayList();
OdbcConnection myConn = new OdbcConnection(Global.strDBServer);
OdbcCommand myCmd = new OdbcCommand(strSQL, myConn);
OdbcDataReader MyReader = null;
try
{
myConn.Open();
// Get a list of processes to kill.
MyReader = myCmd.ExecuteReader();
while (MyReader.Read())
{
// Find all processes sleeping with a timeout value higher than our threshold.
int iPID = Convert.ToInt32(MyReader["Id"].ToString());
string strState = MyReader["Command"].ToString();
int iTime = Convert.ToInt32(MyReader["Time"].ToString());
if (strState == "Sleep" && iTime >= iMinSecondsToExpire && iPID > 0)
{
// This connection is sitting around doing nothing. Kill it.
m_ProcessesToKill.Add(iPID);
}
}
MyReader.Close();
foreach (int aPID in m_ProcessesToKill)
{
strSQL = "kill " + aPID;
myCmd.CommandText = strSQL;
myCmd.ExecuteNonQuery();
}
}
catch (Exception excep)
{
}
finally
{
if (MyReader != null && !MyReader.IsClosed)
{
MyReader.Close();
}
if (myConn != null && myConn.State == ConnectionState.Open)
{
myConn.Close();
}
}
return m_ProcessesToKill.Count;
}
// Call it with the following code to kill sleeping connections >= 100 seconds.
KillSleepingConnections(100);
|
I search and I got that one but I try to implement it in, I dunno when to call the KillSleepingConnections(100);
|
|
|
07/12/2011, 11:38
|
#20
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
|
Project Kibou has a maintenance thread that cleans up things on the server every 30 seconds. I have the MySql Kill Command in there.
|
|
|
07/13/2011, 19:24
|
#21
|
elite*gold: 0
Join Date: Apr 2009
Posts: 101
Received Thanks: 1
|
i have error Error 1 'Conquer_Online_Server.Database.DataHolder.Connect ionString' is inaccessible due to its protection level C:\Users\Administrator\Desktop\fixed\Source\cleanm ysql.cs 15 98 Conquer_Online_Server_x86
in public static void Kill()
{
string command = "SHOW processlist";
List<ulong> processes = new List<ulong>();
MySqlConnection conn = new MySqlConnection(Conquer_Online_Server.Database.Dat aHolder.ConnectionString);
MySqlCommand cmd = new MySqlCommand(command, conn);
MySqlDataReader reader = null;
|
|
|
07/14/2011, 06:09
|
#22
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
|
Quote:
Originally Posted by koko20
i have error Error 1 'Conquer_Online_Server.Database.DataHolder.Connect ionString' is inaccessible due to its protection level C:\Users\Administrator\Desktop\fixed\Source\cleanm ysql.cs 15 98 Conquer_Online_Server_x86
in public static void Kill()
{
string command = "SHOW processlist";
List<ulong> processes = new List<ulong>();
MySqlConnection conn = new MySqlConnection(Conquer_Online_Server.Database.Dat aHolder.ConnectionString);
MySqlCommand cmd = new MySqlCommand(command, conn);
MySqlDataReader reader = null;
|
There's no way that I'm teaching you how to use the code that you're copying from me. If you cannot figure it out then just don't use it.
|
|
|
07/14/2011, 13:21
|
#23
|
elite*gold: 0
Join Date: Apr 2009
Posts: 101
Received Thanks: 1
|
Thank you my friend Fang Do you think these codes eliminate the problem
|
|
|
07/14/2011, 15:58
|
#24
|
elite*gold: 0
Join Date: Aug 2010
Posts: 343
Received Thanks: 21
|
Fang should I call this KillConnections.Kill(); every reading or opening the database?
|
|
|
07/14/2011, 19:21
|
#25
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
|
Quote:
Originally Posted by koko20
Thank you my friend Fang Do you think these codes eliminate the problem
|
They do. I ran it with a block test and the connections were killed successfully (in the exception to the one connection that it was using to kill the connections- which is killed on the next execution of the void).
Quote:
Originally Posted by marlyandedsel
Fang should I call this KillConnections.Kill(); every reading or opening the database?
|
No. You should make a new thread and call it "ServerManagement" (if you don't already have a server management thread that manages server cleanups and runs about twice a minute). Definitely don't call this to kill connections every time mysql is executed.
|
|
|
07/15/2011, 00:29
|
#26
|
elite*gold: 0
Join Date: Apr 2009
Posts: 782
Received Thanks: 458
|
Call it to kill after every time you query something.... and see what happens ^^
Fang already gave you a good start... it's up to you how to use it...
i've swiched to flatfile database oO... works wonderfully! ;D
|
|
|
07/15/2011, 01:38
|
#27
|
elite*gold: 0
Join Date: Aug 2010
Posts: 343
Received Thanks: 21
|
is it in the Thread.cs?
|
|
|
07/15/2011, 03:19
|
#28
|
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
|
Quote:
Originally Posted by koko20
i have error Error 1 'Conquer_Online_Server.Database.DataHolder.Connect ionString' is inaccessible due to its protection level C:\Users\Administrator\Desktop\fixed\Source\cleanm ysql.cs 15 98 Conquer_Online_Server_x86
in public static void Kill()
{
string command = "SHOW processlist";
List<ulong> processes = new List<ulong>();
MySqlConnection conn = new MySqlConnection(Conquer_Online_Server.Database.Dat aHolder.ConnectionString);
MySqlCommand cmd = new MySqlCommand(command, conn);
MySqlDataReader reader = null;
|
It's not public.
|
|
|
07/15/2011, 10:00
|
#29
|
elite*gold: 0
Join Date: Aug 2010
Posts: 343
Received Thanks: 21
|
or can I call it the KillConnections.Kill(); every after reading and closing database aside from doing servermanagement?
|
|
|
07/15/2011, 11:30
|
#30
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
|
Quote:
Originally Posted by marlyandedsel
or can I call it the KillConnections.Kill(); every after reading and closing database aside from doing servermanagement?
|
It's much much more efficient to do it my way by making a new thread to handle it and other server tasks.
|
|
|
 |
|
Similar Threads
|
[Release] Neo305´s Easy WoW Server Handler 4.0.6a
04/26/2013 - WoW Private Server - 61 Replies
Neo305´s Easy WoW Server
http://img200.imageshack.us/img200/537/handlerr.p ng
Ich biete euch hier einen fertigen WoW Cataclysm 4.0.6a Server mit Handler.
Wie man ihn benutzt, steht in der README Datei.
|
[Release] Simple MsSql Handler
05/10/2011 - CO2 PServer Guides & Releases - 12 Replies
I'm going back to MySql because I like it better. Here's the sql handler I was using that works with Sql Express (When you install Visual Studio):
namespace 数据库
{
using System;
using System.Data.SqlClient;
public static class Connection
{
|
Dauer MySQl Error mit 2.4.3 Mangos Handler!
03/11/2011 - WoW Private Server - 1 Replies
so ich bin langsam am verzweifeln -_-
ich hab meine pts fertig, einzige prob was ich habe, jedesmal wenn ich meinen pc neustarte oder herunterfahre wieder hochfahre, starte ich meinen server und kriege dauernd "could not connect to mysql database" fehler ....
da ist ne datei "exemod.dll" sie enthält angeblich einen virus mir wurde gesagt das is ne fehlmeldung, sie wird öfters gelöscht, und glaube es liegt daran das ich server net starten kann, musste ihn immer neuinstallieren das ich ihn...
|
[Release] event handler / system message for 5165 source
05/01/2010 - CO2 PServer Guides & Releases - 10 Replies
i was partially made this and completed by pringle, i dont know if pringle is in here in this forum. but still credit to him.
Go to Program.cs and find:public static Random Rnd = new Random();
Above this add:public static DateTime SystemMsgTime = new DateTime();
scroll down and you found this static void ServerStuff_Execute()
{
try
{
if (World.BroadCastCount > 0 && DateTime.Now > World.LastBroadCast.AddMinutes(1))
{
|
All times are GMT +1. The time now is 16:01.
|
|