From 692cf3c657aaa74645722491c997f23b4d6f8f76 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 26 Aug 2010 00:17:26 +0100 Subject: [PATCH] Remove parts locking from data classes since these are using a copy of the scene object --- OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs | 104 +++++---- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 211 +++++++++--------- OpenSim/Data/SQLite/SQLiteRegionData.cs | 9 +- OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs | 9 +- 4 files changed, 160 insertions(+), 173 deletions(-) diff --git a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs index 4ce93e55c8..7ff87379b5 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,65 +231,62 @@ 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(); - + foreach (SceneObjectPart sceneObjectPart in obj.Children.Values) + { + //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()) + { + 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 { - foreach (SceneObjectPart sceneObjectPart in obj.Children.Values) - { - //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()) - { - 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.Rollback(); } - catch (Exception ex) + catch (Exception ex2) { - _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); - - } + //Show error + _Log.InfoFormat("[REGION DB]: Rollback of SceneObjectGroup store transaction failed with error: {0}", ex2.Message); + } } } diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index b756b4fe07..37d7a88a63 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -135,115 +135,112 @@ namespace OpenSim.Data.MySQL dbcon.Open(); MySqlCommand cmd = dbcon.CreateCommand(); - lock (obj.Children) + foreach (SceneObjectPart prim in obj.Children.Values) { - foreach (SceneObjectPart prim in obj.Children.Values) - { - cmd.Parameters.Clear(); - - cmd.CommandText = "replace into prims (" + - "UUID, CreationDate, " + - "Name, Text, Description, " + - "SitName, TouchName, ObjectFlags, " + - "OwnerMask, NextOwnerMask, GroupMask, " + - "EveryoneMask, BaseMask, PositionX, " + - "PositionY, PositionZ, GroupPositionX, " + - "GroupPositionY, GroupPositionZ, VelocityX, " + - "VelocityY, VelocityZ, AngularVelocityX, " + - "AngularVelocityY, AngularVelocityZ, " + - "AccelerationX, AccelerationY, " + - "AccelerationZ, RotationX, " + - "RotationY, RotationZ, " + - "RotationW, SitTargetOffsetX, " + - "SitTargetOffsetY, SitTargetOffsetZ, " + - "SitTargetOrientW, SitTargetOrientX, " + - "SitTargetOrientY, SitTargetOrientZ, " + - "RegionUUID, CreatorID, " + - "OwnerID, GroupID, " + - "LastOwnerID, SceneGroupID, " + - "PayPrice, PayButton1, " + - "PayButton2, PayButton3, " + - "PayButton4, LoopedSound, " + - "LoopedSoundGain, TextureAnimation, " + - "OmegaX, OmegaY, OmegaZ, " + - "CameraEyeOffsetX, CameraEyeOffsetY, " + - "CameraEyeOffsetZ, CameraAtOffsetX, " + - "CameraAtOffsetY, CameraAtOffsetZ, " + - "ForceMouselook, ScriptAccessPin, " + - "AllowedDrop, DieAtEdge, " + - "SalePrice, SaleType, " + - "ColorR, ColorG, ColorB, ColorA, " + - "ParticleSystem, ClickAction, Material, " + - "CollisionSound, CollisionSoundVolume, " + - "PassTouches, " + - "LinkNumber, MediaURL) values (" + "?UUID, " + - "?CreationDate, ?Name, ?Text, " + - "?Description, ?SitName, ?TouchName, " + - "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + - "?GroupMask, ?EveryoneMask, ?BaseMask, " + - "?PositionX, ?PositionY, ?PositionZ, " + - "?GroupPositionX, ?GroupPositionY, " + - "?GroupPositionZ, ?VelocityX, " + - "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + - "?AngularVelocityY, ?AngularVelocityZ, " + - "?AccelerationX, ?AccelerationY, " + - "?AccelerationZ, ?RotationX, " + - "?RotationY, ?RotationZ, " + - "?RotationW, ?SitTargetOffsetX, " + - "?SitTargetOffsetY, ?SitTargetOffsetZ, " + - "?SitTargetOrientW, ?SitTargetOrientX, " + - "?SitTargetOrientY, ?SitTargetOrientZ, " + - "?RegionUUID, ?CreatorID, ?OwnerID, " + - "?GroupID, ?LastOwnerID, ?SceneGroupID, " + - "?PayPrice, ?PayButton1, ?PayButton2, " + - "?PayButton3, ?PayButton4, ?LoopedSound, " + - "?LoopedSoundGain, ?TextureAnimation, " + - "?OmegaX, ?OmegaY, ?OmegaZ, " + - "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + - "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + - "?CameraAtOffsetY, ?CameraAtOffsetZ, " + - "?ForceMouselook, ?ScriptAccessPin, " + - "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + - "?SaleType, ?ColorR, ?ColorG, " + - "?ColorB, ?ColorA, ?ParticleSystem, " + - "?ClickAction, ?Material, ?CollisionSound, " + - "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; - - FillPrimCommand(cmd, prim, obj.UUID, regionUUID); - - ExecuteNonQuery(cmd); - - cmd.Parameters.Clear(); - - cmd.CommandText = "replace into primshapes (" + - "UUID, Shape, ScaleX, ScaleY, " + - "ScaleZ, PCode, PathBegin, PathEnd, " + - "PathScaleX, PathScaleY, PathShearX, " + - "PathShearY, PathSkew, PathCurve, " + - "PathRadiusOffset, PathRevolutions, " + - "PathTaperX, PathTaperY, PathTwist, " + - "PathTwistBegin, ProfileBegin, ProfileEnd, " + - "ProfileCurve, ProfileHollow, Texture, " + - "ExtraParams, State, Media) values (?UUID, " + - "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + - "?PCode, ?PathBegin, ?PathEnd, " + - "?PathScaleX, ?PathScaleY, " + - "?PathShearX, ?PathShearY, " + - "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + - "?PathRevolutions, ?PathTaperX, " + - "?PathTaperY, ?PathTwist, " + - "?PathTwistBegin, ?ProfileBegin, " + - "?ProfileEnd, ?ProfileCurve, " + - "?ProfileHollow, ?Texture, ?ExtraParams, " + - "?State, ?Media)"; - - FillShapeCommand(cmd, prim); - - ExecuteNonQuery(cmd); - } - - cmd.Dispose(); + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into prims (" + + "UUID, CreationDate, " + + "Name, Text, Description, " + + "SitName, TouchName, ObjectFlags, " + + "OwnerMask, NextOwnerMask, GroupMask, " + + "EveryoneMask, BaseMask, PositionX, " + + "PositionY, PositionZ, GroupPositionX, " + + "GroupPositionY, GroupPositionZ, VelocityX, " + + "VelocityY, VelocityZ, AngularVelocityX, " + + "AngularVelocityY, AngularVelocityZ, " + + "AccelerationX, AccelerationY, " + + "AccelerationZ, RotationX, " + + "RotationY, RotationZ, " + + "RotationW, SitTargetOffsetX, " + + "SitTargetOffsetY, SitTargetOffsetZ, " + + "SitTargetOrientW, SitTargetOrientX, " + + "SitTargetOrientY, SitTargetOrientZ, " + + "RegionUUID, CreatorID, " + + "OwnerID, GroupID, " + + "LastOwnerID, SceneGroupID, " + + "PayPrice, PayButton1, " + + "PayButton2, PayButton3, " + + "PayButton4, LoopedSound, " + + "LoopedSoundGain, TextureAnimation, " + + "OmegaX, OmegaY, OmegaZ, " + + "CameraEyeOffsetX, CameraEyeOffsetY, " + + "CameraEyeOffsetZ, CameraAtOffsetX, " + + "CameraAtOffsetY, CameraAtOffsetZ, " + + "ForceMouselook, ScriptAccessPin, " + + "AllowedDrop, DieAtEdge, " + + "SalePrice, SaleType, " + + "ColorR, ColorG, ColorB, ColorA, " + + "ParticleSystem, ClickAction, Material, " + + "CollisionSound, CollisionSoundVolume, " + + "PassTouches, " + + "LinkNumber, MediaURL) values (" + "?UUID, " + + "?CreationDate, ?Name, ?Text, " + + "?Description, ?SitName, ?TouchName, " + + "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + + "?GroupMask, ?EveryoneMask, ?BaseMask, " + + "?PositionX, ?PositionY, ?PositionZ, " + + "?GroupPositionX, ?GroupPositionY, " + + "?GroupPositionZ, ?VelocityX, " + + "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + + "?AngularVelocityY, ?AngularVelocityZ, " + + "?AccelerationX, ?AccelerationY, " + + "?AccelerationZ, ?RotationX, " + + "?RotationY, ?RotationZ, " + + "?RotationW, ?SitTargetOffsetX, " + + "?SitTargetOffsetY, ?SitTargetOffsetZ, " + + "?SitTargetOrientW, ?SitTargetOrientX, " + + "?SitTargetOrientY, ?SitTargetOrientZ, " + + "?RegionUUID, ?CreatorID, ?OwnerID, " + + "?GroupID, ?LastOwnerID, ?SceneGroupID, " + + "?PayPrice, ?PayButton1, ?PayButton2, " + + "?PayButton3, ?PayButton4, ?LoopedSound, " + + "?LoopedSoundGain, ?TextureAnimation, " + + "?OmegaX, ?OmegaY, ?OmegaZ, " + + "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + + "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + + "?CameraAtOffsetY, ?CameraAtOffsetZ, " + + "?ForceMouselook, ?ScriptAccessPin, " + + "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + + "?SaleType, ?ColorR, ?ColorG, " + + "?ColorB, ?ColorA, ?ParticleSystem, " + + "?ClickAction, ?Material, ?CollisionSound, " + + "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; + + FillPrimCommand(cmd, prim, obj.UUID, regionUUID); + + ExecuteNonQuery(cmd); + + cmd.Parameters.Clear(); + + cmd.CommandText = "replace into primshapes (" + + "UUID, Shape, ScaleX, ScaleY, " + + "ScaleZ, PCode, PathBegin, PathEnd, " + + "PathScaleX, PathScaleY, PathShearX, " + + "PathShearY, PathSkew, PathCurve, " + + "PathRadiusOffset, PathRevolutions, " + + "PathTaperX, PathTaperY, PathTwist, " + + "PathTwistBegin, ProfileBegin, ProfileEnd, " + + "ProfileCurve, ProfileHollow, Texture, " + + "ExtraParams, State, Media) values (?UUID, " + + "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + + "?PCode, ?PathBegin, ?PathEnd, " + + "?PathScaleX, ?PathScaleY, " + + "?PathShearX, ?PathShearY, " + + "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + + "?PathRevolutions, ?PathTaperX, " + + "?PathTaperY, ?PathTwist, " + + "?PathTwistBegin, ?ProfileBegin, " + + "?ProfileEnd, ?ProfileCurve, " + + "?ProfileHollow, ?Texture, ?ExtraParams, " + + "?State, ?Media)"; + + FillShapeCommand(cmd, prim); + + ExecuteNonQuery(cmd); } + + cmd.Dispose(); } } } diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index bfd8279f7b..4208050ab9 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs @@ -360,13 +360,10 @@ namespace OpenSim.Data.SQLite lock (ds) { - lock (obj.Children) + foreach (SceneObjectPart prim in obj.Children.Values) { - foreach (SceneObjectPart prim in obj.Children.Values) - { - // m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); - addPrim(prim, obj.UUID, regionUUID); - } +// m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); + addPrim(prim, obj.UUID, regionUUID); } } diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs index 779b2ed331..289fd948ce 100644 --- a/OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs @@ -327,13 +327,10 @@ namespace OpenSim.Data.SQLiteLegacy lock (ds) { - lock (obj.Children) + foreach (SceneObjectPart prim in obj.Children.Values) { - foreach (SceneObjectPart prim in obj.Children.Values) - { - // m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); - addPrim(prim, obj.UUID, regionUUID); - } +// m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID); + addPrim(prim, obj.UUID, regionUUID); } }