SDK 2.3.301升级后,Service Fabric Actor或Service在随机时间变得不可访问

14
从Service Fabric SDK 2.0.135升级到2.3.301后,我们开始遇到这样的情况:尽管在Service Fabric Explorer中显示为健康状况,但无法访问Service Fabric actor或service。一旦处于这种状态,通过ActorProxy或ServiceProxy调用actor或service的任何调用都会挂起5分钟,最终引发TimeoutException。一旦处于此状态,即使放置一个小时,actor或service也永远不会自动恢复——唯一的解决办法是重置actor或service所在的节点,重新部署actor或service(完全相同的EXE),重置整个群集或重新启动群集中的所有计算机。通常在部署或重新部署SF应用程序后会进入此状态。我们使用Service Fabric的最后一年(自SDK v1.3以来)从未出现过此问题,只有在移至2.3.301后才开始出现。它似乎是随机和不一致的。在我们的解决方案中,13个SF应用程序中受到影响的情况也是随机的。是否有人有任何想法,能帮助我们解决这个问题?它似乎是Service Fabric最新版本中的错误,但也许我们在我们的端口做错了什么。感谢任何帮助。

升级到2.3.301后,我们会周期性地遇到随机的Actor或Service进入一种状态,在从ServiceProxy或ActorProxy调用方法时无法响应调用。挂起5分钟后,我们收到System.Timeout异常,并显示以下消息:

如果服务繁忙或其长时间运行的操作花费的时间超过配置的操作超时时间,则可能会发生这种情况。

请注意,该服务并不忙,也没有执行任何长时间运行的操作。作为一个actor,该服务根本不执行任何正在进行的操作。它在第一次调用时就失败了。

事实上,跟踪显示,即使在actor的方法中,第一行永远没有被调用。就好像Service Fabric通信基础结构无法传递消息一样。

何时开始出现此问题

在过去的12个月中,我们从未见过这个问题。

自从上周升级Service Fabric以来,我们经常在各种条件下看到这个问题。

我们升级到Service Fabric SDK 2.3.301.9590和Service Fabric 5.3.301.9590。

最初,团队中的每个开发人员都单独遇到了这个问题,并且每个人都认为这只是我们机器上的暂时性问题。Service Fabric确实存在一些问题,所以我们接受了这个事实并继续前进。但后来我们开始相互抱怨,并意识到我们都看到了它。即使在即将投入生产的云环境中,我们的QAs也看到了它。

再次强调,这只是在我们上周升级到最新版本的Service Fabric后才开始的。

以前,我们正在运行Service Fabric SDK 2.0.135。

我们通过安装SDK v 2.3.301,打开我们的每个解决方案并允许Visual Studio进行升级来升级我们的代码库。

环境

我正在运行一个新安装的Windows 10 Enterprise(不到2周的时间内安装),使用带有16 GB RAM的i7。我有一个新的Visual Studio 2015 Update 3和SF 2.3.301.9590的安装包。我没有进行任何升级,全新安装了所有内容。

我的同事们的计算机(年龄,配置和“新鲜程度”各异)上也发生了这种情况。它会偶尔发生在我们每个人身上。

最重要的是,这也发生在我们在Azure上的Service Fabric VM上。这些是我们的QA大约一个月前使用Service Fabric VM模板在Azure上创建的计算机。它预先安装了5.3.301.9590。他没有手动安装任何更新到Service Fabric。我们基于SF的应用程序在Azure(或我们自己的开发机器)上没有遇到这个问题,直到开发人员升级到新版本。

这不是我的机器问题,也不仅限于开发环境。对于我们所有人来说,唯一的一致变化是SF版本的更新。

问题原因

我们不知道是什么原因导致的。

通常在部署新的SF应用程序后会立即发生。是的,我们等待通常需要2到3分钟的时间,让SF在部署后“自我调整”。我们让其保持了一个小时甚至更长时间,但它就是无法工作。

传闻中,我认为我曾经拥有一个正常工作然后突然停止工作的SF服务,但当时我们还没有意识到存在问题,所以我不能确定。

解决方法

一旦我们有一个处于“无法访问”状态的SF服务,Service Fabric就无法让其恢复正常状态。应用程序完全无法使用。我们使用以下方法,成功程度不同:

  • 重新部署无法访问的SF应用程序
  • 重新启动托管无法访问的SF服务和actors的节点(通过Service Fabric Explorer进入节点,单击省略号按钮,然后单击“重新启动”选项)
  • 重启整个SF集群(停止,然后再启动)
  • 重新启动运行SF节点的所有计算机
  • 重置整个群集并重新部署所有内容(最后的手段,但有时必要)

有趣的是,使用任务管理器终止有问题的进程并不能帮助。如果我终止有问题的进程,Service Fabric会重新启动它(如预期),但它仍然无法响应消息。

因此,问题似乎出在Service Fabric本身而不是EXE文件上。

当然,这些都不是“解决方案”,因为它们使我们的整个应用程序无法访问,直到SF可以重新启动/平衡。即使重启几个节点也会使许多东西离线。

基本上,这对我们来说是一个停机控制点。我们无法将我们的应用程序投入生产(甚至是beta测试)而SF表现出这种行为。

