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

A running SubscriberClient causes exceptions after a few seconds #10992

Closed
tnotheis opened this issue Sep 5, 2023 · 36 comments
Closed

A running SubscriberClient causes exceptions after a few seconds #10992

tnotheis opened this issue Sep 5, 2023 · 36 comments
Assignees
Labels
needs more info This issue needs more information from the customer to proceed. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@tnotheis
Copy link

tnotheis commented Sep 5, 2023

Environment details

  • OS: doesn't seem to matter (tested it in Windows 11 as well as in a Ubuntu Docker container)
  • .NET version: net7.0
  • Package name and version: Google.Cloud.PubSub.V1, Version 3.6.0

Steps to reproduce

I have a Visual Studio solution with the minimal setup, which I would like to add to a GitHub repo, but it seems like GitHub currently experiences some problems, and I can't create a repository. So here is a zip file: PubSubTestAspNet.zip

  1. Download the zip file
  2. Extract it
  3. Open the solution with Visual Studio
  4. Fill the placeholders (<...>)
  5. Run it
  6. Open the "Output" window

Now wait for about 70 seconds. After that, Visual Studio begins to log occurring exceptions:

Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll

It starts slowly, but it's getting worse with time. Also, the performance degrades the longer the solution is running.

Is this a bug or am I using the library the wrong way?

Thanks!

@jskeet
Copy link
Collaborator

jskeet commented Sep 5, 2023

I'll look at this tomorrow. Looking at the code very briefly though, it's not clear whether this is actually related to ASP.NET Core at all - do you observe the same behavior if you run the same code in a simple console app, without the ASP.NET Core part? It would be good to reproduce this in as simple a fashion as possible.

@tnotheis
Copy link
Author

tnotheis commented Sep 5, 2023

Thank you for the quick reply. Just tested it and it's actually the same problem with a console application. You can use the following code to reproduce it:

using Google.Api.Gax;
using Google.Apis.Auth.OAuth2;
using Google.Cloud.PubSub.V1;

const string projectId = "<...>";
var credentials = GoogleCredential.FromJson("<...>");
const string subscriptionId = "<...>";

var subscriberClient = new SubscriberClientBuilder
{
    GoogleCredential = credentials,
    SubscriptionName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId)
}.Build();

await subscriberClient.StartAsync((_, _) => Task.FromResult(SubscriberClient.Reply.Ack));

I'm looking forward to your reply.

@jskeet jskeet self-assigned this Sep 5, 2023
@jskeet jskeet added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. status: investigating The issue is under investigation, which is determined to be non-trivial. labels Sep 5, 2023
@jskeet
Copy link
Collaborator

jskeet commented Sep 5, 2023

Great, thanks - that will certainly make it simpler to repro. Will look into it tomorrow.

@tnotheis tnotheis changed the title Using SubscriberClient in ASP.NET to listen in the background causes exceptions after a few seconds A running SubscriberClient causes exceptions after a few seconds Sep 5, 2023
@tnotheis
Copy link
Author

tnotheis commented Sep 5, 2023

I tried to downgrade to older versions, and the problem occurs until and including 3.1.0. I didn't downgrade any further because there seemed to be a change in the way you need to initialize a SubscriberClient and I didn't have any more time to make it compile.

@tnotheis
Copy link
Author

tnotheis commented Sep 6, 2023

Just downgraded to 3.0.0. There are still exceptions being logged, but far fewer than with >3.1.0.

@tnotheis
Copy link
Author

tnotheis commented Sep 6, 2023

Okay, seems like the fewer exceptions are explained by the fact that when using version 3.0.0, I couldn't use the SubscriberClientBuilder. And when creating the client manually, I created a single SubscriberServiceApiClient, while the SubscriberClientBuilder creates one per logical processor (in my case: 32). So when using the builder, the number of exceptions is multiplied by 32. I was able to confirm that by setting the ClientCount property of the builder to 1.

This means that the error is probably related to the SubscriberServiceApiClient.

Btw, in the meantime I created a repository with the examples: https://github.com/tnotheis/pubsub-subscriber-exceptions
It has 3 branches:

Branch Library version Uses SubscriberClientBuilder? Number of logged exceptions in 3 min
main 3.6.0 yes ~1100
3.0.0 3.0.0 no 35
3.6.0-without-builder 3.6.0 no 35

