gpt4 book ai didi

c# - 当我在 ServiceFabric 群集上使用 EventFlow 监听 ETW 事件时出现“系统资源不足”

转载 作者:太空宇宙 更新时间:2023-11-03 22:42:57 26 4
gpt4 key购买 nike

我有一个使用在 Service Fabric 上运行的 EventFlow 的 ETW 监听器。

这是我的配置文件(eventFlowConfig.json):

{
"inputs": [
{
"type": "ETW",
"sessionNamePrefix": "MyListenerService",
"cleanupOldSessions": true,
"reuseExistingSession": true,
"providers": [
{
"providerName": "Provider0"
}
]
}
],
"filters": [],
"outputs": [
{
"type": "CustomOutput"
}
],
"schemaVersion": "2018-04-04",

"extensions": [
{
"category": "outputFactory",
"type": "CustomOutput",
"qualifiedTypeName": "MyNamespace.EventFlow.Outputs.CustomOutputFactory, MyAssembly"
}
]
}

这是我的切入点:

private static void Main()
{
try
{
string configurationFileName = "eventFlowConfig.json";

using (var diagnosticsPipeline = ServiceFabricDiagnosticPipelineFactory.CreatePipeline("MyService", configurationFileName))
{
ServiceRuntime.RegisterServiceAsync("MyServiceType",
context => new Service(context)).GetAwaiter().GetResult();

ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(Service).Name);
// Prevents this host process from terminating so services keeps running.
Thread.Sleep(Timeout.Infinite);
}
}
catch (Exception e)
{
ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());
throw;
}
}

当我在调试时在我的本地集群中多次启动/停止我的服务时,我得到了这个异常:

System.Runtime.InteropServices.COMException: 'Insufficient system resources exist to complete the requested service. (Exception from HRESULT: 0x800705AA)'

在重新启动计算机之前,我无法重新启动服务。问题是我在本地以外的其他环境中遇到了同样的异常。

我试过这个:TraceEventSession usage in ServiceFabric application raises insufficient resource error : 我的服务是无状态的,每个节点只有一个实例。

此配置是否足以释放/重用 ETW session ?

"sessionNamePrefix": "MyListenerService",
"cleanupOldSessions": true,
"reuseExistingSession": true,

有没有人遇到过这个问题?

编辑在 @Diego Mendes 的回答之后,我得到了这个执行 logman -ets

...
EventFlow-EtwInput-a8aefb3c-594f-4ac7-b9d8-6da1791fb122 Trace Running
EventFlow-EtwInput-fe5f58e6-d1a7-4198-95b2-d343584cf46b Trace Running
EventFlow-EtwInput-33f67287-5563-4835-b3a1-5527e4fc5e5e Trace Running
EventFlow-EtwInput-959eef04-a5ae-47eb-9b7e-057a9fd3fb28 Trace Running
EventFlow-EtwInput-0095f186-d657-4974-a613-213d7eb49def Trace Running
EventFlow-EtwInput-8fbc52f5-2de6-4826-bce2-36d8abf0c264 Trace Running
EventFlow-EtwInput-8e654b40-c299-48f4-818e-5ebe3c2341a4 Trace Running
EventFlow-EtwInput-7ec63ec9-428b-4658-b059-698b5ae66986 Trace Running

EventFlow 忽略了我的 sessionNamePrefix 并用 EventFlow-EtwInput 覆盖?可能是 EventFlow 的错误?

我将尝试使用 EventFlow-EtwInput 作为我的 sessionNamePrefix

最佳答案

正如您所指出的,这是因为您多次启动和停止服务。每次启动服务时,都会创建一个新 session ,当您在 Debug模式下执行此操作时,调试器会在关闭事件 session 之前终止进程。

来自马特回答你链接:

Windows has a limit of 64 ETW sessions that can be running concurrently. Consider using a single stateless app running on every node to create a single session.

您可以通过运行以下命令检查它何时再次发生,是否有任何 session 保持打开状态:

logman -ets

它将列出所有事件 session ,您的可能显示为如下内容:

MyListenerService-A402EE30-53B7-48E4-B602-76B101C0AB97

如果您有多个事件 session ,是因为它没有正确关闭,也没有重用旧 session 。

在配置中,当你设置:

cleanupOldSessions: If set to TRUE, existing ETW trace sessions matching the sessionNamePrefix will be closed. This helps to collect leftover session instances, as there is a limit on their number.

reuseExistingSession: If turned on, then an existing trace session matching the sessionNamePrefix will be re-used. If cleanupOldSessions is also turned on, then it will leave one session open for re-use.

根据您的设置,您同时使用了 ON,我会尝试调整这些值以查看是否可以解决问题。

关于c# - 当我在 ServiceFabric 群集上使用 EventFlow 监听 ETW 事件时出现“系统资源不足”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51377117/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com