We have a problem with transaction management/concurrency when using ADO to update a database on a SQL 2005 database. We have a test application, to isolate and demonstrate the problem, where a VB6 client application gets a recordset and performs a simple update within the scope of an ADO transaction. When running multiple instances of the test application, failure is very quickly reached with a 'Transaction (Process ID x) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction'
We have tried the following:
1. Testing on SQL 2000, which generally seems to work successfully.
2. The hotfix at http://support.microso ft.com/kb/953948, which accurately describes the issue, but does not seem to solve it.
3. Changing the isolation level of the connection (and consequently the transaction) to read uncommitted. Currently, the isolation level is not explicitly set and assumes the default setting of read committed. This solves the issue, but we are not happy to make this change because it has data integrity implications.
To recreate the issue, do the following:
1. Create a new SQL database on an instance of SQL 2005, consisting of one very simple table.
USE [master]
GO
CREATE DATABASE [TestConcurrency]
GO
USE [TestConcurrency]
GO
CREATE TABLE NextTableIdenti ty (Id integer IDENTITY(1,1),T ableName varchar(255),Ne xtIdentity decimal(21,0) null)
create unique clustered index NextTableIdenti ty_TableName_In dex on NextTableIdenti ty (TableName)
create unique index NextTableIdenti ty_Id_Index on NextTableIdenti ty (Id)
GO
insert into NextTableIdenti ty (TableName,Next Identity) values ('Ccs_Q_Section s',1)
go
2. Create a new VB6 exe, with a button and the following code:
Option Explicit
Private mobjConn As ADODB.Connectio n
Private Sub Command1_Click( )
Dim lngIndex As Long
Label1.Caption = "Started "
DoEvents
For lngIndex = 0 To 300
GetID
Next
Label1.Caption = "Finished"
DoEvents
End Sub
Private Sub GetID()
Dim objRS As ADODB.Recordset
Dim lngID As Long
OpenDB
mobjConn.BeginT rans
Set objRS = ExecuteSQL("SEL ECT NextIdentity, TableName, ID FROM NextTableIdenti ty WHERE TableName = 'Ccs_Q_Sections '")
objRS(0).Value = objRS(0).Value + 1
lngID = objRS(0).Value
objRS.Update
mobjConn.Commit Trans
objRS.Close
CloseDB
Label1.Caption = "(Select) Table : Ccs_Q_Sections ... ID updated <" & lngID & "> successfully."
End Sub
Private Sub OpenDB()
Set mobjConn = New Connection
With mobjConn
.ConnectionStri ng = Me.ConnectionSt ring.Text
.ConnectionTime out = 10000
.CommandTimeout = 10000
.CursorLocation = ADODB.CursorLoc ationEnum.adUse Server
.Open
End With
End Sub
Private Sub CloseDB()
With mobjConn
'.CommitTrans()
.Close
End With
Set mobjConn = Nothing
End Sub
Private Function ExecuteSQL(ByVa l pstrSQL As String) As ADODB.Recordset
Dim objRecordset As ADODB.Recordset
Set objRecordset = New ADODB.Recordset
With objRecordset
.CursorLocation = ADODB.CursorLoc ationEnum.adUse Server
.Open pstrSQL, mobjConn, ADODB.CursorTyp eEnum.adOpenSta tic, _
ADODB.LockTypeE num.adLockPessi mistic, -1
Set ExecuteSQL = objRecordset
End With
End Function
Private Sub Form_Load()
Me.ConnectionSt ring.Text = "PROVIDER=SQLOL EDB;Data Source=myserver name;Initial Catalog='TestCo ncurrency';Loca le Identifier=1033 ;User ID='sa';Passwor d='mypassword'"
End Sub
3. Compile the VB6 exe.
4. Start up 2 or 3 copies of the exe. Quickly press the command button on the form to start the processing within each instance.
5. Very quickly, the following error occurs:
'Transaction (Process ID x) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction'
0 2030 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Anita |
last post by:
Hi All,
Can multiple updates on one table using single
query generate deadlock ?
For example, at the same time, there are 2 users
run 2 queries as follows :
User1 runs :
update tab1 set tab1.v = tab1.v + 1
from tab1 inner join tab2 on tab1.no = tab2.no
|
by: drdeadpan |
last post by:
I asked the DBA to start the Server with options -T1204 and -T3605 and
here's what I get. I need help deciphering this. This happens when we
have 5 usrs performing concurrent actions and for the life of me cannot
decipher this. WHat is a Node, what is the branch ?
WHat are the ECIDs. I cannot even easily find out what process blocks
what. Does anyone have any experience with these. ANy and all help will
be appreaciated. I have posted the...
|
by: Matik |
last post by:
Hello,
I've very often a deadlock problem.
The deadlock is generated always in the same way, by one application
calling in DB two sp's (application has two threads).
This is an error message from trace:
2005-11-29 08:20:29.97 spid4 ResType:LockOwner Stype:'OR' Mode: S
SPID:1160 ECID:0 Ec:(0x296F9540) Value:0x3
|
by: Joe Weinstein |
last post by:
Hi.
create table joe(c1 integer not null, c2 integer not null)
Two sessions:
Session 1:
BEGIN TRAN
insert into joe (c1,c2) values (1,2)
|
by: jw_guildford |
last post by:
My SQL Server has kicked out a deadlocked process, which should only be
running a select statement, though there is another select on one of
the tables in the WHERE clause (see code below). Can anyone tell me
whether this is possible, or is it that my system, which is re-using
connections, is trying to complete an earlier statement? I've looked
through the system and think I'm committing all transactions.
The query I'm running...
| |
by: rajayan |
last post by:
rajayan wrote:
--
rajayan
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------
|
by: Dragan |
last post by:
Hi,
We're working in VS 2005, Team edition, if it makes any difference at
all (should be up-to-date and all that, but could not guarantee it is
100%).
We've implemented a simple generic wrapper parser under C++/CLI. It's
a basic project created under Visual C++/CLR - Class Library - and
it's pretty much what it is, just one /clr compiled class, fully CLR,
no C++ native types or processing, nothing, just managed all the way.
The reason...
|
by: Wolfing |
last post by:
I have a table that every 30 minutes needs to be repopulated from
another table that is recreated from scratch just before.
What I did was this:
CREATE PROCEDURE BatchUpdProducts AS
begin transaction
delete products
insert into products
select * from productsTemp
commit transaction
GO
|
by: DennBen |
last post by:
I am doing an update to set a field value = anothe field value (in the
same table) where it is not supplied. I'm handling this in the
trigger, but am getting deadlocks.
Do you see anything wrong with this that would cause deadlocking?
ALTER TRIGGER
ON .
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |