By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,795 Members | 1,250 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,795 IT Pros & Developers. It's quick & easy.

Data missing after timeout even though COMMIT has been caled prior to timeout

P: n/a

We are working on a VB.NET application using SQLClient command objects to
post data to the underlying SQL Server 2000 database. The application is
deployed in a multi-user environment with no more than 10 user accessing the
database at any given time. The host server is supporting approximately 4
other active databases. In general, there are approximately 60 active
connections on the server.

The incident we are trying to resolve has happened about 3 times within the
last 2 years. It has also been isolated to one user. The problem has
happened in different areas of the code, so it does not appear to be related
to coding problem. It seems to be more of a client connection problem.

To describe the incident, the user begins entering transactions into the
application. Each wrapped in a SQL Server transaction (BEGIN TRANSACTION
.... COMMIT TRANSACTION). This continues for several hours. Eventually, the
server generates a time-out for some reason. All of the users accessing the
system seem to get the time-out if they are accessing the database at the
same time. All of the users have also been entering transactions into the
system in the same manner as the target user. After reestablishing a
connection with the server, the target user learns that all of the
transactions they have entered over the past few hours are no longer in the
database.

The primary table where the transactions are stored has a related hsitory
table for audit purposes. The history table shows that the transactions
made it to the database, but it does not show the transactions as being
deleted.

I am looking for ideas that may help us debug the problem. It is difficult
to run traces as the problem is so intermitent. If you have experienced a
similar problem, we are interested in hearing your suggestions or solutions.

Jan 26 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Here's a possible reason (not sure it applies to you, of course):

Consider the code:

BEGIN TRAN
UPDATE...
DELETE...
--Now, the DELETE is blocked more than the timeout of the client app, or the user cancels the
query.
-- The transaction will still be open.

So, say now that the code tries this again
BEGIN TRAN
UPDATE...
DELETE...
--Say we have no time-out now
COMMIT TRAN

So, what we had is two BEGIN TRAN and only one COMMIT. I.e., the transaction is still open, because
the client app lost track of this. And then you finally end the app, the connection is terminated
and SQL Server does a rollback. This is easy to handle with some checking against @@TRANCOUNT before
you start a transaction.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Scott Cupstid" <sc******@tampabay.rr.comwrote in message
news:Ok**************@TK2MSFTNGP02.phx.gbl...
>
We are working on a VB.NET application using SQLClient command objects to
post data to the underlying SQL Server 2000 database. The application is
deployed in a multi-user environment with no more than 10 user accessing the
database at any given time. The host server is supporting approximately 4
other active databases. In general, there are approximately 60 active
connections on the server.

The incident we are trying to resolve has happened about 3 times within the
last 2 years. It has also been isolated to one user. The problem has
happened in different areas of the code, so it does not appear to be related
to coding problem. It seems to be more of a client connection problem.

To describe the incident, the user begins entering transactions into the
application. Each wrapped in a SQL Server transaction (BEGIN TRANSACTION
... COMMIT TRANSACTION). This continues for several hours. Eventually, the
server generates a time-out for some reason. All of the users accessing the
system seem to get the time-out if they are accessing the database at the
same time. All of the users have also been entering transactions into the
system in the same manner as the target user. After reestablishing a
connection with the server, the target user learns that all of the
transactions they have entered over the past few hours are no longer in the
database.

The primary table where the transactions are stored has a related hsitory
table for audit purposes. The history table shows that the transactions
made it to the database, but it does not show the transactions as being
deleted.

I am looking for ideas that may help us debug the problem. It is difficult
to run traces as the problem is so intermitent. If you have experienced a
similar problem, we are interested in hearing your suggestions or solutions.
Jan 26 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.