ServiceStack/ServiceStack.Redis — Issue #32: RedisResponseException - 43QUEUED (New request)
Author: sachabarber
Created: 2012-02-21 14:53:44+00:00
State: open

I am pretty new to Redis and am kind of evaluating it. I am using Redis server from here : https://github.com/downloads/dmajkic/redis/redis-2.4.5-win32-win64.zip

I am also using the following config for the server:

# Accept connections on the specified port, default is 6379
port 6379

# Close the connection after a client is idle for N seconds (0 to disable)
timeout 300

# Save the DB on disk:
#
# save
#
# Will save the DB if both the given number of seconds and the given
# number of write operations against the DB occurred.
#
# In the example below the behaviour will be to save:
# after 900 sec (15 min) if at least 1 key changed
# after 300 sec (5 min) if at least 10 keys changed
# after 60 sec if at least 10000 keys changed
save 900 1
save 300 10
save 60 10000

# Set server verbosity to 'debug'
# it can be one of:
# debug (a lot of information, useful for development/testing)
# notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged)
loglevel debug

# Specify the log file name. Also 'stdout' can be used to force
# the demon to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
logfile stdout

# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT where
# dbid is a number between 0 and 'databases'-1
databases 1

################################### LIMITS ####################################

# Set the max number of connected clients at the same time. By default there
# is no limit, and it's up to the number of file descriptors the Redis process
# is able to open. The special value '0' means no limts.
# Once the limit is reached Redis will close all the new connections sending
# an error 'max number of clients reached'.

maxclients 32

# Don't use more memory than the specified amount of bytes.
# When the memory limit is reached Redis will try to remove keys with an
# EXPIRE set. It will try to start freeing keys that are going to expire
# in little time and preserve keys with a longer time to live.
# Redis will also try to remove objects from free lists if possible.
#
# If all this fails, Redis will start to reply with errors to commands
# that will use more memory, like SET, LPUSH, and so on, and will continue
# to reply to most read-only commands like GET.
#
# WARNING: maxmemory can be a good idea mainly if you want to use Redis as a
# 'state' server or cache, not as a real DB. When Redis is used as a real
# database the memory usage will grow over the weeks, it will be obvious if
# it is going to use too much memory in the long run, and you'll have the time
# to upgrade. With maxmemory after the limit is reached you'll start to get
# errors for write operations, and this may even lead to DB inconsistency.

maxmemory 2147483648

I am trying to run code like this use ServiceStack client (ServiceStack-ServiceStack.Redis-4add28a)

Here is my code

public void InsertInsideTransaction(bool shouldTransactionRollback)
{
RedisClient transClient = new RedisClient("localhost");

ClearAll();
using (var trans = transClient.CreateTransaction())
{
trans.QueueCommand(r =>
{
var redisUsers = r.GetTypedClient();
var sacha = new User { Id = redisUsers.GetNextSequence(), Name = "Sacha Barber" };
redisUsers.Store(sacha);
//redisUsers.Dispose();
});

//commit or rollback based on incoming flag
if (shouldTransactionRollback)
trans.Rollback();
else
trans.Commit();

IList users = Users();
Console.WriteLine(string.Format("InsertInsideTransaction : There are currently {0}, Users", users.Count()));
}

}

Where User looks like this (from one of the examples that comes with ServiceStack)

public class User
{
public User()
{
this.BlogIds = new List();
}

public long Id { get; set; }
public string Name { get; set; }
public List BlogIds { get; set; }
}

I get this Exception when I try and Commit the Transaction

Unknown reply on multi-request: 43QUEUED, sPort: 60793, LastCommand: EXEC

at ServiceStack.Redis.RedisNativeClient.CreateResponseError(String error) in C:\Users\barbers\Desktop\Downloads\ServiceStack-ServiceStack.Redis-4add28a\ServiceStack-ServiceStack.Redis-4add28a\src\ServiceStack.Redis\RedisNativeClient_Utils.cs:line 146
at ServiceStack.Redis.RedisNativeClient.ReadMultiDataResultCount() in C:\Users\barbers\Desktop\Downloads\ServiceStack-ServiceStack.Redis-4add28a\ServiceStack-ServiceStack.Redis-4add28a\src\ServiceStack.Redis\RedisNativeClient_Utils.cs:line 578
at ServiceStack.Redis.Pipeline.QueuedRedisOperation.ProcessResult() in C:\Users\barbers\Desktop\Downloads\ServiceStack-ServiceStack.Redis-4add28a\ServiceStack-ServiceStack.Redis-4add28a\src\ServiceStack.Redis\Pipeline\QueuedRedisOperation.cs:line 169
at ServiceStack.Redis.RedisTransaction.Commit() in C:\Users\barbers\Desktop\Downloads\ServiceStack-ServiceStack.Redis-4add28a\ServiceStack-ServiceStack.Redis-4add28a\src\ServiceStack.Redis\Transaction\RedisTransaction.cs:line 100
at DocumentDB.Redis.RedisMessAround.InsertInsideTransaction(Boolean shouldTransactionRollback) in C:\Users\barbers\Desktop\DocumentDBs\DocumentDB.Redis\RedisMessAround.cs:line 63
at DocumentDB.Redis.Program.Run() in C:\Users\barbers\Desktop\DocumentDBs\DocumentDB.Redis\Program.cs:line 45
at DocumentDB.Redis.Program.Main(String[] args) in C:\Users\barbers\Desktop\DocumentDBs\DocumentDB.Redis\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

I then thought Ok you guys have it working using Transactions in your unit tests, so I edited the "RedisTransactionTests" than came with the ServiceStack client (ServiceStack-ServiceStack.Redis-4add28a) I am using

Here is what I added to the "RedisTransactionTests"

public class User
{
public User()
{
this.BlogIds = new List();
}

public long Id { get; set; }
public string Name { get; set; }
public List BlogIds { get; set; }
}

[Test]
[TestCase(true)]
[TestCase(false)]
public void TestUserTrans(bool shouldTransactionRollback)
{
int count = 0;

IRedisTransaction trans = Redis.CreateTransaction();

try
{
trans.QueueCommand(r =>
{
var redisUsers = r.GetTypedClient();
var sacha = new User { Id = redisUsers.GetNextSequence(), Name = "Sacha Barber" };
redisUsers.Store(sacha);
});

//commit or rollback based on incoming flag
if (shouldTransactionRollback)
trans.Rollback();
else
trans.Commit();
}
catch (Exception ex)
{

}

IList users = Users();
count = users.Count();
Console.WriteLine(string.Format("TestUserTrans : There are currently {0}, Users", users.Count()));
if (shouldTransactionRollback)
Assert.That(count == 0);
else
Assert.That(count == 1);

}

In there the Exception seems to get completely swallowed.

What on earth am I doing wrong