![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am running a C++ VS20008 service application using SQLNCLI client. I have added Mars=Yes in the connection string. The server is SQLExpress 2005. This is currently running on a development machine with Windows XP Pro SP3. The client has about 5 threads which issue quiries on an ongoing bases about every 10 secs. There is no other database activity from any other clients. After sitting for about an hour the following error gets returned by the SQLNCLI: "ComObject Error: Code = 80004005, Code meaning = Unspecified error, Source = Microsoft SQL Native Client, Description = Connection is busy with results for another command ." Is this a SQLExpress issue only? I thought Mars=Yes would resolve this. What is causing this and how can I fix it? Thanks Morris -- Thanks Morris |
#3
| |||
| |||
|
|
Is this a SQLExpress issue only? |
|
I am running a C++ VS20008 service application using SQLNCLI client. I have added Mars=Yes in the connection string. The server is SQLExpress 2005. This is currently running on a development machine with Windows XP Pro SP3. The client has about 5 threads which issue quiries on an ongoing bases about every 10 secs. There is no other database activity from any other clients. After sitting for about an hour the following error gets returned by the SQLNCLI: "ComObject Error: Code = 80004005, Code meaning = Unspecified error, Source = Microsoft SQL Native Client, Description = Connection is busy with results for another command ." Is this a SQLExpress issue only? I thought Mars=Yes would resolve this. What is causing this and how can I fix it? Thanks Morris -- Thanks Morris |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Morris Is this a SQLExpress issue only? Coul be... Have you tried running the app on Dev. Edition? BTW I hope your SQL Server has at least SP3 installed on "Morris Neuman" <Morris (AT) online (DOT) nospam> wrote in message news CAF59D9-112B-4269-8BB8-C290CA336750 (AT) microsoft (DOT) com...I am running a C++ VS20008 service application using SQLNCLI client. I have added Mars=Yes in the connection string. The server is SQLExpress 2005. This is currently running on a development machine with Windows XP Pro SP3. The client has about 5 threads which issue quiries on an ongoing bases about every 10 secs. There is no other database activity from any other clients. After sitting for about an hour the following error gets returned by the SQLNCLI: "ComObject Error: Code = 80004005, Code meaning = Unspecified error, Source = Microsoft SQL Native Client, Description = Connection is busy with results for another command ." Is this a SQLExpress issue only? I thought Mars=Yes would resolve this. What is causing this and how can I fix it? Thanks Morris -- Thanks Morris . |
#6
| |||
| |||
|
|
Hi Morris, Did you use MARS with some T-SQL statements with the security context switch EXECUTE AS/REVERT etc? If so, this is the cause. Currently this is by design a limitation on MARS though not documented officially. To resolve this issue, please create a separate connection for executing those statements with EXECUTE AS/REVERT. Best regards, Charles Wang . |
#7
| |||
| |||
|
|
What else could cause that error msg? |
|
How many connections can I open against SQL Express? |
|
If it is better to open a new connection for each thread in the app I'll do that. |
#8
| |||
| |||
|
|
Morris Neuman (Morris (AT) online (DOT) nospam) writes: What else could cause that error msg? Without seeing your code, it's hard to tell. But let me say that I agree entirely with Bill. MARS is not a feature I would recommend. It is difficult to understand, and there are plenty of limitations. How many connections can I open against SQL Express? Theoretically 32767. If it is better to open a new connection for each thread in the app I'll do that. Absolutely! It was not clear from your original post whether you actually had a single connection shared between threads, but if you have, that is a design that is which seems wrong to me. Why do you have multiple threads? To do things in parallel, I presume. But what happens if you have a single connection? 1) You have a semaphore to control this common resource. Which of course defeats the purpose of threads. (Unless the datbase connection is just a very small part of the whole plot.) 2) You use MARS. Then you don't need the semaphore. But execution in SQL Server on the different requests are interleaved, not parallel, so you still get serialisation. You just show the semaphore down to SQL Server. The scenario where MARS makes (somewhat) sense is when you read rows from a table, and you want update the rows as you pass along. Without MARS you would have to read all rows first, which could be problematic if there are very many rows. But using MARS to share a single connection between threads? No way. -- Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se Links for SQL Server Books Online: SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx . |
#9
| |||
| |||
|
|
The basic design is over 10 years old when a database connection was an expensive resource so it was shared amongst al the threads. I'm more a telephony software expert than SQL expert so I wasn't sure that a connection for each thread was a best practice for the situation. In that vein is it just as well to create and destroy a connection for each query? Or should each thread have a private connection for the duration of execution? |
|
Do you know if this issue is just for SQL EXPRESS or I will have the same result with all SQL versions? |
|
Thanks again for your response and the links you supplied. |
#10
| |||
| |||
|
|
Morris Neuman (Morris (AT) online (DOT) nospam) writes: The basic design is over 10 years old when a database connection was an expensive resource so it was shared amongst al the threads. I'm more a telephony software expert than SQL expert so I wasn't sure that a connection for each thread was a best practice for the situation. In that vein is it just as well to create and destroy a connection for each query? Or should each thread have a private connection for the duration of execution? It's very common to write applications where you connect, run a query and disconnect. While this may seem expensive, it does not have to be, because of something known as connection pooling. When you disconnect, the API lingers to the connection for 60 seconds, and if you request for a new connection with the same connection properties within those 60 seconds, a connection will be reused from the pool if necessary. If each thread keeps on connection during its entire lifetime, it can indeed be a little expensive, and take up some memory both client-side and server-side. Do you know if this issue is just for SQL EXPRESS or I will have the same result with all SQL versions? I don't know exactly what you did, but from what you described, I see nothing that would be specific to Express, so, yes, I think you would see the same no matter which edition of SQL Server you would use. Thanks again for your response and the links you supplied. The links are just part of my signature, and not related to this question. -- Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se Links for SQL Server Books Online: SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx |
![]() |
| Thread Tools | |
| Display Modes | |
| |