High CPU use of SqlClient

There was a bug in SqlClient which could cause high CPU use.

The scenario is a SqlClient application sends an attention to Sql Server but receives no acknowledgement from the server because the connection is broken.

The bug lies in the logic of reading server’s response from the wire. We buffer the incoming data from the wire. In the above scenario, we read from the beginning of the buffer over and over when there’s no more data coming from the wire as the connection is shut down. Basically it triggers an infinite loop.

The fix can be downloaded from:

http://support.microsoft.com/?kbid=912731

System.Data.SqlClient.SqlException 3988

Exception Type: System.Data.SqlClient.SqlException
Number: 3988
Message: New transaction is not allowed because there are other threads running in the session

If you have ever seen this type of exception when talking to RTM SQL Server 2005 (but never saw it with the Beta version of the server), it’s likely that you have an open data reader associated with the connection when starting a new transaction.

The change (from Beta to RTM) is by-design. To avoid non-determinate transaction state, the request of a transaction should be the only request when you execute a transaction. In other words, you have to close the reader associated with the connection before starting a new transaction.

Resources

There’re a lot of resources online talking about ADO.NET:

1. Data Access and Storage Developer Center: official Data website at microsoft.com.

2. Data Access Blog: team’s blog site. You may find information interesting from different team members.

3. .NET Framework Data Access and Storage – MSDN Forums: it’s a place where lots of developers are asking questions about ADO.NET and System.Data namespace. Some team mates (including me) are answering questions there. It’s good to get feedback from our customers (developers) and help them. However, please do read the FAQ and announcements before posting a question.

4. Channel 9: MSDN channel 9 on ADO.NET. You might find some interesting videos there.

5. Search engine is always helpful:)

Welcome to Bill Lin’s blog!

It’s not easy for me to start out the first blog entry so I’ll make it succinct. My name is Bill Lin and I’m a developer on the ADO.NET team. As a dev, I’ve worked on the team for 8 months. I currently am working for SqlClient.

Moving forward, topics I expect to talk about include SqlClient and SQL Server. But it’s possible to see things that are not data related:)