C#使用服务代理或Actor代理时引发异常的JSON呈现

"exception": {
    "ClassName": "System.TimeoutException",
    "Message": "This can happen if message is dropped when service is busy or its long running operation and taking more time than configured Operation Timeout.",
    "Data": null,
    "InnerException": null,
    "HelpURL": null,
    "StackTraceString": "   at Microsoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient`1.<InvokeWithRetryAsync>d__7`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.ServiceFabric.Services.Remoting.Client.ServiceRemotingPartitionClient.<InvokeAsync>d__8.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.ServiceFabric.Services.Remoting.Builder.ProxyBase.<InvokeAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.ServiceFabric.Services.Remoting.Builder.ProxyBase.<ContinueWithResult>d__7`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at RenderingCachingEngine.RenderingCachingEngine.<Render>d__10.MoveNext() in C:\\Code\\Ink\\Dev\\Current\\Source\\Rendering Service Fabric\\RenderingCachingEngine\\RenderingCachingEngine.cs:line 381",
    "RemoteStackTraceString": null,
    "RemoteStackIndex": 0,
    "ExceptionMethod": "8\nMoveNext\nMicrosoft.ServiceFabric.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\nMicrosoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient`1+<InvokeWithRetryAsync>d__7`1\nVoid MoveNext()",
    "HResult": -2146233083,
    "Source": "Microsoft.ServiceFabric.Services",
    "WatsonBuckets": null
  }

以下是服务布局信息的JSON呈现:

  "serviceFabricInfo": {
    "serviceFabricServiceName": "fabric:/Rendering/RenderingCachingEngine",
    "serviceFabricServiceTypeName": "RenderingCachingEngineType",
    "serviceFabricReplicaId": 131225099453058851,
    "serviceFabricPartitionId": "e400087d-8a08-4dab-bcdd-1f5ce82f374f",
    "serviceFabricApplicationName": "fabric:/Rendering",
    "serviceFabricApplicationTypeName": "RenderingType",
    "serviceFabricNodeName": "_Node_4"
  }

重新部署时的事件查看器日志

Windows事件查看器在“应用程序和服务日志-> Microsoft-Service Fabric-> Admin”下显示了一些值得注意的日志。

以下日志是在我重新部署我的应用程序的更新版本时发生的(请注意,DataBinding.exe是包含我的两个SF actor的EXE的名称):

Log Name:      Microsoft-ServiceFabric/Admin
Source:        Microsoft-ServiceFabric
Date:          11/2/2016 2:38:53 PM
Event ID:      256
Task Category: Common
Level:         Error
Keywords:      Default
User:          NETWORK SERVICE
Computer:      shayward10.ovx.local
Description:
WriteNode failed. HRESULT=-2147467259, Output=CustomOutput
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-ServiceFabric" Guid="{CBD93BC2-71E5-4566-B3A7-595D8EECA6E8}" />
    <EventID>256</EventID>
    <Version>0</Version>
    <Level>2</Level>
    <Task>1</Task>
    <Opcode>0</Opcode>
    <Keywords>0x8000000000000001</Keywords>
    <TimeCreated SystemTime="2016-11-02T18:38:53.678587200Z" />
    <EventRecordID>7620</EventRecordID>
    <Correlation />
    <Execution ProcessID="4440" ThreadID="7360" />
    <Channel>Microsoft-ServiceFabric/Admin</Channel>
    <Computer>shayward10.ovx.local</Computer>
    <Security UserID="S-1-5-20" />
  </System>
  <EventData>
    <Data Name="id">
    </Data>
    <Data Name="type">XmlLiteWriter</Data>
    <Data Name="text">WriteNode failed. HRESULT=-2147467259, Output=CustomOutput</Data>
  </EventData>
</Event>

Log Name:      Microsoft-ServiceFabric/Admin
Source:        Microsoft-ServiceFabric
Date:          11/2/2016 2:38:54 PM
Event ID:      23073
Task Category: Hosting
Level:         Warning
Keywords:      Default
User:          SYSTEM
Computer:      shayward10.ovx.local
Description:
ServiceHostProcess: DataBinding.exe for ApplicationId 805915c7-456c-49d3-af95-62cc44650664 terminated unexpectedly with exit code 3221225786 on node id bf865279ba277deb864a976fbf4c200e
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-ServiceFabric" Guid="{CBD93BC2-71E5-4566-B3A7-595D8EECA6E8}" />
    <EventID>23073</EventID>
    <Version>0</Version>
    <Level>3</Level>
    <Task>90</Task>
    <Opcode>0</Opcode>
    <Keywords>0x8000000000000001</Keywords>
    <TimeCreated SystemTime="2016-11-02T18:38:54.820567800Z" />
    <EventRecordID>7621</EventRecordID>
    <Correlation />
    <Execution ProcessID="6944" ThreadID="3812" />
    <Channel>Microsoft-ServiceFabric/Admin</Channel>
    <Computer>shayward10.ovx.local</Computer>
    <Security UserID="S-1-5-18" />
  </System>
  <EventData>
    <Data Name="id">bf865279ba277deb864a976fbf4c200e</Data>
    <Data Name="AppId">805915c7-456c-49d3-af95-62cc44650664</Data>
    <Data Name="ReturnCode">3221225786</Data>
    <Data Name="ProcessName">DataBinding.exe</Data>
  </EventData>
</Event>

Log Name:      Microsoft-ServiceFabric/Admin
Source:        Microsoft-ServiceFabric
Date:          11/2/2016 2:38:56 PM
Event ID:      256
Task Category: Common
Level:         Error
Keywords:      Default
User:          NETWORK SERVICE
Computer:      shayward10.ovx.local
Description:
WriteNode failed. HRESULT=-2147467259, Output=CustomOutput
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-ServiceFabric" Guid="{CBD93BC2-71E5-4566-B3A7-595D8EECA6E8}" />
    <EventID>256</EventID>
    <Version>0</Version>
    <Level>2</Level>
    <Task>1</Task>
    <Opcode>0</Opcode>
    <Keywords>0x8000000000000001</Keywords>
    <TimeCreated SystemTime="2016-11-02T18:38:56.261857600Z" />
    <EventRecordID>7627</EventRecordID>
    <Correlation />
    <Execution ProcessID="4440" ThreadID="8564" />
    <Channel>Microsoft-ServiceFabric/Admin</Channel>
    <Computer>shayward10.ovx.local</Computer>
    <Security UserID="S-1-5-20" />
  </System>
  <EventData>
    <Data Name="id">
    </Data>
    <Data Name="type">XmlLiteWriter</Data>
    <Data Name="text">WriteNode failed. HRESULT=-2147467259, Output=CustomOutput</Data>
  </EventData>
</Event>

事件查看器在超时时记录日志

一旦服务处于无法访问状态,尝试调用它会导致每个请求产生以下日志(等待5分钟后):

Log Name:      Microsoft-ServiceFabric/Admin
Source:        Microsoft-ServiceFabric
Date:          11/2/2016 2:44:55 PM
Event ID:      44289
Task Category: FabricTransport
Level:         Warning
Keywords:      Default
User:          NETWORK SERVICE
Computer:      shayward10.ovx.local
Description:
Error While Sending Message : FABRIC_E_TIMEOUT
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-ServiceFabric" Guid="{CBD93BC2-71E5-4566-B3A7-595D8EECA6E8}" />
    <EventID>44289</EventID>
    <Version>0</Version>
    <Level>3</Level>
    <Task>173</Task>
    <Opcode>0</Opcode>
    <Keywords>0x8000000000000001</Keywords>
    <TimeCreated SystemTime="2016-11-02T18:44:55.349048200Z" />
    <EventRecordID>7629</EventRecordID>
    <Correlation />
    <Execution ProcessID="18600" ThreadID="8076" />
    <Channel>Microsoft-ServiceFabric/Admin</Channel>
    <Computer>shayward10.ovx.local</Computer>
    <Security UserID="S-1-5-20" />
  </System>
 <EventData>
    <Data Name="id">
    </Data>
    <Data Name="type">ServiceCommunicationClient</Data>
    <Data Name="text">Error While Sending Message : FABRIC_E_TIMEOUT</Data>
  </EventData>
</Event>
2个回答

8

此问题可能发生在两种情况下。

  1. 如果您的ActorService方法处理时间超过默认超时时间,则需要更改OperationTimeout值。默认情况下,超时时间为5分钟。如果要更改超时时间,可以在客户端程序集中添加FabricTransportServiceRemotingProviderAttribute属性进行更改。

https://msdn.microsoft.com/en-us/library/microsoft.servicefabric.services.remoting.fabrictransport.fabrictransportserviceremotingproviderattribute.aspx

  1. 如果第一种情况不是问题所在,则您可以尝试以下已知错误的缓解方法。
    • 在Service Manifest中为ActorService端点指定端口0。默认情况下,ActorEndpoint将列在ServiceManifest中,但不会有端口。

这就是您进行更改后ActorService的外观。

<Endpoint Name="Actor1ActorServiceEndpoint" Port="0" />

我们已经意识到这个问题,正在修复中。

嗨 @MSFT-SuchiAgicha,问题是特定于某个actor吗?还是同样的解决方法应该适用于所有有状态服务?复制器端点怎么样?更多细节将不胜感激。谢谢! - d_z
1
@MSFT-SuchiAgicha,这个问题已经有解决方案了吗?或者我们可以在哪里跟踪这个问题呢? - jflood.net

3

如果有帮助的话,我们在长时间运行(超过5分钟)的操作中遇到了这些超时问题。根据Suchi提供的提示关于FabricTransportServiceRemotingProviderAttribute,我们将以下行添加到我们的SF项目的AssemblyInfo.cs,以将超时时间增加到1小时。

[assembly: FabricTransportServiceRemotingProvider(OperationTimeoutInSeconds = 3600)]
[assembly: FabricTransportActorRemotingProvider(OperationTimeoutInSeconds = 3600)]

另外请注意,如果您正在使用Azure服务总线,则最大锁定时间为5分钟,因此您需要实现一些锁定续订代码来支持长时间运行的操作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接