簡體   English   中英

StackExchange TimeoutException試圖在redis中插入2個集合中的750個項目

[英]StackExchange TimeoutException when trying to insert 750 items in 2 sets in redis

最初我試圖將一些項目集合插入到2個redis集中 (也許這根本不是好主意,但是......)。 我想要一次添加的條目數量750+

現在我在嘗試使用StackExchange.redis客戶端執行此操作時收到超時異常 ,有趣的是我能夠使用之前調查過的“遺留”書架客戶端完成類似的操作

所以,我在某些方面肯定是錯的(甚至可能在我的初始bookSleeve實現中),只是想弄清楚到底出了什么問題。 下面是我與redis客戶端一起使用的代碼示例: 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執行相同的代碼:

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)
{
    ...
}

在我開始單元測試后,我收到StackExchange客戶端的下一個錯誤:

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

只是想知道,究竟我做錯了什么。 提前感謝您的任何建議!

PS對於stackEchange.redis配置我正在使用Marc從github提供的配置示例(此處可用:StackExchange / StackExchange.Redis / blob / master / Docs / Configuration.md)

PS請查看當前的StackExchange客戶端配置文件:

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"
};

標准條目(在集合中使用)看起來像:

{
    "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"
}

PS在Marc的回應之后,我進行了幾次測試,並在單元測試中遇到了一些其他錯誤

{"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. 

所以我同意這是Connection問題,與當前切換到StackExchange.redis客戶端無關。

以下傳遞正常,並在本地報告10毫秒。 如果你能填補空白,我會非常感興趣,所以我可以做一個代表性的測試來重現這個問題。 請注意, qu=0, qs=3告訴我,當它超時時,我們正在等待redis服務器響應。 顯然,本地帶寬和延遲會引起人們的興趣,但從根本上說, 它應該可行 我也對你的sync-timeout設置的內容感興趣。

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);                
            }
        }
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM