RedisBoost
RedisBoost copied to clipboard
Deadlock under load with large values
We have tracked down an issue which caused a deadlock with RedisBoost. Our test suite runs several concurrent tests, and some of the hash items requested are in the 100k range. We found out that TryGet(out byte[] buffer) in BuffersPool.cs was returning false because MaxPoolSize had been reached. When it returns false, the calling function doesn't recover properly, and all current and future transactions fail.
We "fixed" it by eliminating the MaxPoolSize restriction (see below), but obviously this allows the buffer pools to grow unchecked. Without spending a lot more time understanding what it should do in this out of memory situation, we decided this was an acceptable trade-off. We wanted to post the issue to see if anyone knows what an actual fix would be (as well as to help others who may be seeing deadlock with large items).
private bool TryGet(out byte[] buffer)
{
buffer = _pool.GetOrCreate(() =>
{
int iPoolSize = Interlocked.Increment(ref _poolSize);
//if (iPoolSize > MaxPoolSize)
// return null;
return new byte[BufferSize];
}
);
return buffer != null;
}