gloebit / opensim-moneymodule-gloebit

OpenSim addon module integrating with the Gloebit digital currency service
GNU Lesser General Public License v3.0
8 stars 12 forks source link

Graceful handling of connection issues #86

Open Tampa opened 4 years ago

Tampa commented 4 years ago

It seems when there is a failure to connect to the Gloebit database that failure is not handled gracefully and causes termination of the process, something that modules should try to avoid if possible.

Stacktrace: Exception: MySql.Data.MySqlClient.MySqlException (0x80004005): Reading from the stream has failed. ---> System.IO.IOException: Unable to read data from the transport connection: Operation on non-blocking socket would block. ---> System.Net.Sockets.SocketException: Operation on non-blocking socket would block at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) [0x00016] in <4bf78e13a6ea4494a3898e6a836a77f4>:0 at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x00065] in <4bf78e13a6ea4494a3898e6a836a77f4>:0

Ideally this would not cause a full termination rather just a delayed retry or disabling the module for the time being until the simulator is restarted. I will see if I can find the code and add some graceful handling, but you know it better so please have a look also.

Tampa commented 4 years ago
Exception: MySql.Data.MySqlClient.MySqlException (0x80004005): Reading from the stream has failed. ---> System.IO.IOException: Unable to read data from the transport connection: Operation on non-blocking socket would block. ---> System.Net.Sockets.SocketException: Operation on non-blocking socket would block
  at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) [0x00016] in <4bf78e13a6ea4494a3898e6a836a77f4>:0 
  at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x00065] in <4bf78e13a6ea4494a3898e6a836a77f4>:0 
   --- End of inner exception stack trace ---
  at MySql.Data.Common.MyNetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00052] in <0004ab8b375b422f9000ac25a68089d9>:0 
  at MySql.Data.MySqlClient.TimedStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00026] in <0004ab8b375b422f9000ac25a68089d9>:0 
  at System.IO.BufferedStream.Read (System.Byte[] array, System.Int32 offset, System.Int32 count) <0x7f0db02a4010 + 0x00126> in <a1ae6166591d4020b810288d19af38d4>:0 
  at MySql.Data.MySqlClient.MySqlStream.ReadFully (System.IO.Stream stream, System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00006] in <0004ab8b375b422f9000ac25a68089d9>:0 
  at MySql.Data.MySqlClient.MySqlStream.LoadPacket () [0x0000e] in <0004ab8b375b422f9000ac25a68089d9>:0 
  at MySql.Data.MySqlClient.MySqlStream.LoadPacket () [0x000a5] in <0004ab8b375b422f9000ac25a68089d9>:0 
  at MySql.Data.MySqlClient.MySqlStream.ReadPacket () [0x00000] in <0004ab8b375b422f9000ac25a68089d9>:0 
  at MySql.Data.MySqlClient.NativeDriver.Open () [0x00094] in <0004ab8b375b422f9000ac25a68089d9>:0 
  at MySql.Data.MySqlClient.Driver.Open () [0x0000b] in <0004ab8b375b422f9000ac25a68089d9>:0 
  at MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) [0x0004e] in <0004ab8b375b422f9000ac25a68089d9>:0 
  at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection () [0x00000] in <0004ab8b375b422f9000ac25a68089d9>:0 
  at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection () [0x0008a] in <0004ab8b375b422f9000ac25a68089d9>:0 
  at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver () [0x0003f] in <0004ab8b375b422f9000ac25a68089d9>:0 
  at MySql.Data.MySqlClient.MySqlPool.GetConnection () [0x0001c] in <0004ab8b375b422f9000ac25a68089d9>:0 
  at MySql.Data.MySqlClient.MySqlConnection.Open () [0x0016d] in <0004ab8b375b422f9000ac25a68089d9>:0 
  at OpenSim.Data.MySQL.MySQLGenericTableHandler`1[T].DoQuery (MySql.Data.MySqlClient.MySqlCommand cmd) [0x0001c] in <7b939838379b41f193264c7d8a4d0f42>:0 
  at OpenSim.Data.MySQL.MySQLGenericTableHandler`1[T].Get (System.String[] fields, System.String[] keys, System.String options) [0x000be] in <7b939838379b41f193264c7d8a4d0f42>:0 
  at OpenSim.Data.MySQL.MySQLGenericTableHandler`1[T].Get (System.String[] fields, System.String[] keys) [0x00001] in <7b939838379b41f193264c7d8a4d0f42>:0 
  at Gloebit.GloebitMoneyModule.GloebitUser.Get (System.String appKeyStr, System.String agentIdStr) [0x0008b] in <ef957e929695440a88307ef2c18fd9f2>:0 
  at Gloebit.GloebitMoneyModule.GloebitUser.Get (System.String appKeyStr, OpenMetaverse.UUID agentID) [0x0000f] in <ef957e929695440a88307ef2c18fd9f2>:0 
  at Gloebit.GloebitMoneyModule.GloebitUser.IsNewSession (OpenMetaverse.UUID newSessionID) [0x00081] in <ef957e929695440a88307ef2c18fd9f2>:0 
  at Gloebit.GloebitMoneyModule.GloebitMoneyModule+<>c__DisplayClass116_0.<OnCompleteMovementToRegion>b__0 (System.Object <p0>) [0x000c5] in <ef957e929695440a88307ef2c18fd9f2>:0 
  at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) <0x7f0db00b6a60 + 0x00041> in <a1ae6166591d4020b810288d19af38d4>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) <0x7f0db00ae620 + 0x00147> in <a1ae6166591d4020b810288d19af38d4>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) <0x7f0db00ae5a0 + 0x00022> in <a1ae6166591d4020b810288d19af38d4>:0 
  at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () <0x7f0db00b69e0 + 0x00039> in <a1ae6166591d4020b810288d19af38d4>:0 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <a1ae6166591d4020b810288d19af38d4>:0 
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () <0x7f0db00b68e0 + 0x00012> in <a1ae6166591d4020b810288d19af38d4>:0 

InnerException: System.IO.IOException: Unable to read data from the transport connection: Operation on non-blocking socket would block. ---> System.Net.Sockets.SocketException: Operation on non-blocking socket would block
  at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) [0x00016] in <4bf78e13a6ea4494a3898e6a836a77f4>:0 
  at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x00065] in <4bf78e13a6ea4494a3898e6a836a77f4>:0 
   --- End of inner exception stack trace ---
  at MySql.Data.Common.MyNetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00052] in <0004ab8b375b422f9000ac25a68089d9>:0 
  at MySql.Data.MySqlClient.TimedStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00026] in <0004ab8b375b422f9000ac25a68089d9>:0 
  at System.IO.BufferedStream.Read (System.Byte[] array, System.Int32 offset, System.Int32 count) <0x7f0db02a4010 + 0x00126> in <a1ae6166591d4020b810288d19af38d4>:0 
  at MySql.Data.MySqlClient.MySqlStream.ReadFully (System.IO.Stream stream, System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00006] in <0004ab8b375b422f9000ac25a68089d9>:0 
  at MySql.Data.MySqlClient.MySqlStream.LoadPacket () [0x0000e] in <0004ab8b375b422f9000ac25a68089d9>:0 

Full stacktrace, it seems to be the Gloebit user get method. The connection to the database needs a few try catch to make sure connect failures don't terminate.