From 8031f8ec09df4f654c86a9c7bc498664f7b9d9dc Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 26 Aug 2010 00:08:53 +0100
Subject: Improve consistency of locking for SOG.m_parts in order to avoid race
conditions in linking and unlinking
---
OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs | 94 +++++++++++++++--------------
1 file changed, 48 insertions(+), 46 deletions(-)
(limited to 'OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs')
diff --git a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
index 7d017a6..4ce93e5 100644
--- a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
@@ -232,66 +232,68 @@ namespace OpenSim.Data.MSSQL
///
public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
{
- _Log.InfoFormat("[MSSQL]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Children.Count);
-
- using (SqlConnection conn = new SqlConnection(m_connectionString))
+ lock (obj.Children)
{
- conn.Open();
- SqlTransaction transaction = conn.BeginTransaction();
-
- try
+ _Log.DebugFormat("[MSSQL]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Children.Count);
+
+ using (SqlConnection conn = new SqlConnection(m_connectionString))
{
- foreach (SceneObjectPart sceneObjectPart in obj.Children.Values)
+ conn.Open();
+ SqlTransaction transaction = conn.BeginTransaction();
+
+ try
{
- //Update prim
- using (SqlCommand sqlCommand = conn.CreateCommand())
- {
- sqlCommand.Transaction = transaction;
- try
- {
- StoreSceneObjectPrim(sceneObjectPart, sqlCommand, obj.UUID, regionUUID);
- }
- catch (SqlException sqlEx)
- {
- _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrim SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber);
- throw;
- }
- }
-
- //Update primshapes
- using (SqlCommand sqlCommand = conn.CreateCommand())
+ foreach (SceneObjectPart sceneObjectPart in obj.Children.Values)
{
- sqlCommand.Transaction = transaction;
- try
+ //Update prim
+ using (SqlCommand sqlCommand = conn.CreateCommand())
{
- StoreSceneObjectPrimShapes(sceneObjectPart, sqlCommand, obj.UUID, regionUUID);
+ sqlCommand.Transaction = transaction;
+ try
+ {
+ StoreSceneObjectPrim(sceneObjectPart, sqlCommand, obj.UUID, regionUUID);
+ }
+ catch (SqlException sqlEx)
+ {
+ _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrim SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber);
+ throw;
+ }
}
- catch (SqlException sqlEx)
+
+ //Update primshapes
+ using (SqlCommand sqlCommand = conn.CreateCommand())
{
- _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrimShapes SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber);
- throw;
+ sqlCommand.Transaction = transaction;
+ try
+ {
+ StoreSceneObjectPrimShapes(sceneObjectPart, sqlCommand, obj.UUID, regionUUID);
+ }
+ catch (SqlException sqlEx)
+ {
+ _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrimShapes SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber);
+ throw;
+ }
}
}
+
+ transaction.Commit();
}
-
- transaction.Commit();
- }
- catch (Exception ex)
- {
- _Log.ErrorFormat("[REGION DB]: Store SceneObjectGroup error: {0}, Rolling back...", ex.Message);
- try
- {
- transaction.Rollback();
- }
- catch (Exception ex2)
+ catch (Exception ex)
{
- //Show error
- _Log.InfoFormat("[REGION DB]: Rollback of SceneObjectGroup store transaction failed with error: {0}", ex2.Message);
-
+ _Log.ErrorFormat("[REGION DB]: Store SceneObjectGroup error: {0}, Rolling back...", ex.Message);
+ try
+ {
+ transaction.Rollback();
+ }
+ catch (Exception ex2)
+ {
+ //Show error
+ _Log.InfoFormat("[REGION DB]: Rollback of SceneObjectGroup store transaction failed with error: {0}", ex2.Message);
+
+ }
}
}
}
-
}
///
--
cgit v1.1
From 692cf3c657aaa74645722491c997f23b4d6f8f76 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 26 Aug 2010 00:17:26 +0100
Subject: Remove parts locking from data classes since these are using a copy
of the scene object
---
OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs | 94 ++++++++++++++---------------
1 file changed, 45 insertions(+), 49 deletions(-)
(limited to 'OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs')
diff --git a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
index 4ce93e5..7ff8737 100644
--- a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs
@@ -89,7 +89,6 @@ namespace OpenSim.Data.MSSQL
Dictionary objects = new Dictionary();
SceneObjectGroup grp = null;
-
string sql = "SELECT *, " +
"sort = CASE WHEN prims.UUID = prims.SceneGroupID THEN 0 ELSE 1 END " +
"FROM prims " +
@@ -232,66 +231,63 @@ namespace OpenSim.Data.MSSQL
///
public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
{
- lock (obj.Children)
+ _Log.DebugFormat("[MSSQL]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Children.Count);
+
+ using (SqlConnection conn = new SqlConnection(m_connectionString))
{
- _Log.DebugFormat("[MSSQL]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Children.Count);
-
- using (SqlConnection conn = new SqlConnection(m_connectionString))
+ conn.Open();
+ SqlTransaction transaction = conn.BeginTransaction();
+
+ try
{
- conn.Open();
- SqlTransaction transaction = conn.BeginTransaction();
-
- try
+ foreach (SceneObjectPart sceneObjectPart in obj.Children.Values)
{
- foreach (SceneObjectPart sceneObjectPart in obj.Children.Values)
+ //Update prim
+ using (SqlCommand sqlCommand = conn.CreateCommand())
{
- //Update prim
- using (SqlCommand sqlCommand = conn.CreateCommand())
+ sqlCommand.Transaction = transaction;
+ try
{
- sqlCommand.Transaction = transaction;
- try
- {
- StoreSceneObjectPrim(sceneObjectPart, sqlCommand, obj.UUID, regionUUID);
- }
- catch (SqlException sqlEx)
- {
- _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrim SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber);
- throw;
- }
+ StoreSceneObjectPrim(sceneObjectPart, sqlCommand, obj.UUID, regionUUID);
}
-
- //Update primshapes
- using (SqlCommand sqlCommand = conn.CreateCommand())
+ catch (SqlException sqlEx)
{
- sqlCommand.Transaction = transaction;
- try
- {
- StoreSceneObjectPrimShapes(sceneObjectPart, sqlCommand, obj.UUID, regionUUID);
- }
- catch (SqlException sqlEx)
- {
- _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrimShapes SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber);
- throw;
- }
+ _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrim SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber);
+ throw;
}
}
-
- transaction.Commit();
- }
- catch (Exception ex)
- {
- _Log.ErrorFormat("[REGION DB]: Store SceneObjectGroup error: {0}, Rolling back...", ex.Message);
- try
- {
- transaction.Rollback();
- }
- catch (Exception ex2)
+
+ //Update primshapes
+ using (SqlCommand sqlCommand = conn.CreateCommand())
{
- //Show error
- _Log.InfoFormat("[REGION DB]: Rollback of SceneObjectGroup store transaction failed with error: {0}", ex2.Message);
-
+ sqlCommand.Transaction = transaction;
+ try
+ {
+ StoreSceneObjectPrimShapes(sceneObjectPart, sqlCommand, obj.UUID, regionUUID);
+ }
+ catch (SqlException sqlEx)
+ {
+ _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrimShapes SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber);
+ throw;
+ }
}
}
+
+ transaction.Commit();
+ }
+ catch (Exception ex)
+ {
+ _Log.ErrorFormat("[REGION DB]: Store SceneObjectGroup error: {0}, Rolling back...", ex.Message);
+ try
+ {
+ transaction.Rollback();
+ }
+ catch (Exception ex2)
+ {
+ //Show error
+ _Log.InfoFormat("[REGION DB]: Rollback of SceneObjectGroup store transaction failed with error: {0}", ex2.Message);
+
+ }
}
}
}
--
cgit v1.1