From 6309fcc5b4b42102b5bb901dbbdf44846f5643f2 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 2 Nov 2009 11:19:55 -0800 Subject: Reverting the memory leak patch for MySQL. Problems have been reported with the grid server after running for several hours --- OpenSim/Data/Migration.cs | 79 +++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 41 deletions(-) (limited to 'OpenSim/Data/Migration.cs') diff --git a/OpenSim/Data/Migration.cs b/OpenSim/Data/Migration.cs index 7a99d4a..e51dc22 100644 --- a/OpenSim/Data/Migration.cs +++ b/OpenSim/Data/Migration.cs @@ -131,26 +131,25 @@ namespace OpenSim.Data m_log.InfoFormat("[MIGRATIONS] Upgrading {0} to latest revision.", _type); m_log.Info("[MIGRATIONS] NOTE: this may take a while, don't interupt this process!"); - using (DbCommand cmd = _conn.CreateCommand()) + DbCommand cmd = _conn.CreateCommand(); + foreach (KeyValuePair kvp in migrations) { - foreach (KeyValuePair kvp in migrations) - { - int newversion = kvp.Key; - cmd.CommandText = kvp.Value; - // we need to up the command timeout to infinite as we might be doing long migrations. - cmd.CommandTimeout = 0; - cmd.ExecuteNonQuery(); + int newversion = kvp.Key; + cmd.CommandText = kvp.Value; + // we need to up the command timeout to infinite as we might be doing long migrations. + cmd.CommandTimeout = 0; + cmd.ExecuteNonQuery(); - if (version == 0) - { - InsertVersion(_type, newversion); - } - else - { - UpdateVersion(_type, newversion); - } - version = newversion; + if (version == 0) + { + InsertVersion(_type, newversion); } + else + { + UpdateVersion(_type, newversion); + } + version = newversion; + cmd.Dispose(); } } @@ -190,45 +189,43 @@ namespace OpenSim.Data protected virtual int FindVersion(DbConnection conn, string type) { int version = 0; - - using (DbCommand cmd = conn.CreateCommand()) + DbCommand cmd = conn.CreateCommand(); + try { - try + cmd.CommandText = "select version from migrations where name='" + type +"' order by version desc"; + using (IDataReader reader = cmd.ExecuteReader()) { - cmd.CommandText = "select version from migrations where name='" + type + "' order by version desc"; - using (IDataReader reader = cmd.ExecuteReader()) + if (reader.Read()) { - if (reader.Read()) - version = Convert.ToInt32(reader["version"]); + version = Convert.ToInt32(reader["version"]); } - } - catch - { - // Something went wrong, so we're version 0 + reader.Close(); } } - + catch + { + // Something went wrong, so we're version 0 + } + cmd.Dispose(); return version; } private void InsertVersion(string type, int version) { - using (DbCommand cmd = _conn.CreateCommand()) - { - cmd.CommandText = "insert into migrations(name, version) values('" + type + "', " + version + ")"; - m_log.InfoFormat("[MIGRATIONS]: Creating {0} at version {1}", type, version); - cmd.ExecuteNonQuery(); - } + DbCommand cmd = _conn.CreateCommand(); + cmd.CommandText = "insert into migrations(name, version) values('" + type + "', " + version + ")"; + m_log.InfoFormat("[MIGRATIONS]: Creating {0} at version {1}", type, version); + cmd.ExecuteNonQuery(); + cmd.Dispose(); } private void UpdateVersion(string type, int version) { - using (DbCommand cmd = _conn.CreateCommand()) - { - cmd.CommandText = "update migrations set version=" + version + " where name='" + type + "'"; - m_log.InfoFormat("[MIGRATIONS]: Updating {0} to version {1}", type, version); - cmd.ExecuteNonQuery(); - } + DbCommand cmd = _conn.CreateCommand(); + cmd.CommandText = "update migrations set version=" + version + " where name='" + type + "'"; + m_log.InfoFormat("[MIGRATIONS]: Updating {0} to version {1}", type, version); + cmd.ExecuteNonQuery(); + cmd.Dispose(); } // private SortedList GetAllMigrations() -- cgit v1.1