Need expert guidance on debugging a multi-threaded ODBC/S2K application

Need expert guidance on debugging a multi-threaded ODBC/S2K application

Post by Ed Fai » Wed, 25 Sep 2002 12:06:33



Hi,
I am seeing some unusual failures in a very multithreaded app that uses ODBC
to write into a Sql 2000 database.  I'm in bad need of some expert guidance
in debugging.  I'm not asking for anybody to debug my code, as much as I am
asking for general strategies on *how* to debug it.

This C++ application runs as a service and uses Win32 threads, and is
running on a Dual-CPU server. I haven't tested it yet on a single processor.
The code Prepares a handful of SQL statements and then each thread uses
SQLExec to execute the prepared statements which write into the database.  I
use Win32 mutexes around the parameters and results of each SQL command so
that the threads don't interfere with one another.

The issue I'm seeing is that the application will run fine for tens of
thousands of database insertions, but will consistently "hang" before
execution completes.  The application generates no error messages and does
not exit, but it goes to nearly 100% CPU utilization and appears in general
to stop doing it's work.

When it goes into this state I can attach the de*, and I can find the
thread that is executing.  If I step through this thread  I can see that it
is in SQLSRV32.DLL.

What I can't tell is why SQLSRV32 is doing this, and I can't get any hints
where in my code it's originating.

I've tried running with various versions of the SQL Server ODBC Driver;
currently I'm using 2000.81.9001.00.  The results varied somewhat as I tried
various versions -- they all failed in this manner, but the version above
seems to stay up the longest (sometimes for 20 minutes).

So, my questions are, how can I tell what SQL command the runaway thread is
trying to execute?  How can I tell what SQLSVR is trying to do in such a
tight loop?  And finally, if you have any wizardly advice for writing such
an application, please share them with me.

I should add that the code uses the following connection attribute:
SQLSetConnectAttr(myDbcHandle,SQL_ATTR_CONCURRENCY,(void *)
SQL_CONCUR_VALUES,0)

And, I'm using W2K Server w/SP2 applied.

Thanks for any insight you might offer...

ed

 
 
 

1. Need expert guidance debugging a multi-threaded ODBC/S2K application

Hi,
I am seeing some unusual failures in a very multithreaded app that uses ODBC
to write into a Sql 2000 database.  I'm in bad need of some expert guidance
in debugging.  I'm not asking for anybody to debug my code, as much as I am
asking for general strategies on *how* to debug it.

This C++ application runs as a service and uses Win32 threads, and is
running on a Dual-CPU server. I haven't tested it yet on a single processor.
The code Prepares a handful of SQL commands and then each thread uses
SQLExec to execute the prepared commands which write into the database.  I
use Win32 mutexes around the parameters and results of each SQL command so
that the threads don't interfere with one another.

The issue I'm seeing is that the application will run fine for tens of
thousands of database insertions, but will consistently "hang" before
execution completes.  The application generates no error messages and does
not exit, but it goes to nearly 100% CPU utilization and appears in general
to stop doing it's work.

When it goes into this state I can attach the debugger, and I can find the
thread that is executing.  If I step through this thread  I can see that it
is in SQLSRV32.DLL.

What I can't tell is why SQLSRV32 is doing this, and I can't get any hints
where in my code it's originating.

I've tried running with various versions of the SQL Server ODBC Driver;
currently I'm using 2000.81.9001.00.  The results varied mewhat as I tried
various versions -- they all failed in this manner, but the version above
seems to stay up the longest (sometimes for 20 minutes).

So, my questions are, how can I tell what SQL command the runaway thread is
trying to execute?  How can I tell what SQLSVR is trying to do in such a
tight loop?  And finally, if you have any advice for writing such an
application, please share them with me.

I should add that the code uses the following connection attribute:
SQLSetConnectAttr(myDbcHandle,SQL_ATTR_CONCURRENCY,(void *)
SQL_CONCUR_VALUES,0)

And I'm using W2K Server w/SP2 applied.

Thanks for any insight you might offer...

ed

2. Replication with a DB of another brand (SQLBase)

3. Multi-thread capability and non-threaded applications ...

4. Largest DB Size in Production Usage

5. Help needed with multi-threaded Open Server application

6. VBA Help

7. Need guidance from the experts.

8. variable problems....

9. - Multi-org expert/Oracle Applications Analyst - Portland, Oregon jw005849

10. Multi-Threaded Application accessing diff Databases under diff instances

11. Multi Threaded Application

12. Multi-threaded server application and Informix

13. CDatabase objects in a multi-threaded application