@jskeet
Copy link
Collaborator

jskeet commented Sep 6, 2023

I've reproduced this now, and the RpcException is:

Status(StatusCode="Unavailable", Detail="The service was unable to fulfill your request. Please try again. [code=8a75]")

It looks like it's coming from ResponseStream.MoveNext.

The fact that we're seeing that as far back as 3.0 suggests that this is a service issue rather than a library issue, but I'm reluctant to come to any firm conclusions just yet.

While it's also possible that some RPC failures are expected (SubscriberClient retries, of course) I definitely wouldn't expect them to happen this frequently. I would note that while SubscriberClient is handwritten and contains a lot of really fiddly async code, SubscriberServiceApiClient is just generated from the API definitions - so I wouldn't expect the problem to be in there.

Could you clarify what you meant by this in the initial post:

Also, the performance degrades the longer the solution is running.

Do you mean your topic has lots of messages and they're being pulled more slowly over time? Any details so I could try to reproduce that too would be appreciated.

@jskeet
Copy link
Collaborator

jskeet commented Sep 6, 2023

Could I ask a question about timing? Is this code that you've had running for some time, and it looks like the problem only started recently, or is it fresh new code? I assume that in production, you wouldn't see the exceptions (because they're being caught) and you'd just see the performance degradation. If the reason you've been running this in the debugger is because you did spot a performance degradation in a production service, then any information you have about when things changed would be enormously helpful.

@tnotheis
Copy link
Author

tnotheis commented Sep 6, 2023

Could you clarify what you meant by this in the initial post:

Also, the performance degrades the longer the solution is running.

Do you mean your topic has lots of messages and they're being pulled more slowly over time? Any details so I could try to reproduce that too would be appreciated.

Sorry for the late reply. I wanted to reproduce the performance problem. But it only seemed to occur in my actual solution. So I fiddled around with it to see when it was happening and when it wasn't. Until I noticed that it wasn't related to this library at all... A restart of my PC, combined with the deletion of my database volume and all my containers then fixed the performance problems. So ignore that one.

@jskeet
Copy link
Collaborator

jskeet commented Sep 6, 2023

Until I noticed that it wasn't related to this library at all...

That's really good to know, thanks. (And thanks for being so responsive - your idea of a "late" reply is far more responsive than most folks!)

@tnotheis
Copy link
Author

tnotheis commented Sep 6, 2023

Could I ask a question about timing? Is this code that you've had running for some time, and it looks like the problem only started recently, or is it fresh new code? I assume that in production, you wouldn't see the exceptions (because they're being caught) and you'd just see the performance degradation. If the reason you've been running this in the debugger is because you did spot a performance degradation in a production service, then any information you have about when things changed would be enormously helpful.

The code in question was implemented several months ago, but was only used in some small tests until yesterday, when we finally got a pub/sub topic. I then ran a larger test suite, which took a few minutes. It was during this test run that I first noticed the logged exceptions. So I can't say how long the problem has existed.

Since there is no performance degradation, as I mentioned in my previous comment, the impact on our business is no longer that high. But of course I will still try to provide you with any information necessary to resolve this. Because as you said, the amount of exceptions seems like there's something wrong.

@jskeet
Copy link
Collaborator

jskeet commented Sep 6, 2023

That's all good to know, thanks. (It's also good to hear that the impact on the business is no longer high.)

I don't think there's anything else to ask you to test at the moment, but thanks so much for the help so far.

FYI, I've reproduced this in both .NET 7.0 and .NET 4.8, where the latter uses Grpc.Core rather than Grpc.Net.Client - so it's unlikely to be a gRPC stack issue.

I'm talking with folks internally, and will update you when I can.

@jskeet
Copy link
Collaborator

jskeet commented Sep 6, 2023

Hmm... having said I'm able to reproduce it, I'm not sure that's actually correct - I can't reproduce nearly that many exceptions.

In order to limit the variation, I've got a new test which creates the client like this:

var client = new SubscriberClientBuilder
{
    ClientCount = 1,
    SubscriptionName = subscriptionName
}.Build();

That should correspond to the code you had with manually-specified underlying clients, where you were reporting ~11 exceptions per minute. I'm only seeing one every ~80-120 seconds (so less than 1 per minute).

One difference is that I'm using HEAD code (so that I can easily add more diagnostics) - but we pushed out version 3.7.0 today, so if you can upgrade your test rig to that, it would be helpful in terms of minimizing differences. Note that I'm only counting RpcExceptions (as that's what we're catching) - I suspect that TaskCanceledException is being handled internally.

I suspect that the debugger output is adding to some confusion here - running in the debugger, I'm seeing 4 lines like this:

Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll

... for every one exception actually caught. Even that wouldn't fully explain the discrepancy though - I'd expect you to see debugger output of 2-4 lines per minute, not 11.

@jskeet
Copy link
Collaborator

jskeet commented Sep 6, 2023

If you want to run the exact code I'm running, see #11004 including the comment - basically if you fetch either that pull request, or everything after it's merged, and make the small change indicated in the commit, you can get simpler diagnostics.

@tnotheis
Copy link
Author

tnotheis commented Sep 6, 2023

First of all: I just installed version 3.7.0. The output is still the same though, unfortunately.

Did you keep the program running for more than one minute? The reason I ask this is that after ~70s there are actually only 4 exceptions logged. But if you run it for ~2.5 minutes, there is a second batch of exceptions logged, which is significantly larger than the first one (27 instead of 4).

@tnotheis
Copy link
Author

tnotheis commented Sep 6, 2023

That's what I meant by "It starts slowly, but it's getting worse with time." in the issue description. Could have been more expressive, I admit.

@jskeet
Copy link
Collaborator

jskeet commented Sep 6, 2023

Yes, I was running for about 10 minutes. I haven't seen a batch of exceptions logged like you're describing. I'm running again now, not in VS, but with the code in #11004. Now there's the possibility that the exception isn't the one I'm currently logging... I'll see if I can find a more "catch-all" place to put that logging.

@jskeet
Copy link
Collaborator

jskeet commented Sep 6, 2023

Hmm. Not seeing anywhere nicely centralized that I can add logging right now - I'm sure it's possible, but I'm keep to get another run going. I've added it everywhere I think we might be seeing things. I'm going to leave this running for an hour and then upload the log here, so you can compare it with what you're seeing.

@tnotheis
Copy link
Author

tnotheis commented Sep 6, 2023

For the sake of completeness, here is the whole log after 2.5 minutes:

Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'System.Threading.Channels.ChannelClosedException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Quic.QuicException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Quic.QuicException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Quic.QuicException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Quic.QuicException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Quic.QuicException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Quic.QuicException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Quic.QuicException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Quic.QuicException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Quic.QuicException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Quic.QuicException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Quic.QuicException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in Grpc.Net.Client.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in Grpc.Net.Client.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll

I will have a call with a colleague soon where I will make him run the project to see if the problem is my machine.

@jskeet
Copy link
Collaborator

jskeet commented Sep 6, 2023

That's really interesting - the only exceptions I've seen in VS at all are System.Threading.Tasks.TaskCanceledException and Grpc.Core.RpcException. It looks like you're seeing very different behavior.

(This could end up being related to a proxy or other network difference.)

I'm still running my just-on-a-console test - after that I'll try again in VS and copy my log from that (after leaving it for at least 10 minutes).

@tnotheis
Copy link
Author

tnotheis commented Sep 6, 2023

Now it's getting weird. My colleague doesn't see any exceptions at all. So this means we have three different behaviors now.

He has installed dotnet 7.0.200. I have 7.0.307. Which version do you have?

@jskeet
Copy link
Collaborator

jskeet commented Sep 6, 2023

I've been running under .NET 6.0 - SDK 6.0.413.

If we want to try .NET 7, I've got 7.0.400 installed, but nothing between 7.0.110 and that. I'll try with 7.0.400 to see if that changes things.

I've attached my console log below - this is just the additional Console.WriteLine though, not the output window of VS. As you can see, the exceptions are pretty rare (and that's in-line with my expectation of "each streaming pull call times out after a while and is restarted"; the fact that the RPC error is Unavailable is a little odd, but I suspect it's been like that forever).

I'll run in VS now (still with .NET 6 to start with) and capture ~10 minutes of output from that.

log.txt

@jskeet
Copy link
Collaborator

jskeet commented Sep 6, 2023

Okay, 11 minutes of Output Window from VS running in .NET 6:

The thread 0x21e4 has exited with code 0 (0x0).
The thread 0x41c has exited with code 0 (0x0).
The thread 0x1e9c has exited with code 0 (0x0).
The thread 0x48f8 has exited with code 0 (0x0).
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
The thread 0x5650 has exited with code 0 (0x0).
The thread 0x8b6c has exited with code 0 (0x0).
The thread 0x8024 has exited with code 0 (0x0).
The thread 0x82c8 has exited with code 0 (0x0).
The thread 0x7058 has exited with code 0 (0x0).
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
The thread 0x152c has exited with code 0 (0x0).
The thread 0x4f88 has exited with code 0 (0x0).
The thread 0x64c4 has exited with code 0 (0x0).
The thread 0x8a24 has exited with code 0 (0x0).
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
The thread 0x178c has exited with code 0 (0x0).
The thread 0x4eac has exited with code 0 (0x0).
The thread 0xe5c has exited with code 0 (0x0).
The thread 0x84a8 has exited with code 0 (0x0).
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
The thread 0x3428 has exited with code 0 (0x0).
The thread 0x6720 has exited with code 0 (0x0).
The thread 0x3a6c has exited with code 0 (0x0).
The thread 0x3c5c has exited with code 0 (0x0).
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
The thread 0x6fd8 has exited with code 0 (0x0).
The thread 0x2b94 has exited with code 0 (0x0).
The thread 0x7a90 has exited with code 0 (0x0).
The thread 0x7520 has exited with code 0 (0x0).
The thread 0xa228 has exited with code 0 (0x0).
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll

(6 exceptions logged to the actual console.) Will try in .NET 7 now.

@jskeet
Copy link
Collaborator

jskeet commented Sep 6, 2023

Output window log when running with .NET 7.0, which is loading assemblies from Microsoft.NETCore.App\7.0.10, for about 10 minutes:

The thread 0x8368 has exited with code 0 (0x0).
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
The thread 0x8958 has exited with code 0 (0x0).
The thread 0x38c4 has exited with code 0 (0x0).
The thread 0x7be4 has exited with code 0 (0x0).
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
The thread 0x5c6c has exited with code 0 (0x0).
The thread 0x9f08 has exited with code 0 (0x0).
The thread 0xa3cc has exited with code 0 (0x0).
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
The thread 0x63f8 has exited with code 0 (0x0).
The thread 0x50b0 has exited with code 0 (0x0).
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
The thread 0x4118 has exited with code 0 (0x0).
The thread 0x9df8 has exited with code 0 (0x0).
The thread 0x6d8c has exited with code 0 (0x0).
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
The thread 0x9330 has exited with code 0 (0x0).
The thread 0x5d74 has exited with code 0 (0x0).
The thread 0x6df4 has exited with code 0 (0x0).
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in System.Private.CoreLib.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll
Exception thrown: 'Grpc.Core.RpcException' in Grpc.Net.Client.dll

So again, no big batch of exceptions.

@jskeet
Copy link
Collaborator

jskeet commented Sep 6, 2023

Just to set expectations: I'm on vacation tomorrow, so will pick this up again on Friday. It now looks like it's probably environmental though...

@tnotheis
Copy link
Author

tnotheis commented Sep 6, 2023

It now looks like it's probably environmental though...

Yeah, that's what I'm thinking.

Tomorrow is a day full of meeting, so I won't have much time to look into this either. But I will try to find some time on Friday.

Enjoy your vacation and thank you for the effort.

@jskeet
Copy link
Collaborator

jskeet commented Sep 13, 2023

Any more updates on this? I'd like to close it if possible, as I don't think it's anything to do with the client library specifically. It may well be an aspect of a gRPC implementation, and I'd be interested to know more, but I doubt that we'll want to make any changes in the Pub/Sub library. Let me know your thoughts.

@jskeet jskeet added needs more info This issue needs more information from the customer to proceed. and removed status: investigating The issue is under investigation, which is determined to be non-trivial. labels Sep 13, 2023
@tnotheis
Copy link
Author

Sorry, I totally forgot to update this issue. I've been very busy the last few days.
I guess it's okay to close it. I will reopen it in case there are some serious problems.

@jskeet
Copy link
Collaborator

jskeet commented Sep 13, 2023

Great, thanks! (Hope whatever's causing you to be busy is either welcome, or is resolved soon...)

@jskeet jskeet closed this as completed Sep 13, 2023
@tnotheis
Copy link
Author

Thank you for the great support!

@kamisoft-fr
Copy link

Hi folks, please note that I'm facing the same issue that prints warnings for weeks(months?),

lots of

Recoverable error in streaming pull; will retry.
System.AggregateException: One or more errors occurred. (Status(StatusCode="Unavailable", Detail="The service was unable to fulfill your request. Please try again. [code=8a75]"))
---> Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="The service was unable to fulfill your request. Please try again. [code=8a75]")
at Grpc.Net.Client.Internal.HttpContentClientStreamReader`2.MoveNextCore(CancellationToken cancellationToken)
--- End of inner exception stack trace ---

and sometimes

Recoverable error in streaming pull; will retry.
System.AggregateException: One or more errors occurred. (Status(StatusCode="Unavailable", Detail="Error starting gRPC call. HttpRequestException: An error occurred while sending the request. QuicException: The connection timed out from inactivity.", DebugException="System.Net.Http.HttpRequestException: An error occurred while sending the request."))
---> Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="Error starting gRPC call. HttpRequestException: An error occurred while sending the request. QuicException: The connection timed out from inactivity.", DebugException="System.Net.Http.HttpRequestException: An error occurred while sending the request.")
---> System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.Net.Quic.QuicException: The connection timed out from inactivity.
at System.Net.Quic.ResettableValueTaskSource.TryComplete(Exception exception, Boolean final)
at System.Net.Quic.QuicStream.HandleEventShutdownComplete(_SHUTDOWN_COMPLETE_e__Struct& data)
at System.Net.Quic.QuicStream.HandleStreamEvent(QUIC_STREAM_EVENT& streamEvent)
at System.Net.Quic.QuicStream.NativeCallback(QUIC_HANDLE* connection, Void* context, QUIC_STREAM_EVENT* streamEvent)
--- End of stack trace from previous location ---
at System.Net.Quic.ResettableValueTaskSource.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Net.Quic.QuicStream.ReadAsync(Memory1 buffer, CancellationToken cancellationToken) at System.Net.Http.Http3RequestStream.ReadFrameEnvelopeAsync(CancellationToken cancellationToken) at System.Net.Http.Http3RequestStream.ReadResponseAsync(CancellationToken cancellationToken) at System.Net.Http.Http3RequestStream.SendAsync(CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.Http3RequestStream.SendAsync(CancellationToken cancellationToken) at System.Net.Http.Http3RequestStream.SendAsync(CancellationToken cancellationToken) at System.Net.Http.Http3Connection.SendAsync(HttpRequestMessage request, Int64 queueStartingTimestamp, CancellationToken cancellationToken) at System.Net.Http.Http3Connection.SendAsync(HttpRequestMessage request, Int64 queueStartingTimestamp, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.TrySendUsingHttp3Async(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.Metrics.MetricsHandler.SendAsyncWithMetrics(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at Grpc.Net.Client.Balancer.Internal.BalancerHttpHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at Grpc.Net.Client.Internal.GrpcCall2.RunCall(HttpRequestMessage request, Nullable1 timeout) --- End of inner exception stack trace --- at Grpc.Net.Client.Internal.HttpContentClientStreamReader2.MoveNextCore(CancellationToken cancellationToken)
--- End of inner exception stack trace ---

Maybe it can help, I tried to limit the ClientCount to 1 but I'm still facing those logs!

@jskeet
Copy link
Collaborator

jskeet commented May 14, 2024

@kamisoft-fr: I would suggest at least trying to disable HTTP/3.

See the code here for an example of how to do that. It's slightly fiddly at the moment - we're hoping that the gRPC team can simplify it somewhat.

If that doesn't help, please file a new issue with more details, ideally including a short but complete example as a console app, including environmental details.

@kamisoft-fr
Copy link

Thanks Jon, unfortunately it did change the behavior

As soon as I start the app, always after 1 minute ish, the warnings start to popup

10:50:17 info: Program[0] Received message: test message
10:50:17 info: Program[0] Received message: test message2
10:50:19 info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down.
10:50:19 info: Microsoft.Hosting.Lifetime[0] Hosting environment: development
10:50:20 info: Program[0] Received message: test message3
10:51:17 warn: Len.Common.Infrastructure.Pubsub.Google.GoogleChannelSubscriber[0] Recoverable error in streaming pull; will retry. System.AggregateException: One or more errors occurred. (Status(StatusCode="Unavailable", Detail="The service was unable to fulfill your request. Please try again. [code=8a75]")) ---> Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="The service was unable to fulfill your request. Please try again. [code=8a75]") at Grpc.Net.Client.Internal.HttpContentClientStreamReader2.MoveNextCore(CancellationToken cancellationToken) --- End of inner exception stack trace --- 10:51:17 warn: Len.Common.Infrastructure.Pubsub.Google.GoogleChannelSubscriber[0] Recoverable error in streaming pull; will retry. System.AggregateException: One or more errors occurred. (Status(StatusCode="Unavailable", Detail="The service was unable to fulfill your request. Please try again. [code=8a75]")) ---> Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="The service was unable to fulfill your request. Please try again. [code=8a75]") at Grpc.Net.Client.Internal.HttpContentClientStreamReader2.MoveNextCore(CancellationToken cancellationToken) --- End of inner exception stack trace ---
10:51:21 warn: Len.Common.Infrastructure.Pubsub.Google.GoogleChannelSubscriber[0] Recoverable error in streaming pull; will retry. System.AggregateException: One or more errors occurred. (Status(StatusCode="Unavailable", Detail="The service was unable to fulfill your request. Please try again. [code=8a75]")) ---> Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="The service was unable to fulfill your request. Please try again. [code=8a75]") at Grpc.Net.Client.Internal.HttpContentClientStreamReader2.MoveNextCore(CancellationToken cancellationToken) --- End of inner exception stack trace --- 10:51:22 warn: Len.Common.Infrastructure.Pubsub.Google.GoogleChannelSubscriber[0] Recoverable error in streaming pull; will retry. System.AggregateException: One or more errors occurred. (Status(StatusCode="Unavailable", Detail="The service was unable to fulfill your request. Please try again. [code=8a75]")) ---> Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="The service was unable to fulfill your request. Please try again. [code=8a75]") at Grpc.Net.Client.Internal.HttpContentClientStreamReader2.MoveNextCore(CancellationToken cancellationToken) --- End of inner exception stack trace ---
10:51:25 warn: Len.Common.Infrastructure.Pubsub.Google.GoogleChannelSubscriber[0] Recoverable error in streaming pull; will retry. System.AggregateException: One or more errors occurred. (Status(StatusCode="Unavailable", Detail="The service was unable to fulfill your request. Please try again. [code=8a75]")) ---> Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="The service was unable to fulfill your request. Please try again. [code=8a75]") at Grpc.Net.Client.Internal.HttpContentClientStreamReader2.MoveNextCore(CancellationToken cancellationToken) --- End of inner exception stack trace --- 10:51:26 warn: Len.Common.Infrastructure.Pubsub.Google.GoogleChannelSubscriber[0] Recoverable error in streaming pull; will retry. System.AggregateException: One or more errors occurred. (Status(StatusCode="Unavailable", Detail="The service was unable to fulfill your request. Please try again. [code=8a75]")) ---> Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="The service was unable to fulfill your request. Please try again. [code=8a75]") at Grpc.Net.Client.Internal.HttpContentClientStreamReader2.MoveNextCore(CancellationToken cancellationToken) --- End of inner exception stack trace ---

I created a console app with all my pubsub boilerplate as it is in done in my code base, I'm about to push it somewhere so that you can launch it locally :)

@jskeet
Copy link
Collaborator

jskeet commented May 15, 2024

@kamisoft-fr: As noted before, please create a new issue rather than commenting further here. (And did you mean "it did not change the behavior" instead of "it did change the behavior"? Something to note in the new issue.)

@kamisoft-fr
Copy link

Yes indeed I meant "did not", I will create the issue right away!

@kamisoft-fr
Copy link

Here it is, thanks for your time! #12964

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info This issue needs more information from the customer to proceed. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants