question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Grpc.Core.RpcException: Status(StatusCode=Unauthenticated, Detail="Deadline Exceeded") ?

See original GitHub issue

We are deploying asp.net core 2.0 project to app engine flex(while previous version is under load: about 200req/sec), and in some cases we are getting “Grpc.Core.RpcException: Status(StatusCode=Unauthenticated, Detail=“Deadline Exceeded”)” while trying to run query on datastore with standard datastore client, sometimes errors are gone and sometimes they are rising again, not sure if it depends on requests rate. So here is our app.yaml:

env: flex
runtime: aspnetcore
resources:
 cpu: 16
 memory_gb: 14.4

automatic_scaling:
  min_num_instances: 8
  max_num_instances: 20
  cool_down_period_sec: 180
  cpu_utilization:
    target_utilization: 0.5 

And here is full stack trace:

Grpc.Core.RpcException: Status(StatusCode=Unauthenticated, Detail="Deadline Exceeded")
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification
at Grpc.Core.Internal.AsyncCall`2.UnaryCall
at Grpc.Core.DefaultCallInvoker.BlockingUnaryCall[TRequest,TResponse]
at Grpc.Core.Internal.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TResponse]
at Google.Cloud.Datastore.V1.Datastore.DatastoreClient.RunQuery
at Google.Api.Gax.Grpc.ApiCall.<>c__DisplayClass0_0`2.<Create>b__1
at Google.Api.Gax.Grpc.ApiCallRetryExtensions.<>c__DisplayClass1_0`2.<WithRetry>b__0
at Google.Cloud.Datastore.V1.QueryStreamer.<Sync>d__7.MoveNext
at System.Collections.Generic.List`1.AddEnumerable
at System.Linq.Enumerable.ToList[TSource]
at Google.Cloud.Datastore.V1.LazyDatastoreQuery.GetAllResults

@vuukle @jskeet

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:140

github_iconTop GitHub Comments

1reaction
jskeetcommented, Feb 23, 2018

At this point I suspect you really need a Datastore expert to help you. I’ll reach out internally to try to find someone who can help.

1reaction
jskeetcommented, Feb 19, 2018

I’m afraid I don’t know details about Datastore itself - I work on a lot of different APIs, so don’t know very much about each of them. I just make sure you can get requests from C# code to the server…

Here’s a small sample for you for the pooling. You’d create an instance on start-up, then keep that instance everywhere, calling var db = pool.GetNextInstance(); each time you wanted to make a request. If you have a chance to test that out and see if it improves your latency, that would be really interesting.

using Google.Apis.Auth.OAuth2;
using Google.Cloud.Datastore.V1;
using Grpc.Auth;
using Grpc.Core;
using System.Linq;

namespace DatastoreTest
{
    // Sample code only; needs more work for productionization.

    /// <summary>
    /// Pool of DatastoreDb instances which are returned in round-robin order (they're never
    /// "returned" to the pool). Assumptions: default credentials, a single DB, and no need to
    /// release channels.
    /// </summary>
    public class RoundRobinDatastoreDbPool
    {
        private readonly DatastoreDb[] _instances;
        private int _nextIndex = 0;
        private readonly object _lock = new object();

        public RoundRobinDatastoreDbPool(string projectId, string namespaceId, int count)
        {
            var credentials = GoogleCredential.GetApplicationDefault()
                .CreateScoped(DatastoreClient.DefaultScopes) // Not necessary as of Grpc.Core 1.8
                .ToChannelCredentials();
            string host = DatastoreClient.DefaultEndpoint.Host;
            int port = DatastoreClient.DefaultEndpoint.Port;
            _instances = Enumerable.Range(0, count)
                .Select(_ => new Channel(host, port, credentials))
                .Select(channel => DatastoreClient.Create(channel))
                .Select(client => DatastoreDb.Create(projectId, namespaceId, client))
                .ToArray();
        }

        public DatastoreDb GetNextInstance()
        {
            lock (_lock)
            {
                DatastoreDb instance = _instances[_nextIndex++];
                if (_nextIndex == _instances.Length)
                {
                    _nextIndex = 0;
                }
                return instance;
            }
        }
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Grpc proxy server for Google speech streaming api is not ...
Grpc.Core.RpcException: Status(StatusCode=DeadlineExceeded, Detail="Deadline Exceeded") at System.Runtime.CompilerServices.TaskAwaiter.
Read more >
Deadline Exceeded when fetching ads since 4/6
The query can successfully return ~400k Responsive Search Ads within 40 minutes. But now it hit the "Deadline Exceeded" every 15 minutes. Grpc.Core.RpcException...
Read more >
Grpc.Core.RpcException : Deadline Exceeded ("grpc_status"
This exception occurs twice or thrice in an hour. Grpc.Core.RpcException: Status(StatusCode="DeadlineExceeded", Detail="Deadline Exceeded", ...
Read more >
C# worker, Deadline Exceeded, grpc_status":4 - Zeebe Client
Hi, I've a worker (C#), and there are errors in the log despite this, the worker continues working and handling tasks.
Read more >
Reliable gRPC services with deadlines and cancellation
A deadline allows a gRPC client to specify how long it will wait for a call to complete. When a deadline is exceeded,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found