diff options
author | Justin Clarke Casey | 2008-02-04 17:30:53 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-02-04 17:30:53 +0000 |
commit | bde363b57205c7e12d68ba71c254e6ffccd9210f (patch) | |
tree | 0b169a0f993b5492869f3cb1b2f76d19a717bb13 /OpenSim/Framework | |
parent | A smidgen more error info for the asset server (diff) | |
download | opensim-SC_OLD-bde363b57205c7e12d68ba71c254e6ffccd9210f.zip opensim-SC_OLD-bde363b57205c7e12d68ba71c254e6ffccd9210f.tar.gz opensim-SC_OLD-bde363b57205c7e12d68ba71c254e6ffccd9210f.tar.bz2 opensim-SC_OLD-bde363b57205c7e12d68ba71c254e6ffccd9210f.tar.xz |
* 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 second
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLAssetData.cs | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs index 567412f..407d6d2 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs | |||
@@ -76,6 +76,7 @@ namespace OpenSim.Framework.Data.MySQL | |||
76 | _dbConnection.Connection); | 76 | _dbConnection.Connection); |
77 | MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); | 77 | MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); |
78 | p.Value = assetID.GetBytes(); | 78 | p.Value = assetID.GetBytes(); |
79 | |||
79 | try | 80 | try |
80 | { | 81 | { |
81 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | 82 | using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) |
@@ -107,39 +108,42 @@ namespace OpenSim.Framework.Data.MySQL | |||
107 | } | 108 | } |
108 | 109 | ||
109 | public void CreateAsset(AssetBase asset) | 110 | public void CreateAsset(AssetBase asset) |
110 | { | 111 | { |
111 | MySqlCommand cmd = | 112 | lock (_dbConnection) |
112 | new MySqlCommand( | 113 | { |
113 | "REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" + | 114 | MySqlCommand cmd = |
114 | "VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)", | 115 | new MySqlCommand( |
115 | _dbConnection.Connection); | 116 | "REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" + |
116 | 117 | "VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)", | |
117 | // need to ensure we dispose | 118 | _dbConnection.Connection); |
118 | try | 119 | |
119 | { | 120 | // need to ensure we dispose |
120 | using (cmd) | 121 | try |
121 | { | 122 | { |
122 | MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); | 123 | using (cmd) |
123 | p.Value = asset.FullID.GetBytes(); | 124 | { |
124 | cmd.Parameters.AddWithValue("?name", asset.Name); | 125 | MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); |
125 | cmd.Parameters.AddWithValue("?description", asset.Description); | 126 | p.Value = asset.FullID.GetBytes(); |
126 | cmd.Parameters.AddWithValue("?assetType", asset.Type); | 127 | cmd.Parameters.AddWithValue("?name", asset.Name); |
127 | cmd.Parameters.AddWithValue("?invType", asset.InvType); | 128 | cmd.Parameters.AddWithValue("?description", asset.Description); |
128 | cmd.Parameters.AddWithValue("?local", asset.Local); | 129 | cmd.Parameters.AddWithValue("?assetType", asset.Type); |
129 | cmd.Parameters.AddWithValue("?temporary", asset.Temporary); | 130 | cmd.Parameters.AddWithValue("?invType", asset.InvType); |
130 | cmd.Parameters.AddWithValue("?data", asset.Data); | 131 | cmd.Parameters.AddWithValue("?local", asset.Local); |
131 | cmd.ExecuteNonQuery(); | 132 | cmd.Parameters.AddWithValue("?temporary", asset.Temporary); |
132 | cmd.Dispose(); | 133 | cmd.Parameters.AddWithValue("?data", asset.Data); |
134 | cmd.ExecuteNonQuery(); | ||
135 | cmd.Dispose(); | ||
136 | } | ||
133 | } | 137 | } |
138 | catch (Exception e) | ||
139 | { | ||
140 | MainLog.Instance.Error( | ||
141 | "ASSETS", | ||
142 | "MySql failure creating asset {0} with name {1}" + Environment.NewLine + e.ToString() | ||
143 | + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); | ||
144 | _dbConnection.Reconnect(); | ||
145 | } | ||
134 | } | 146 | } |
135 | catch (Exception e) | ||
136 | { | ||
137 | MainLog.Instance.Error( | ||
138 | "ASSETS", | ||
139 | "MySql failure creating asset {0} with name {1}" + Environment.NewLine + e.ToString() | ||
140 | + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); | ||
141 | _dbConnection.Reconnect(); | ||
142 | } | ||
143 | } | 147 | } |
144 | 148 | ||
145 | public void UpdateAsset(AssetBase asset) | 149 | public void UpdateAsset(AssetBase asset) |