Comments (4)
Upgrading the .Net version from 4.5.2 to 4.6.1 in our production environment solved our intermittent IIS app pool crashing issues.
from ef6.
@sglencross can you provide the LINQ query?
Also, can you try setting context.Configuration.UseDatabaseNullSemantics = true
before that particular query? We have had previous reports that the default (UseDatabaseNullSemantics = false
) can cause larger trees that in a very complicated query can cause stack overflow.
from ef6.
Setting this before our query is problematic as we have abstracted our context from the linq operations on the DBSet. The query related to the stack overflow above is spread out across several classes and would be difficult to summarize without changing its behaviour.
We do have a simpler query not related to the stack dump above but has also intermittently crashed our IIS app pool. We suspect it is also having the same kind of issue.
//_dbTerms is a IDbSet<Term> exposed on the context
public IEnumerable<TermModel> Execute(int languageId, Guid clientId)
{
var clientSpecificTerms = _dbTerms.Where(t => t.ClientId == clientId && t.LanguageId == languageId);
var languageFallbackTerms = _dbTerms.Where(t => t.ClientId == null && t.LanguageId == languageId &&
clientSpecificTerms.All(clientTerm => clientTerm.Key != t.Key));
var clientDefaultTerms = _dbTerms.Where(t => t.ClientId == clientId && t.LanguageId == Languages.English.Id &&
clientSpecificTerms.All(clientTerm => clientTerm.Key != t.Key) &&
languageFallbackTerms.All(languageFallback => languageFallback.Key != t.Key));
var defaultTerms = _dbTerms.Where(t => t.LanguageId == Languages.English.Id && t.ClientId == null &&
clientSpecificTerms.All(clientTerm => clientTerm.Key != t.Key) &&
languageFallbackTerms.All(languageFallback => languageFallback.Key != t.Key) &&
clientDefaultTerms.All(clientDefaultTerm => clientDefaultTerm.Key != t.Key));
return clientSpecificTerms.Union(languageFallbackTerms)
.Union(clientDefaultTerms)
.Union(defaultTerms)
.OrderBy(t => t.Key)
.Select(t => new TermModel { Key = t.Key, Value = t.Value })
.ToList();
}
This is the generated SQL
SELECT 1 AS [C1], [Project2].[Key] AS[Key], [Limit1].[Value] AS[Value] FROM
(SELECT[Distinct1].[Key] AS[Key]FROM ( SELECT DISTINCT[Extent1].[Key] AS[Key] FROM[dbo].[Terms] AS[Extent1]
WHERE([Extent1].[LanguageId] IN(@languageId,1))
AND([Extent1].[ClientId] = @clientId OR[Extent1].[ClientId] IS NULL)
) AS[Distinct1]
) AS [Project2]
OUTER APPLY (SELECT TOP (1) [Project3].[Value] AS [Value] FROM
(SELECT CASE WHEN([Extent2].[LanguageId] = @languageId) THEN cast(1 as bit) WHEN([Extent2].[LanguageId] <> @languageId) THEN cast(0 as bit) END AS[C1],
CASE WHEN([Extent2].[ClientId] = @clientId) THEN cast(1 as bit) WHEN(NOT(([Extent2].[ClientId] = @clientId) AND((CASE WHEN([Extent2].[ClientId] IS NULL) THEN cast(1 as bit) ELSE cast(0 as bit) END) = 0))) THEN cast(0 as bit) END AS[C2], [Extent2].[Value] AS[Value]
FROM[dbo].[Terms] AS[Extent2]
WHERE ([Extent2].[LanguageId] IN (@languageId,1))
AND ([Extent2].[ClientId] = @clientId OR[Extent2].[ClientId] IS NULL)
AND (([Project2].[Key] = [Extent2].[Key]) OR(([Project2].[Key] IS NULL)
AND ([Extent2].[Key] IS NULL)))
) AS [Project3]
ORDER BY [Project3].[C1] DESC, [Project3].[C2] DESC) AS[Limit1]
Would changing the UseDatabaseNullSemantics
setting on this query prevent the intermittent crashes happening with this query?
from ef6.
We are currently on .Net 4.5.2 and have been informed that there is a known issue that may be contributing to our crashes. Specifically the CLR issue addressed in this hotfix:
https://support.microsoft.com/en-us/kb/3139544#bookmark-issuesresolve
We are going to move to .Net 4.6.1 in the next week or two which will hopefully solve our issue.
from ef6.
Related Issues (20)
- Visual Studio DB Save Changes HOT 1
- Bulk Insert/Update from C# .Net 4.8 HOT 1
- Package Manager Console doesn't take configuration from project only always compiles with ANY CPU option HOT 1
- add-migrations does not add Migrations folder HOT 1
- Nuget does not pull the dll's HOT 1
- Error when updating code to .NET 8 HOT 3
- After upgrading to the latest version of vs, running DbMigrator reports an error HOT 1
- Add-Migration not recognized after install of Microsoft.EntityFrameworkCore.Tools HOT 1
- To match the data types of columns in the database and in the class HOT 1
- Entity Framework not able to import stored procedures HOT 1
- Entity Framework not importing stored procedures HOT 1
- Thread.CurrentThread.CurrentCulture settings are leaked into the generated SQL causing invalid SQL HOT 7
- Next Release for Microsoft.Data.SqlClient HOT 20
- EF 6.5 release checklist HOT 35
- EntityFramework package initialization error in Package Manager Console HOT 1
- EF6.5 + Azure + ASP.NET MVC + Microsoft.Data.SqlClient ProviderName HOT 6
- Cannot use EF6 with Microsoft.EntityFramework.SqlServer and Microsoft.Data.SqlClient HOT 6
- Documentation for HResult -2146232004 HOT 1
- No app.config override for Microsoft.Data.SqlClient? HOT 2
- EF 6.5.0 RTM NuGet Package BROKEN HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ef6.