后超时异常异步命令和Task.WhenAny等待在StackExchange.Redis [英] Timeout exception after async commands and Task.WhenAny awaits in StackExchange.Redis

查看:725
本文介绍了后超时异常异步命令和Task.WhenAny等待在StackExchange.Redis的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了所谓的超时执行HGET公司:产品:设置,研究所:1,队列:8,曲= 0,QS = 8,QC = 0,WR = 0/0, = 79/1 超时异常。

I'm experiencing the so-called Timeout performing HGET company:product:settings, inst: 1, queue: 8, qu=0, qs=8, qc=0, wr=0/0, in=79/1 timeout exception.

这很奇怪,因为同样的Redis的实例,并在同一台机器上被存储的数据,但它会抛出该异常特定的应用程序。的更新事实上,同样的应用中,一行以上接收从Redis的数据。问题是与 HGET

It's strange because the same Redis instance and in the same machine is storing data, but it's a specific application which throws this exception. Update: In fact, the same application, one line above receives data from Redis. The issue is with HGET.

另外,我增加了对多路配置的超时时间为6秒,没有运气。

Also, I've increased timeouts on multiplexer configuration to 6 seconds with no luck.

另外,我检查了了IDatabase 实例具有 IsConnected 值。

In addition, I've checked that IDatabase instance has IsConnected with true value.

如何跨preT这些错误消息,什么是整个超时背后的问题?

How to interpret these error messages and what's the issue behind the whole timeout?

我已经成功地解决了该问题变的的一些code节得到了的数据库的(即 multiplexer.GetDatabase())。

I've successfully fixed the issue changing when some code section gets a database (i.e. multiplexer.GetDatabase()).

多路复用器的具有每的AppDomain实例在StackExchange.Redis文档中所述,控制元件的许多反转创建<$的许多实例C $ C>了IDatabase 在自己的code。也就是说,了IDatabase 实例不共享。

While multiplexer has an instance per AppDomain as described in StackExchange.Redis documentation, many inversion of control components are creating many instances of IDatabase in their own code. That is, IDatabase instance isn't shared.

实际code正在执行 ListRightPopLeftPush ,并在此之后,它实例化控制组件的反转读取组件instatiation中的哈希键。如果实例整个组件之前,做所谓的 ListRightPopLeftPush ,那么整个 HashGet 不会抛出超时异常

Actual code is performing a ListRightPopLeftPush, and after that, it's instantiating an inversion of control component which reads a hash key during component instatiation. If instantiate the whole component before doing the so-called ListRightPopLeftPush, then the whole HashGet won't throw the timeout exception.

好像即使 ListRightPopLeftPush 从其他执行了IDatabase 情况下,它会产生一些问题,在接下来了IDatabase 例如,当涉及到执行读操作。

It seems like even when ListRightPopLeftPush is executed from other IDatabase instance, it produces some kind of issue in the next IDatabase instance when it comes to perform read operations.

不管怎样,我的修订的不回答这个问题。我只是增加了更多的详细信息,让我们找到什么问题,自己的解决方案。

Anyway, my fix doesn't answer the question. I've just added more detailed info to let us find what's the issue and its own solution.

总之,上面的修复不会解决进一步读取访问Redis的。我得到的还呼吁同超时异常。而现在 paramater异常的消息说,找到 60/1

Anyway, the above "fix" won't fix further read accesses to Redis. I'm getting the same timeout exception in further calls. And now in paramater found in exception's message says 60/1.

推荐答案

根据一个<一个href="http://chat.stackoverflow.com/rooms/60377/discussion-between-matias-fidemraizer-and-marc-gravell">long在聊天,很多挖掘的讨论,它看起来像在一些不起眼的情景TPL被劫持当我们正在做这样的事情 .TrySetResult 专用阅读器线程(其中:我们经常做)。这将导致瞬间死锁,如果你做一个同步调用,因为它可能无法处理任何插槽的数据,如果它是忙等待任务完成(这将永远只能自行填写)。我们实际上有<一个href="http://stackoverflow.com/questions/22579206/how-can-i-$p$pvent-synchronous-continuations-on-a-task">$c$c到位的专为prevent这个的,但它看起来像真正的解决方法的部队​​的它发生在其他一些情况下。这......太可怕了。我会看看我能找到。但基本上,问题是,目前的中的一些有限的情况下 TaskCompletionSource.TrySetResult 是给电源TPL运行同步延续。这包括 Task.WhenAny

Based on a long discussion in chat, and a lot of digging, it looks like in some obscure scenarios the TPL is hijacking the dedicated reader thread when we are doing things like .TrySetResult (which: we do often). This causes an instant deadlock if you make a synchronous call, since it can't possibly process any socket data if it is busy waiting for a task to complete (which would only ever be completed by itself). We do actually have code in place specifically to prevent this, but it looks like the workaround actually forces it to happen in some other scenarios. Which... is horrible. I will see what I can find. But basically, the problem is that currently, in some limited scenarios, TaskCompletionSource.TrySetResult is giving power to the TPL to run synchronous continuations. This includes Task.WhenAny.

这篇关于后超时异常异步命令和Task.WhenAny等待在StackExchange.Redis的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