Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 What used to be ONE transaction

Author  Topic 

MrRenn
Starting Member

8 Posts

Posted - 2009-05-11 : 08:38:51
Hi

I have an MFC application with explicit transaction handling. Within the transactions are CRecordSets used. ODBC is used to connect to a server (MSSQL 2000). The application is a COM-dll.

Example:
Begin transaction
Save record A
Updates
Save record B
Commit transaction

This must be executed in ONE transaction and the software has worked like this for years but now something strange is happening. In one installation every save and update come in different transactions that result in lock-timeouts. Then rollback fails to rollback everything, cause it's no longer one transaction.


Any ideas of what can cause this?



tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-11 : 11:06:16
How do you know it's happening in more than one transaction, how did you see that information? Have you viewed what is getting passed to SQL Server by running SQL Profiler?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-11 : 11:07:37
By the way, your pseudocode isn't using proper error handling. You need to check the value of @@ERROR after every DML operation in a transaction in order to determine whether or not to proceed or rollback.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

MrRenn
Starting Member

8 Posts

Posted - 2009-05-11 : 11:28:03
I've used the SQL Profiler on two separated installations and compared the results. On the working installation everything is executed in a single transaction. In the failing one it's not.

I don't get any errors or warnings but I do get a "look:timeout". After 15 seconds I get an "Attention" and then the code continues to execute. This happens twice and causes a timeout for the whole transaction at about 30 seconds into the whole transaction. If I could just change one of these two timeout values the transaction would probably pass through.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-11 : 11:39:58
There is no way to change a timeout value from within SQL Server. Timeouts are set at the application layer.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

MrRenn
Starting Member

8 Posts

Posted - 2009-05-11 : 11:55:27
The query timeout is set to 400 seconds in the code. It is something else that makes the transaction end at 30 seconds.
Go to Top of Page

MrRenn
Starting Member

8 Posts

Posted - 2009-05-12 : 02:27:10
The problem surfaced once before and then disappeared after some days. I really don't think it's the SQL Server, I think it's something else.
Go to Top of Page

MrRenn
Starting Member

8 Posts

Posted - 2009-05-13 : 05:17:59
It seems like this is not a problem with the application or the database. It must be something higher up. Can any restrictions from .NET or IIS effect the type of connection I get to the database in the COM application?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-05-13 : 13:40:39
I am not aware of anything like that affecting the connection.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-13 : 14:35:57
Why are you suddenlt getting locks?


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

MrRenn
Starting Member

8 Posts

Posted - 2009-05-14 : 13:44:05
quote:
Originally posted by Peso

Why are you suddenlt getting locks?


E 12°55'05.63"
N 56°04'39.26"




You tell me! :) The same COM application in production for a year and suddenly it fails, not randomly but everytime at the exact same place. I don't know why my explicit transaction disappeared.
Go to Top of Page

MrRenn
Starting Member

8 Posts

Posted - 2009-05-14 : 13:52:01
What's even more strange is that I got it to work when I directly loaded the DLL from a test application. But it fails when the webservice loads the DLL using COM from the .NET application.

I've used "Process explorer" to see if it's te right DLL that is loaded and the DLL is located in the right directory. I'm confused.
Go to Top of Page

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2009-05-17 : 03:39:20
Sounds like someone has introduced a rogue 'commit' into a SP or something. Maybe logging?
Or if COM+ is managing your transactions then someone could have flicked some switches.

Have you checked your change control?
Go to Top of Page

MrRenn
Starting Member

8 Posts

Posted - 2009-05-18 : 08:09:10
I suspected the logging. The application logs into one table from triggers fired on update and insert on multiple tables. But then again, it used to work.

I haven't found anything in the event viewer that indicates any strange changes. I've deleted the COM interface and then registered it again with what I think is the correct parameters, without any luck.

I know that there were changes made to the network outside this application environment but I can't see how that would affect the IIS and the other applications inside the closed network. Is it possible that some permissions are in some way inherited from this network outside causing MSDTC, connection pooling or something else to not work properly?
Go to Top of Page
   

- Advertisement -