Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Pipelining of requests forbidden when getting metrics #154

Open
Socolin opened this issue Feb 23, 2021 · 5 comments
Open

Error: Pipelining of requests forbidden when getting metrics #154

Socolin opened this issue Feb 23, 2021 · 5 comments

Comments

@Socolin
Copy link
Contributor

Socolin commented Feb 23, 2021

Hello,

When a function is running at the same time as the metric collector I get this exception: Pipelining of requests forbidden
of type System.NotSupportedException at RabbitMQ.Client.Impl.RpcContinuationQueue.Enqueue

The problem is that the same channel is used in different thread, this is not supported by RabbitMQ librar. Iit should use another IModel to do that.

public Task<RabbitMQTriggerMetrics> GetMetricsAsync()
{
QueueDeclareOk queueInfo = _rabbitMQModel.QueueDeclarePassive(_queueName);
RabbitMQTriggerMetrics metrics = new RabbitMQTriggerMetrics
{
QueueLength = queueInfo.MessageCount,
Timestamp = DateTime.UtcNow,
};
return Task.FromResult(metrics);
}

[
    {
        "method": "RabbitMQ.Client.Impl.RpcContinuationQueue.Enqueue",
        "level": 0,
        "assembly": "RabbitMQ.Client, Version=6.0.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce",
        "line": 0
    },
    {
        "method": "RabbitMQ.Client.Impl.ModelBase.Enqueue",
        "level": 1,
        "assembly": "RabbitMQ.Client, Version=6.0.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce",
        "line": 0
    },
    {
        "method": "RabbitMQ.Client.Impl.ModelBase.QueueDeclare",
        "level": 2,
        "assembly": "RabbitMQ.Client, Version=6.0.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce",
        "line": 0
    },
    {
        "method": "RabbitMQ.Client.Impl.AutorecoveringModel.QueueDeclarePassive",
        "level": 3,
        "assembly": "RabbitMQ.Client, Version=6.0.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce",
        "line": 0
    },
    {
        "method": "Microsoft.Azure.WebJobs.Extensions.RabbitMQ.RabbitMQListener.GetMetricsAsync",
        "level": 4,
        "assembly": "WebJobs.Extensions.RabbitMQ, Version=2021.2.16.1, Culture=neutral, PublicKeyToken=null"
    },
    {
        "method": "Microsoft.Azure.WebJobs.Extensions.RabbitMQ.RabbitMQListener+<Microsoft-Azure-WebJobs-Host-Scale-IScaleMonitor-GetMetricsAsync>d__22.MoveNext",
        "level": 5,
        "assembly": "WebJobs.Extensions.RabbitMQ, Version=2021.2.16.1, Culture=neutral, PublicKeyToken=null",
        "line": 0
    },
    {
        "method": "System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw",
        "level": 6,
        "assembly": "System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e",
        "line": 0
    },
    {
        "method": "System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess",
        "level": 7,
        "assembly": "System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e",
        "line": 0
    },
    {
        "method": "System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification",
        "level": 8,
        "assembly": "System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e",
        "line": 0
    },
    {
        "method": "System.Runtime.CompilerServices.TaskAwaiter`1.GetResult",
        "level": 9,
        "assembly": "System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e",
        "line": 0
    },
    {
        "method": "Microsoft.Azure.WebJobs.Script.Scale.FunctionsScaleMonitorService+<TakeMetricsSamplesAsync>d__13.MoveNext",
        "level": 10,
        "assembly": "Microsoft.Azure.WebJobs.Script, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null",
        "line": 95,
        "fileName": "D:\\a\\1\\s\\src\\WebJobs.Script\\Scale\\FunctionsScaleMonitorService.cs"
    }
]
@yojagad
Copy link
Contributor

yojagad commented Feb 25, 2021

Can you elaborate on this a little bit more ? Do you get the IModel object(_rabbitMqModel) from a different function using RabbitMQ binding and use the same in GetMetricsAsync() ?

@Socolin
Copy link
Contributor Author

Socolin commented Feb 26, 2021

I don't gent anything, the current code reuse the same IModel for evrything, for getting the metrics, for consuming and for publishing. It should use one IModel / thread and even use 2 connections (one for publish, one for consumemer)

https://www.cloudamqp.com/blog/2017-12-29-part1-rabbitmq-best-practice.html#don%E2%80%99t-share-channels-between-threads

@yojagad
Copy link
Contributor

yojagad commented Feb 26, 2021

Thanks for clarifying that. Aside from our current implementation of IScaleMonitor and GetMetricsAsync(), can I get more info on what your function actually does as well, including the signature, etc ? This will help me narrow down on a plausible solution and also run some scenarios on our end.

@ghost
Copy link

ghost commented Mar 2, 2021

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@Socolin
Copy link
Contributor Author

Socolin commented Mar 2, 2021

I'm using 2 trigger function, one of them with a dead letter queue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants