patternsqlMinor
SQL Profiler Shows Update (EventClass) with No Errors, But Data in Table is Not Changed
Viewed 0 times
updatesqlwithbuteventclassshowsprofilererrorsdatachanged
Problem
I am trying to debug a web app that uses a database and I need a little help. The problem is that part of the code throws a timeout error. I started using
The app is supposed to call an
This is where it gets interesting. By selecting the
Looking at the Profiler trace again, the
Any advice to help me debug and fix this would be appreciated.
SQL Server Profiler to check the communication between the app and the database. (I am not really a database expert and this is a new tool for me).The app is supposed to call an
UPDATE on a specific record. Shortly after, it calls a SELECT on the same record (because it refreshes the screen). I can see both the UPDATE and the SELECT event classes in the Profiler trace. (There are a few other event classes between them). The SELECT is showing with a duration of 30499 and an Error of 2 - Abort. I am guessing this is the source of my timeout error.This is where it gets interesting. By selecting the
EventClass in the Profiler trace, I can see the SQL SELECT statement that is being called. I copied and pasted this into a new query in Management Studio and tried it out. The SELECT statement worked fine and returned the record before my finger left the f5 key. However, the data in the record was the old data. It seems that the previous UPDATE call did not change the record.Looking at the Profiler trace again, the
UPDATE event class shows an Error of 0 - OK. When I select the UPDATE event class and copy the SQL code into Management Studio it runs fine and does update the record. Is anyone able to help me work out what is going on please.- If the
UPDATEstatement is shown in Profiler with no error, then does this mean that it should have updated the database?
- What could be causing the
SELECTstatement to abort (considering that it runs fine when I try it in SQL Server Management Studio)?
- Could problems with the
UPDATEbe causing the record to lock up which stop theSELECTfrom running?
Any advice to help me debug and fix this would be appreciated.
Solution
Managed to fix this problem. Turns out that the data access handler in the application code should have called commit after the
Based on my limited understanding, the access handler (based on Interop.COMSVCSLib) is using a buffer(?) built in to SQL Server. For some reason, I expected this buffer to be external to the database.
Thus
(If someone wants to write a more detailed answer that can help me understand this process better then I will mark it as the answer, since I don't really like answering my own questions).
UPDATE call, but this was missing.Based on my limited understanding, the access handler (based on Interop.COMSVCSLib) is using a buffer(?) built in to SQL Server. For some reason, I expected this buffer to be external to the database.
Thus
SQL Server Profiler was capturing the UPDATE call even though the update was not being committed. When the SELECT was called, presumably SQL Server was still waiting for the update to be committed and so caused the timeout. When the UPDATE failed to be committed then SQL Server caused the data to be thrown away and the old data was preserved.(If someone wants to write a more detailed answer that can help me understand this process better then I will mark it as the answer, since I don't really like answering my own questions).
Context
StackExchange Database Administrators Q#63930, answer score: 3
Revisions (0)
No revisions yet.