From e36a54ee2ab7b9e8f9c9170610a942c261eb270c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 5 Oct 2009 20:39:23 -0700 Subject: [PATCH 1/8] #if DEBBUG code for monitoring the ThreadPool. --- OpenSim/Region/Framework/Scenes/Scene.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 606135b516..35e57e5f34 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -962,6 +962,13 @@ namespace OpenSim.Region.Framework.Scenes int maintc = 0; while (!shuttingdown) { +#if DEBUG + int w = 0, io = 0, maxw=0, maxio=0; + ThreadPool.GetAvailableThreads(out w, out io); + ThreadPool.GetMaxThreads(out maxw, out maxio); + if ((maxw - w < 10) || (maxio - io < 10)) + m_log.DebugFormat("[WARNING]: ThreadPool reaching exhaustion. workers = {0}({1}); io = {2}({3})", w, io, maxw, maxio); +#endif maintc = Environment.TickCount; TimeSpan SinceLastFrame = DateTime.Now - m_lastupdate; From 0c46df973ad08381a7fcdb892e4525dfdb1d6ee4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 5 Oct 2009 21:02:10 -0700 Subject: [PATCH 2/8] Correction on the DEBUG code. --- OpenSim/Region/Framework/Scenes/Scene.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 35e57e5f34..d0dc02133f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -963,11 +963,10 @@ namespace OpenSim.Region.Framework.Scenes while (!shuttingdown) { #if DEBUG - int w = 0, io = 0, maxw=0, maxio=0; + int w = 0, io = 0; ThreadPool.GetAvailableThreads(out w, out io); - ThreadPool.GetMaxThreads(out maxw, out maxio); - if ((maxw - w < 10) || (maxio - io < 10)) - m_log.DebugFormat("[WARNING]: ThreadPool reaching exhaustion. workers = {0}({1}); io = {2}({3})", w, io, maxw, maxio); + if ((w < 10) || (io < 10)) + m_log.DebugFormat("[WARNING]: ThreadPool reaching exhaustion. workers = {0}; io = {1}", w, io); #endif maintc = Environment.TickCount; From 8a7a947faaeeaeac2f74f695cefd6eb3e774dc15 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 6 Oct 2009 14:30:25 +0100 Subject: [PATCH 3/8] Remove the using() constructs from the new style database modules; they caused the underlying connection of a reader or command to be closed before the reader or command itself. Added the proper logic to Close and dispose items in CloseDBConnection. Readers and Connections need Close(), Commands need Dispose(), in the order Reader, Command, Connection. Also reinstated 80-column-friendly formatting --- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 60 ++++++++-------- OpenSim/Data/MySQL/MySQLFramework.cs | 14 ++-- OpenSim/Data/MySQL/MySQLRegionData.cs | 2 +- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 72 +++++++++---------- 4 files changed, 75 insertions(+), 73 deletions(-) diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index a41f9f8f40..0780936d9c 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -55,42 +55,40 @@ namespace OpenSim.Data.MySQL AuthenticationData ret = new AuthenticationData(); ret.Data = new Dictionary(); - using (MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID")) + MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID"); + + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); + + IDataReader result = ExecuteReader(cmd); + + if (result.Read()) { - cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); + ret.PrincipalID = principalID; - using (IDataReader result = ExecuteReader(cmd)) + if (m_ColumnNames == null) { - if (result.Read()) - { - ret.PrincipalID = principalID; + m_ColumnNames = new List(); - if (m_ColumnNames == null) - { - m_ColumnNames = new List(); - - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); - } - - foreach (string s in m_ColumnNames) - { - if (s == "UUID") - continue; - - ret.Data[s] = result[s].ToString(); - } - - CloseDBConnection(cmd); - return ret; - } - else - { - CloseDBConnection(cmd); - return null; - } + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); } + + foreach (string s in m_ColumnNames) + { + if (s == "UUID") + continue; + + ret.Data[s] = result[s].ToString(); + } + + CloseDBConnection(result, cmd); + return ret; + } + else + { + CloseDBConnection(result, cmd); + return null; } } diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index f37e9bcb6c..ccd1ab0ed9 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs @@ -40,7 +40,9 @@ namespace OpenSim.Data.MySQL /// public class MySqlFramework { - private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly log4net.ILog m_log = + log4net.LogManager.GetLogger( + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); protected MySqlConnection m_Connection; @@ -81,7 +83,8 @@ namespace OpenSim.Data.MySQL errorSeen = true; m_Connection.Close(); - MySqlConnection newConnection = (MySqlConnection)((ICloneable)m_Connection).Clone(); + MySqlConnection newConnection = + (MySqlConnection)((ICloneable)m_Connection).Clone(); m_Connection.Dispose(); m_Connection = newConnection; m_Connection.Open(); @@ -102,15 +105,18 @@ namespace OpenSim.Data.MySQL protected IDataReader ExecuteReader(MySqlCommand cmd) { - MySqlConnection newConnection = (MySqlConnection)((ICloneable)m_Connection).Clone(); + MySqlConnection newConnection = + (MySqlConnection)((ICloneable)m_Connection).Clone(); newConnection.Open(); cmd.Connection = newConnection; return cmd.ExecuteReader(); } - protected void CloseDBConnection(MySqlCommand cmd) + protected void CloseDBConnection(IDataReader reader, MySqlCommand cmd) { + reader.Close(); + cmd.Connection.Close(); cmd.Connection.Dispose(); } } diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 3fe27d5702..3b561d14ed 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -173,7 +173,7 @@ namespace OpenSim.Data.MySQL retList.Add(ret); } - CloseDBConnection(cmd); + CloseDBConnection(result, cmd); } return retList; diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index 38a6f55ed3..0bbc3f5645 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -64,48 +64,46 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - using (MySqlCommand cmd = new MySqlCommand(command)) + MySqlCommand cmd = new MySqlCommand(command); + + cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + + IDataReader result = ExecuteReader(cmd); + + if (result.Read()) { - cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + ret.PrincipalID = principalID; + UUID scope; + UUID.TryParse(result["ScopeID"].ToString(), out scope); + ret.ScopeID = scope; - using (IDataReader result = ExecuteReader(cmd)) + if (m_ColumnNames == null) { - if (result.Read()) - { - ret.PrincipalID = principalID; - UUID scope; - UUID.TryParse(result["ScopeID"].ToString(), out scope); - ret.ScopeID = scope; + m_ColumnNames = new List(); - if (m_ColumnNames == null) - { - m_ColumnNames = new List(); - - DataTable schemaTable = result.GetSchemaTable(); - foreach (DataRow row in schemaTable.Rows) - m_ColumnNames.Add(row["ColumnName"].ToString()); - } - - foreach (string s in m_ColumnNames) - { - if (s == "UUID") - continue; - if (s == "ScopeID") - continue; - - ret.Data[s] = result[s].ToString(); - } - - CloseDBConnection(cmd); - return ret; - } - else - { - CloseDBConnection(cmd); - return null; - } + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); } + + foreach (string s in m_ColumnNames) + { + if (s == "UUID") + continue; + if (s == "ScopeID") + continue; + + ret.Data[s] = result[s].ToString(); + } + + CloseDBConnection(result, cmd); + return ret; + } + else + { + CloseDBConnection(result, cmd); + return null; } } From 2a060136bd89174a3071de9458c25af133c01b64 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 6 Oct 2009 15:28:38 +0100 Subject: [PATCH 4/8] Lock the heartbeat against multiple invocations. May prevent deadlocks and/or runaway thread use --- OpenSim/Region/Framework/Scenes/Scene.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d0dc02133f..c863c3baab 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -137,6 +137,8 @@ namespace OpenSim.Region.Framework.Scenes protected IAssetService m_AssetService = null; protected IAuthorizationService m_AuthorizationService = null; + private Object m_heartbeatLock = new Object(); + public IAssetService AssetService { get @@ -942,6 +944,9 @@ namespace OpenSim.Region.Framework.Scenes /// private void Heartbeat(object sender) { + if (!Monitor.TryEnter(m_heartbeatLock)) + return; + try { Update(); @@ -952,6 +957,11 @@ namespace OpenSim.Region.Framework.Scenes catch (ThreadAbortException) { } + finally + { + Monitor.Pulse(m_heartbeatLock); + Monitor.Exit(m_heartbeatLock); + } } /// From d4d060b57d380c9a19536bde79013b7634dbdf83 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 6 Oct 2009 07:49:05 -0700 Subject: [PATCH 5/8] Commenting the DEBUG code that I added yesterday, because it's causing mono to fail with https://bugzilla.novell.com/show_bug.cgi?id=538854 --- OpenSim/Region/Framework/Scenes/Scene.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d0dc02133f..df9b163c04 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -962,12 +962,12 @@ namespace OpenSim.Region.Framework.Scenes int maintc = 0; while (!shuttingdown) { -#if DEBUG - int w = 0, io = 0; - ThreadPool.GetAvailableThreads(out w, out io); - if ((w < 10) || (io < 10)) - m_log.DebugFormat("[WARNING]: ThreadPool reaching exhaustion. workers = {0}; io = {1}", w, io); -#endif +//#if DEBUG +// int w = 0, io = 0; +// ThreadPool.GetAvailableThreads(out w, out io); +// if ((w < 10) || (io < 10)) +// m_log.DebugFormat("[WARNING]: ThreadPool reaching exhaustion. workers = {0}; io = {1}", w, io); +//#endif maintc = Environment.TickCount; TimeSpan SinceLastFrame = DateTime.Now - m_lastupdate; From e474fc2fdbc424e64ce3a0f249b0d0afa44d86eb Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 6 Oct 2009 08:50:25 -0700 Subject: [PATCH 6/8] Corrected words in error message. --- OpenSim/Framework/Communications/RestClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index 7a735060fe..d98f47d80b 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs @@ -318,11 +318,11 @@ namespace OpenSim.Framework.Communications HttpWebResponse errorResponse = e.Response as HttpWebResponse; if (null != errorResponse && HttpStatusCode.NotFound == errorResponse.StatusCode) { - m_log.Warn("[ASSET] Asset not found (404)"); + m_log.Warn("[REST CLIENT] Resource not found (404)"); } else { - m_log.Error("[ASSET] Error fetching asset from asset server"); + m_log.Error("[REST CLIENT] Error fetching resource from server " + _request.Address.ToString()); m_log.Debug(e.ToString()); } From 3db4d38645260b0299e082b47b010dddf569bf31 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 6 Oct 2009 09:54:15 -0700 Subject: [PATCH 7/8] Removing dependencies on System.Runtime.Remoting. --- .../CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs | 4 ++++ prebuild.xml | 6 ------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs index 44e850bae3..6c89ac8c0d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs @@ -61,6 +61,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private void OnRegionUp(GridRegion otherRegion) { + // This shouldn't happen + if (otherRegion == null) + return; + m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}", m_scene.RegionInfo.RegionName, otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY); diff --git a/prebuild.xml b/prebuild.xml index f863ab64c6..e58b81b348 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -724,7 +724,6 @@ - @@ -805,7 +804,6 @@ - @@ -1539,7 +1537,6 @@ - @@ -1624,7 +1621,6 @@ - @@ -1682,7 +1678,6 @@ ../../../../bin/ - @@ -3590,7 +3585,6 @@ - From 77b4abaa251929a4d6079d766f041f997071dc46 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 6 Oct 2009 11:08:11 -0700 Subject: [PATCH 8/8] * Removed verbose debug message * Restored HG inventory access which had been lost upon adding a 3rd argument to inventory and asset server handlers * Fixed a stupid bug in the InventoryConnector which was making move items do things twice --- .../Asset/AssetServiceInConnectorModule.cs | 2 +- .../Inventory/InventoryServiceInConnectorModule.cs | 2 +- OpenSim/Server/Base/ServerUtils.cs | 2 +- .../Handlers/Inventory/InventoryServerInConnector.cs | 1 + .../Connectors/Inventory/InventoryServiceConnector.cs | 7 ------- 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs index bb9a4b2aca..879cc70903 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs @@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset m_log.Info("[RegionAssetService]: Starting..."); - Object[] args = new Object[] { m_Config, MainServer.Instance }; + Object[] args = new Object[] { m_Config, MainServer.Instance, string.Empty }; ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:AssetServiceConnector", args); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs index c326818443..54c6d89073 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs @@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory m_log.Info("[RegionInventoryService]: Starting..."); - Object[] args = new Object[] { m_Config, MainServer.Instance }; + Object[] args = new Object[] { m_Config, MainServer.Instance, String.Empty }; ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:InventoryServiceInConnector", args); } diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 9d9735e439..0964caaed7 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -260,7 +260,7 @@ namespace OpenSim.Server.Base public static Dictionary ParseXmlResponse(string data) { - m_log.DebugFormat("[XXX]: received xml string: {0}", data); + //m_log.DebugFormat("[XXX]: received xml string: {0}", data); Dictionary ret = new Dictionary(); diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs index ca452638ec..3c92209d80 100644 --- a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs @@ -77,6 +77,7 @@ namespace OpenSim.Server.Handlers.Inventory m_doLookup = serverConfig.GetBoolean("SessionAuthentication", false); AddHttpHandlers(server); + m_log.Debug("[INVENTORY HANDLER]: handlers initialized"); } protected virtual void AddHttpHandlers(IHttpServer m_httpServer) diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs index 5443891539..e047f71437 100644 --- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs @@ -416,13 +416,6 @@ namespace OpenSim.Services.Connectors e.Source, e.Message); } - foreach (InventoryItemBase item in items) - { - InventoryItemBase itm = this.QueryItem(userID, item, sessionID); - itm.Name = item.Name; - itm.Folder = item.Folder; - this.UpdateItem(userID, itm, sessionID); - } } private void MoveItemsCompleted(IAsyncResult iar)