-
-
Notifications
You must be signed in to change notification settings - Fork 916
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
NullReferenceException #1950
Comments
Please close this ticket, it was posted in the wrong GitHub Repo. I have moved this to the server side, where it belongs. You may delete as well. My mistake. |
From the stacktrace I see that the error belongs to this repo. |
@STRATZ-Ken Could you please provide a minimum repro? |
@sungam3r Its really not possible. I cannot even replicate it. It seems to start happening after about an hour or two. Some food for thought. I did make a pretty big change. I use Entity Framework with DBPoolingContext. This requires all the types to be Scoped if I do Dependency Injection. Which led me to #648 . After reading that performance could be hurt, I changed my services to Singleton, and then used the "hack" in #648 provided to get my DBContext inside each of the Types for GraphQL. After about 12 hours, I would have a massive memory leak from using Scoped services, plus overall the performance was garbage. Since switching to Singleton about 18 hours ago, I have not had a single outage or missed API hit. My RAM is stead around 8-12GB and I am doing nearly 12,000 calls per minute. I don't know if the above could be the issue, but it was worth noting. |
Just wondering:
|
I hope this helps. |
In case of memory leak you can try any memory profiler, for example JetBrains dotMemery. It has 10 or 15 days free trial period. |
Yeah, This is exactly what I did. I found that only calling GraphQL endpoints, there after a while there was 14million 'objects'. After diving deeper, the objects were based on GraphQL. Which led me to #648 |
If you can already see what objects are in memory, then it will not be difficult to find the cause. If you can't, you can send a dump. |
The
This should save some CPU time per request if your queries are pretty repetitive, as it eliminates both parsing and validation of the incoming queries. It also reduces the number of allocations by quite a bit. If it's being hit by many different people's implementations, then you might find a wide variety of queries stored in the cache, even for similar queries. So you might need to allocate a large buffer -- but it should be effective. Note that if you have any validation rules that inspect the incoming variables (none are included by default), then those would have to run for each document. |
This is the latest error I am getting. Line 18 is :
Which is from the link above : #648 (comment) |
Probably because you are missing an |
|
You do realize that with 3.0, you can just call |
@Shane32 Totally correct, but to me it looks cleaner. At least this stack trace gives a bit more information so I know exactly what call is having issues. |
Is the problem intermittent or reproducable? |
Intermittent. I cannot produce the issue locally. Though, it may be a specific command that someone globally is running, I tried 3 of 4 different types that called that object, none produced the error locally. |
Well, my primary suggestion is to look hard for an |
Query as the key does not work itself. There are also variables and operation name so key is actually should be a tuple (query, vars, operation). |
Sure it does. I'm not caching results. I'm only caching the query-to-AST conversion and validation rule processing -- neither of which are based on the operation name or variables. Note that validation rules can inspect variables, but none of the default validation rules do so. Any custom validation rule that inspects variables can be executed for each request, after the AST has been cached and it has passed the other validation rules. |
I have a separate caching mechanism that detects specific predefined queries that are requested without variables, and responds with a predefined response which has already been exectued, serialized and gzip/brotli compressed. |
OK. Good.
Wow. Unexpectedly for me. Then it's clear. |
@Shane32 Just a reminder from me to check this since I have an impession that it's not true. @STRATZ-Ken Did you manage to solve your problem? |
I just did a cross-reference search for |
Other rules may check the types of the variables, but that is stored within the document as |
I seem to understand that I confused the validation of types with validation of values. InputFieldsAndArgumentsOfCorrectLength indeed the only rule that validates variable values. The remaining rules validates the document, and the actual values of variables can cause problems only when executing already validated document. I think I understand my concern now. Look, if (saveInCache && validationResult.IsValid)
{
_documentCache[options.Query] = document;
} Validation rules can check variables so |
Now tracked in #2390. Still waiting for comments from @STRATZ-Ken about initial problem. |
Currently, I am not having the issue. I am not exactly sure what made it go away. I do believe it has to do with how you call data through your Repo layers with Entity Framework and GraphQL. I really wish I could say more on the topic. |
OK. Closing for now. |
Description
I have a very large GraphQL API server. Upon fixing some issues with a Sentry reporting agent, I am finally getting my errors in Sentry. I recently found a NullReferenceException which is coming with little to know information.
Steps to reproduce
I am not really sure. Due to my logging being broken for so long, I am not sure when this started. I was on the pre-release of 3.0.0, which it occurred. I just upgraded to 3.1.0 and it still occurs.
Environment
IIS
.Net Core 3.1
Entity Framework
WebSockets (GraphQL)
Windows Server 2012 R2.
The text was updated successfully, but these errors were encountered: