* Synchronize asset storage operations to mysql as well as reads
* This may help with asset server mysql problems, since both the previous osgrid failures occurred when both a read and write were attempted in the same secondThreadPoolClientBranch
parent
cd658ea845
commit
bde363b572
|
@ -76,6 +76,7 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
_dbConnection.Connection);
|
_dbConnection.Connection);
|
||||||
MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16);
|
MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16);
|
||||||
p.Value = assetID.GetBytes();
|
p.Value = assetID.GetBytes();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||||
|
@ -108,37 +109,40 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
|
|
||||||
public void CreateAsset(AssetBase asset)
|
public void CreateAsset(AssetBase asset)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd =
|
lock (_dbConnection)
|
||||||
new MySqlCommand(
|
{
|
||||||
"REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" +
|
MySqlCommand cmd =
|
||||||
"VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)",
|
new MySqlCommand(
|
||||||
_dbConnection.Connection);
|
"REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" +
|
||||||
|
"VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)",
|
||||||
|
_dbConnection.Connection);
|
||||||
|
|
||||||
// need to ensure we dispose
|
// need to ensure we dispose
|
||||||
try
|
try
|
||||||
{
|
|
||||||
using (cmd)
|
|
||||||
{
|
{
|
||||||
MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16);
|
using (cmd)
|
||||||
p.Value = asset.FullID.GetBytes();
|
{
|
||||||
cmd.Parameters.AddWithValue("?name", asset.Name);
|
MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16);
|
||||||
cmd.Parameters.AddWithValue("?description", asset.Description);
|
p.Value = asset.FullID.GetBytes();
|
||||||
cmd.Parameters.AddWithValue("?assetType", asset.Type);
|
cmd.Parameters.AddWithValue("?name", asset.Name);
|
||||||
cmd.Parameters.AddWithValue("?invType", asset.InvType);
|
cmd.Parameters.AddWithValue("?description", asset.Description);
|
||||||
cmd.Parameters.AddWithValue("?local", asset.Local);
|
cmd.Parameters.AddWithValue("?assetType", asset.Type);
|
||||||
cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
|
cmd.Parameters.AddWithValue("?invType", asset.InvType);
|
||||||
cmd.Parameters.AddWithValue("?data", asset.Data);
|
cmd.Parameters.AddWithValue("?local", asset.Local);
|
||||||
cmd.ExecuteNonQuery();
|
cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
|
||||||
cmd.Dispose();
|
cmd.Parameters.AddWithValue("?data", asset.Data);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
cmd.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
MainLog.Instance.Error(
|
||||||
|
"ASSETS",
|
||||||
|
"MySql failure creating asset {0} with name {1}" + Environment.NewLine + e.ToString()
|
||||||
|
+ Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name);
|
||||||
|
_dbConnection.Reconnect();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
MainLog.Instance.Error(
|
|
||||||
"ASSETS",
|
|
||||||
"MySql failure creating asset {0} with name {1}" + Environment.NewLine + e.ToString()
|
|
||||||
+ Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name);
|
|
||||||
_dbConnection.Reconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue