Pregunta

Initially I'm trying to insert some collection of items into 2 redis sets (maybe this is not good idea at all, but ...). amount of entries that I'm trying to add at once: 750+

For now I do receive timeout exception when trying to perform this action using StackExchange.redis client, the interesting thing that I'm able to complete similar action using "legacy" booksleeve client I've investigated previously.

So, I definitely wrong in something (even maybe in my intial bookSleeve implementation), just trying to figure out what exactly is wrong. Below is sample of the code that I use with redis clients: BookSleeve:

using (var tran = connection.CreateTransaction())
{
Task lastOpTask = null;
tran.SuspendFlush();
try
{
    // perform required configurations/ actions
    tran.Sets.Add(_redisConfiguration.DbNumber, CurrentIdsSetDbKey, stringIds);
    tran.Sets.Add(_redisConfiguration.DbNumber, CurrentDetailsSetDbKey, stringDetails);
    lastOpTask = tran.Execute();
    isOperationSuccessful = true;
}
catch (TaskCanceledException ex)
{
    ...
}
catch (TimeoutException ex1)
{
    ...
}
finally
{
    tran.ResumeFlush();
}

if (lastOpTask != null)
{
    connection.Wait(lastOpTask);
    ...
}
}

StackExchange.redis implementation of the same code:

var tran = db.CreateTransaction();

// todo: do we need to add here any condition or PipeLining? any watch/unwatch verifications?
tran.SetAddAsync(CurrentIdsSetDbKey, stringIds);
tran.SetAddAsync(CurrentDetailsSetDbKey, stringDetails);

try
{
    isOperationSuccessful = tran.Execute();
}
catch (TaskCanceledException ex)
{
    ...
}
catch (TimeoutException ex1)
{
    ...
}

After I start unit tests I receive next error for StackExchange client:

Message: Timeout performing EXEC, inst: 3, queue: 3, qu=0, qs=3, qc=0, wr=0/0

Source: in StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor1 processor, ServerEndPoint server) in c:\TeamCity\buildAgent\work\18a91a3757cef937\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:line 1693 in StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor1 processor, ServerEndPoint server) in c:\TeamCity\buildAgent\work\18a91a3757cef937\StackExchange.Redis\StackExchange\Redis\RedisBase.cs:line 92 in StackExchange.Redis.RedisTransaction.Execute(CommandFlags flags) in c:\TeamCity\buildAgent\work\18a91a3757cef937\StackExchange.Redis\StackExchange\Redis\RedisTransaction.cs:line 51 in DFS.Cache.CacheManager.RedisStackExchange.RedisContestCacheManager.RegisterAvailableContests(IList1 contests) in d:\Projects\DFS\Code\DFS\DFS.Cache.CacheManager.RedisStackExchange\RedisContestCacheManager.cs:line 131

Just wondering, what exactly I'm doing wrong. Thank you in advance for any suggestions!.

P.S. For stackEchange.redis configuration I'm using config sample provided by Marc from github (available here: StackExchange/StackExchange.Redis/blob/master/Docs/Configuration.md)

P.S. Please see current StackExchange client Config file:

var config = new ConfigurationOptions
{
    EndPoints =
        {
            {"MasterIP", 6379},
            {"SlaveIP", 6380}
        },
    CommandMap = CommandMap.Create(new HashSet<string>
        {
            // EXCLUDE a few commands (to work with data-flow-related mode only)
            "INFO",
            "CONFIG",
            "CLUSTER",
            "PING",
            "ECHO",
            "CLIENT"
        }, available: false),
    KeepAlive = 60, // 60 sec to ensure connection is alive
    ConnectTimeout = 5000, // 5 sec
    SyncTimeout = 5000, // 5 sec
    ServiceName = "mymaster", // sentinel service name
    DefaultVersion = new Version(2, 8, 8),
    Password = "password"
};

Standard entry (used in sets) looks like:

{
    "Id":"08e5ffdbced046cb8f55c50e4bab822d",
    "Entries":0,
    "State":"i",
    "Name":"very dummy entry name value: autoGet 299",
    "Summary": "entry summary details, some long string 299, some common info, some data: true, 8200"
    "IsMultiple":true,
    "IsPublic":true,
    "MaxEntries":8200,
    "IsEntryVisible":true,
    "StartDate":"9/10/2014 12:00:00 AM"
}

P.S. After Marc's response I ran couple of tests and got some other errors in Unit tests, for example

{"Timeout performing SISMEMBER set:raw:Ids, inst: 1, queue: 6, qu=0, qs=6, qc=0, wr=0/0"} when set contains not more than 300 items. 

So I agree that this is Connection issue and has nothing to do with current switch to the StackExchange.redis client.

¿Fue útil?

Solución

The following passes just fine, and reports 10ms locally. I would be very interested if you could fill in the blanks a bit so I can do a representative test that reproduces the issue. Note that qu=0, qs=3 tells me that at the point that it times out, we're waiting for the redis server to respond. Obviously local bandwidth and latency would be of interest, but fundamentally, it should work. I'd also be interested in what your sync-timeout is set to.

using System.Diagnostics;
using System.Linq;
using NUnit.Framework;

namespace StackExchange.Redis.Tests.Issues
{
    [TestFixture]
    public class SO22786599 : TestBase
    {
        [Test]
        public void Execute()
        {
            string CurrentIdsSetDbKey = Me() + ".x";
            string CurrentDetailsSetDbKey = Me() + ".y";

            RedisValue[] stringIds = Enumerable.Range(1, 750).Select(i => (RedisValue)(i + " id")).ToArray();
            RedisValue[] stringDetails = Enumerable.Range(1, 750).Select(i => (RedisValue)(i + " detail")).ToArray();

            using (var conn = Create())
            {
                var db = conn.GetDatabase();
                var tran = db.CreateTransaction();

                tran.SetAddAsync(CurrentIdsSetDbKey, stringIds);
                tran.SetAddAsync(CurrentDetailsSetDbKey, stringDetails);

                var watch = Stopwatch.StartNew();
                var isOperationSuccessful = tran.Execute();
                watch.Stop();
                System.Console.WriteLine("{0}ms", watch.ElapsedMilliseconds);
                Assert.IsTrue(isOperationSuccessful);                
            }
        }
    }
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top