Having issue with EF and CSLA under constant high load

Having issue with EF and CSLA under constant high load

Old forum URL: forums.lhotka.net/forums/t/12170.aspx


tikluganguly posted on Wednesday, October 02, 2013

Hi All,

        I am facing a very peculiar problem with EF. We are having an ERP for educational institutes. The application is written using CSLA 3.5, Silverlight 5,WCF and EF 4 with .NET 4.0. And we are using SQL Server 2008. 

 During high usage (say 30 users working at once) the application starts behaving strangely after serveral hours of use. The errors we get are something like these

 

1) "DataPortal.Fetch failed (The specified cast from a materialized 'System.Guid' type to the 
    'System.Int32' type is not valid.)"
2) "DataPortal.Fetch failed (The 'GroupName' property on 'ModuleShellLicense' could not be set 
to a 'DateTime' value. You must set this property to a non-null value of type 'String'. )"

3) "at Csla.Server.ChildDataPortal.Fetch(Type objectType, Boolean hasParameters, Object[] parameters) 
System.InvalidOperationException: The 'ID' property on 'LanguageType' could not be set to a 'Int32' value. 
You must set this property to a non-null value of type 'Guid'. "
4) "at Csla.Server.ChildDataPortal.Fetch(Type objectType, Boolean hasParameters, Object[] parameters)  
System.InvalidOperationException: The 'ID' property on 'TUTN_Invoice' could not be set to a 'Int32' value. 
You must set this property to a non-null value of type 'Guid'. "
5) "at Csla.Server.ChildDataPortal.Fetch(Type objectType, Boolean hasParameters, Object[] parameters) 
System.InvalidOperationException: The specified cast from a materialized 'System.Guid' type to 
the 'System.Int32' type is not valid."

Our objectcontext is enclosed in a using block. and for every fetch we create a new objectcontext. We do 
not get these exception under low load for a long time. But we only get these errors under loads of 30 
users or more who are using the system constantly for atleast 4-5 hrs or more.

The application server is hosted in a quad core xeon server machine with 16 GB ram (We are using two machines one for IIS another for SQL Server). some of the tables like the tables related to grades and attendance have records more than a million each. Also just to let you know we do not have explicit indexes in the foreign key columns in the tables we mentioned (I am not an SQL expert but I think we do needt to add the indexes as well. ).  

I am not sure whom should I start asking for so I started by asking you guys.  I would really appreciate if you can give some hints about what could be causing the error. 

Regards

Tiklu

tikluganguly replied on Wednesday, October 02, 2013

I forgot to mention. SessionState is turned off for the system. And the application is running on its own application pull. The WFC service is configured PerCall

Regards

Tiklu

skagen00 replied on Wednesday, October 02, 2013

Have you monitored memory usage on the IIS machines?

I can't say those errors look familiar to me, but we had some sort of a very slow leak over time in our application - something that requires a kill of the application pool's process every week or two. 

We ended up adding a setting to the application pool to recycle itself after it hit a certain memory threshhold.   It would recycle and not appear to have any effect on users currently logged in - it ended up solving our problem in particular.

Who is to say - but what you talk about - heavy usage over a period of time causing the problem - could be indicative of something funky happening that might be resolvable through an app pool recycling.  Clearly it's not the ideal - ideal is we found what exactly was leaking - but this was an easy remedy with no apparent negative consequence for us.

tikluganguly replied on Thursday, October 03, 2013

Hi skagen00,

             Thank you for your reply. I will try to see if we are having a memory leak. Just to let you know we even thought that the app pool may be getting flooded for some unknown reason and as a quick fix we even set recycling to 2 hrs (I know it is insane.). But it is still not helping much. As you said I will keep an eye on the memory usage of that particular app pool in IIS and keep you posted. 

Regards

Tiklu

Copyright (c) Marimer LLC