在{time}之后超时获取角色'{actorName}'的基于回合的并发锁 [英] Acquisition of turn based concurrency lock for actor '{actorName}' timed out after {time}

查看:117
本文介绍了在{time}之后超时获取角色'{actorName}'的基于回合的并发锁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我提供的服务可以通过某种名称来创建某种类型的Actor:

I have service which creates Actors of some type by some name:

var storer = this.serviceClient.Create<IStorer>(new ActorId(agencyToProcess.Name));

然后我调用Actor的方法。

and then I call Actor's method.

await storer.StoreStatusesAsync().ConfigureAwait(false);

在此通话中,我收到错误消息:

On this call I receive error :


System.AggregateException:发生一个或多个错误。 --->
Microsoft.ServiceFabric.Actors.ActorConcurrencyLockTimeoutException:
为演员 actorName获取基于回合的并发锁,在00:01:13.6480000之后将
超时。在
Microsoft.ServiceFabric.Actors.Runtime.ActorConcurrencyLock.d__17.MoveNext()

System.AggregateException: One or more errors occurred. ---> Microsoft.ServiceFabric.Actors.ActorConcurrencyLockTimeoutException: Acquisition of turn based concurrency lock for actor 'actorName' timed out after 00:01:13.6480000. at Microsoft.ServiceFabric.Actors.Runtime.ActorConcurrencyLock.d__17.MoveNext()

我不明白这是什么erorr的含义以及解决方法。

I can't understand what this erorr means and how to fix it.

这个问题并非每次都会发生。 (100次中有20次)。

This problem doesn't happen everytime. (20 times out of 100).

[ServiceDescription("Storer", ServicePrefix = "MyApp")]
public interface IStorer : IActor
{
    Task StoreStatusesAsync();
}






此服务创建于观察员有完整的代码可以在观察者中创建参与者。


This services are created in Observer. There are code full code which creates actors in observer.

public async void OnNext(AgencyModel agencyToProcess)
{
    try
    {
        var storer = this.serviceClient.Create<IStorer>(new ActorId(agencyToProcess.Name));

        await storer.StoreStatusesAsync().ConfigureAwait(false);
    }
    catch (Exception exception)
    {
        this.Logger.Error(exception);
    }
}


推荐答案

此发生这种情况是因为您的服务正在尝试调用当前锁定的Actor,从而正在处理另一个调用。

This happens because your service is trying to call an Actor that is currently locked processing another call.

根据您的代码外观,您是基于事件触发actor,如果两个针对同一演员的事件被连续调用,其中一个事件将等待前一个演员完成,如果前一个演员花费的时间太长,则超时将引发 ActorConcurrencyLockTimeoutException。

By the looks of you code, you are triggering actors based on events, if two events targeting the same actor get called consecutively, one of them will wait for the previous to finish, and if the previous takes too long to complete, a timeout will throw the 'ActorConcurrencyLockTimeoutException'.

这种情况通常不会发生,因为每个呼叫可能需要花费几秒钟或更短的时间来处理,但是当您有许多呼叫排队时,最新的呼叫将等待所有先前的呼叫按其各自的顺序处理,这将很快超时或

It does not happen often because each call might take a few seconds or less to process, but when you have many calls enqueued, the latest will wait for all previous to process in their respective order, and this will timeout soon or later.

要减少这些异常,您可以增加超时阈值,默认值为60秒,但我认为这不是一个好主意,因为它也可能会排队许多请求,可能无法处理所有他们,同时拥有资源和联系。重新平衡服务时,这些请求也可能丢失。

To reduce these exceptions you could increase the timeout threshold, The default is 60 seconds, but in my opinion this is not a good idea, as it might enqueue too many requests and possibly not be able to process all of them, while holding resources and connections. These requests may also get lost when services are re-balanced.

最好的解决方案是找到限制这些请求的方法。

The best solution is find an approach to throttle these requests.

这篇关于在{time}之后超时获取角色'{actorName}'的基于回合的并发锁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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