We have created a website based on the Kigg project on CodePlex:
http://kigg.codeplex.com/releases/view/28200
Basically, the code uses the repository template, with the implementation of the repository based on Linq-To-Sql. The full source code can be found at the link above.
The site has been working for some time, and about a year ago we started getting errors, for example:
- There is already an open DataReader associated with this Command, which should be closed first.
- ExecuteNonQuery requires an open and accessible connection. The status of the current connection is closed.
These are the closest examples of errors that I can find based on my memory. These errors began to occur when site traffic began. After I hit my head against the wall, I realized that the problem is inherited in Linq-To-Sql and how we use the same connection to invoke several commands in the same web request. p>
As a rule, I discovered MARS (several active result sets) and added this to the data context connection string and, like magic, all my errors went away.
Now, fast forward about 1 year, and site traffic has increased significantly. Every week or so, I get an error message in SQL Server that reads:
A serious error occurred in the current team. Results, if any, should be discarded.
Immediately after this error, I get from hundreds to thousands of InvalidCastException errors in the error logs. Basically, this error appears for every Linq-To-Sql data context call. Only after restarting the web server are these errors resolved.
I read a post on the Micosoft support site that described my problem (minus InvalidCastException errors) and stating that the solution is that if I am going to use MARS, I should also use Asncronous Processing = True. I tried this, but that also did not solve my problem.
Not quite sure where to go from here. I hope someone here has seen and solved this problem before.
sql-server linq-to-sql mars kigg
Swisher Sweet Feb 19 '13 at 21:43 2013-02-19 21:43
source share