0

While I was debugging my code using ServiceStack redis components - I noticed a bug that was causing my thread to stop responding halting in a io blocked mode.

The code I use is to store a value on a servicestack hash as in the code below. Here the default factory is a pooled redis client manager with send and receive thread counts of 20:

using (IRedisClient client = defaultFactory.GetClient())
{
    client.Hashes[cacheName][key] = SerializationHelper.Serialize(value, ST.Binary);
}

From my stack trace I see that the Write to hash actually calls a socket receive function - which is blocking the operation - how should I handle this situation in my code. In my receive codes I always put a timeout yet since this is a write operation there does not seem to be a timeout option.

My stacktrace is below:

[Managed to Native Transition]  
System.dll!System.Net.Sockets.Socket.Receive(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, out System.Net.Sockets.SocketError errorCode) + 0xbd bytes    
System.dll!System.Net.Sockets.Socket.Receive(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags) + 0x1d bytes  
System.dll!System.Net.Sockets.NetworkStream.Read(byte[] buffer, int offset, int size) + 0x83 bytes  
mscorlib.dll!System.IO.BufferedStream.ReadByte() + 0xa9 bytes   
ServiceStack.Redis.dll!ServiceStack.Redis.RedisNativeClient.SafeReadByte() + 0x25 bytes 
ServiceStack.Redis.dll!ServiceStack.Redis.RedisNativeClient.ReadLong() + 0x3b bytes 
ServiceStack.Redis.dll!ServiceStack.Redis.RedisNativeClient.SendExpectLong(byte[][] cmdWithBinaryArgs) + 0xa6 bytes 
ServiceStack.Redis.dll!ServiceStack.Redis.RedisNativeClient.HSet(string hashId, byte[] key, byte[] value) + 0xbd bytes  
ServiceStack.Redis.dll!ServiceStack.Redis.RedisClient.SetEntryInHash(string hashId, string key, string value) + 0x5d bytes  
ServiceStack.Redis.dll!ServiceStack.Redis.RedisClientHash.this[string].set(string key, string value) + 0x48 bytes   

The version of servicestack I am using is 4.0.9. Thank you in advance

user3141326
  • 1,423
  • 2
  • 21
  • 31
  • Does this happen intermittently or all the time? Have you looked into firewall issues? Apparently the socket doesn't get a reply after a request. It should have a timeout, I didn't look into ServiceStack, so I don't know at what interval it is set if you can't pass one. Redis-sentinel could also help you out here, possibly. – Tw Bert Mar 30 '14 at 20:03
  • It happens intermittently - not all the time - thus should not be a firewall issue. I will check about redis sentinel it looks like an interesting one. – user3141326 Mar 31 '14 at 05:54

0 Answers0