Remove some use of database connection locking from MySQLSimulationData - this has not been necessary for some time as database connections are not shared.

However, many locks remain since they may effectively be providing transactionality in some operations (e.g. prim updates across multiple tables).
These are candidates for being replaced with proper database transactions, since this would not block unrelated operations (e.g. land save and object save)
or unrelated operations on the same tables (e.g. storage of one linkset whilst another is being removed).
In practice, any performance deg due to contention is probably rare and short lived as the major prim operations are performed in memory and only persisted some time afterwards.
0.8-extended
Justin Clark-Casey (justincc) 2014-08-22 20:23:48 +01:00 committed by Justin Clark-Casey
parent 8dd6830efb
commit 3438985b0d
1 changed files with 296 additions and 316 deletions

View File

@ -51,6 +51,15 @@ namespace OpenSim.Data.MySQL
private static string LogHeader = "[REGION DB MYSQL]"; private static string LogHeader = "[REGION DB MYSQL]";
private string m_connectionString; private string m_connectionString;
/// <summary>
/// This lock was being used to serialize database operations when the connection was shared, but this has
/// been unnecessary for a long time after we switched to using MySQL's underlying connection pooling instead.
/// FIXME: However, the locks remain in many places since they are effectively providing a level of
/// transactionality. This should be replaced by more efficient database transactions which would not require
/// unrelated operations to block each other or unrelated operations on the same tables from blocking each
/// other.
/// </summary>
private object m_dbLock = new object(); private object m_dbLock = new object();
protected virtual Assembly Assembly protected virtual Assembly Assembly
@ -738,8 +747,6 @@ namespace OpenSim.Data.MySQL
RegionLightShareData nWP = new RegionLightShareData(); RegionLightShareData nWP = new RegionLightShareData();
nWP.OnSave += StoreRegionWindlightSettings; nWP.OnSave += StoreRegionWindlightSettings;
lock (m_dbLock)
{
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
dbcon.Open(); dbcon.Open();
@ -829,7 +836,6 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
}
return nWP; return nWP;
} }
@ -875,8 +881,6 @@ namespace OpenSim.Data.MySQL
} }
public void StoreRegionWindlightSettings(RegionLightShareData wl) public void StoreRegionWindlightSettings(RegionLightShareData wl)
{
lock (m_dbLock)
{ {
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
@ -978,11 +982,8 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
}
public void RemoveRegionWindlightSettings(UUID regionID) public void RemoveRegionWindlightSettings(UUID regionID)
{
lock (m_dbLock)
{ {
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
@ -996,12 +997,9 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
}
#region RegionEnvironmentSettings #region RegionEnvironmentSettings
public string LoadRegionEnvironmentSettings(UUID regionUUID) public string LoadRegionEnvironmentSettings(UUID regionUUID)
{
lock (m_dbLock)
{ {
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
@ -1027,11 +1025,8 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
}
public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
{
lock (m_dbLock)
{ {
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
@ -1048,11 +1043,8 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
}
public void RemoveRegionEnvironmentSettings(UUID regionUUID) public void RemoveRegionEnvironmentSettings(UUID regionUUID)
{
lock (m_dbLock)
{ {
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
@ -1066,12 +1058,9 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
}
#endregion #endregion
public void StoreRegionSettings(RegionSettings rs) public void StoreRegionSettings(RegionSettings rs)
{
lock (m_dbLock)
{ {
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
@ -1121,7 +1110,7 @@ namespace OpenSim.Data.MySQL
ExecuteNonQuery(cmd); ExecuteNonQuery(cmd);
} }
} }
}
SaveSpawnPoints(rs); SaveSpawnPoints(rs);
} }
@ -2042,8 +2031,6 @@ namespace OpenSim.Data.MySQL
} }
public void SaveExtra(UUID regionID, string name, string val) public void SaveExtra(UUID regionID, string name, string val)
{
lock (m_dbLock)
{ {
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
@ -2060,11 +2047,8 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
}
public void RemoveExtra(UUID regionID, string name) public void RemoveExtra(UUID regionID, string name)
{
lock (m_dbLock)
{ {
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
@ -2080,14 +2064,11 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
}
public Dictionary<string, string> GetExtra(UUID regionID) public Dictionary<string, string> GetExtra(UUID regionID)
{ {
Dictionary<string, string> ret = new Dictionary<string, string>(); Dictionary<string, string> ret = new Dictionary<string, string>();
lock (m_dbLock)
{
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
dbcon.Open(); dbcon.Open();
@ -2105,7 +2086,6 @@ namespace OpenSim.Data.MySQL
} }
} }
} }
}
return ret; return ret;
} }