473,503 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tricky Record Locking Problems

I have a problem with record locking / blocking within an application.
The app is quite straight forward. Written in Delphi 5 using BDE to
access a SQL 7 database (Win2K server).

Every so often the users (when they bother to tell me) find that the
application locks up and they are unable to work. No errors are
produced (error trapping in the app is good). They 'shout round' to
each other and get someone to exit the data entry screen. This seems
to free up the locking/blocking issue.

There are about 50,000 records in the table (script below) and it is
accessed through a simple query (script below). All users will access
this in the same way. I'm assuming that a new record is being edited
when the problem occurs, but this shouldn't cause locking/blocking
until it gets committed (right ?).

The problem is tracking down the source of this and finding the
pattern which I can work back from. I've used Erland's aba_lockinfo
script (a few months back admittedly so will re-visit this), but
nothing obvious is jumping out at me.

No other tables should be in use at this point.

Any suggestions ?

Thanks

Ryan

/* Code for query component - users navigate to the record they need
to edit
there could be 15,000 records showing as outstanding - perhaps this
is the area that I need to re-visit so that less records can be edited
? */

SELECT *

FROM
PostReceived

WHERE
ToDelete = 0 AND
Completed <> 1

ORDER BY
PostID

/* Table in question */

if exists (select * from sysobjects where id =
object_id(N'[dbo].[PostReceived]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
drop table [dbo].[PostReceived]
GO

CREATE TABLE [dbo].[PostReceived] (
[PostID] [int] IDENTITY (1, 1) NOT NULL ,
[Type] [varchar] (100) NULL ,
[ClientsName] [varchar] (100) NULL ,
[DateReceived] [datetime] NULL ,
[EnteredBy] [varchar] (100) NULL ,
[AssignedTo] [varchar] (100) NULL ,
[DateAssignedTo] [datetime] NULL ,
[Adviser] [varchar] (100) NULL ,
[TargetDate] [datetime] NULL ,
[CompletionDate] [datetime] NULL ,
[Completed] [bit] NULL ,
[KeyAccount] [varchar] (100) NULL ,
[Notes] [text] NULL ,
[Specific1] [varchar] (20) NULL ,
[Specific2] [varchar] (20) NULL ,
[Specific3] [varchar] (20) NULL ,
[Specific4] [varchar] (20) NULL ,
[Specific5] [varchar] (20) NULL ,
[ToDelete] [bit] NULL ,
[EnterUser] [varchar] (20) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
Jul 20 '05 #1
3 5109
Ryan (ry********@hotmail.com) writes:
I have a problem with record locking / blocking within an application.
The app is quite straight forward. Written in Delphi 5 using BDE to
access a SQL 7 database (Win2K server).

Every so often the users (when they bother to tell me) find that the
application locks up and they are unable to work. No errors are
produced (error trapping in the app is good). They 'shout round' to
each other and get someone to exit the data entry screen. This seems
to free up the locking/blocking issue.

There are about 50,000 records in the table (script below) and it is
accessed through a simple query (script below). All users will access
this in the same way. I'm assuming that a new record is being edited
when the problem occurs, but this shouldn't cause locking/blocking
until it gets committed (right ?).
It depends on how Delphi handles the data. I don't know what access
methods Delphi uses, so I will talk in terms of ADO that I know at least
something about. Say that your application would get the data into a
recordset with a client-side cursor. In this case you should not get any
locking problems, because data is read once and then released.

But if you wuuld use a server-side cursor with perssimistic locking,
you would get blocking all over the place, because each user would
hold locks ons his data set, and no one else would be able to update.

There are a couple of variations on this theme. If the application
fails to commit an update, so the user clings to the locks, then
no user will be able to get any rows, because with the WHERE clause
of your query, it seems that a table scan is the only way to get the
rows, and thus SQL Server has to access the updated and locked rows
to see if they qualify. This particular situation you could overcome
with a READPAST hint. However, since we don't really know what is
causing the problem, it is difficult to tell.
The problem is tracking down the source of this and finding the
pattern which I can work back from. I've used Erland's aba_lockinfo
script (a few months back admittedly so will re-visit this), but
nothing obvious is jumping out at me.


Running it in a blocking situation could give some information of
what is going on. But in the end knowledge about what the Delphi
does is necessary.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
Sorry, ignore it. I spotted the problem. I left a copy of the table
open which I should have closed when the user entered that form. It
then locks the table, hence my problem.

Ryan
Jul 20 '05 #3
Erland, thanks for the reply, I managed to post mine before I saw
yours. The aba_lockinfo SP really helped me (once I re-visited it). I
used it whilst trying various things out with while debugging the app
and eventually found one particular way of getting into the data entry
screen wasn't doing what I wanted it to do (under a specific
scenario). By using your sp, I watched what happened on the server and
found where the problem was. I could reliably re-create the problem. I
fixed it and tested with the sp, and it seems to have done the trick.
Once again, thanks.
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1667
by: jv | last post by:
Hello, I'm using A2K and am trying to make sure that my program only locks one record at a time and I don't seem to have any luck getting that to happen. In the database options, I've selected...
2
1672
by: pj | last post by:
We are experiencing record locking errors which don't make sense. O/S :Windows 2003 Server running Terminal Services Access 2003 SP1 Front end copied to each user folder. 4 users adding...
22
18762
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4....
5
8810
by: payffl | last post by:
My users are running Access '03. They have a database with a form that allows them to enter new records. Frequently they will move to a new record and not enter any information. This prevents...
0
4085
by: Cindy Huyser | last post by:
I have an Access 2000 database behind a threaded Java application that that can have have concurrent access to the same table (but not the same record). The database is set up for shared access...
3
1858
by: David C. Barber | last post by:
How do you lock a record in SQL Server from ASP 2? I need to read the record, allow the user to edit it, and then have them click Save and rewrite it. Obviously I don't want anyone else getting...
6
2663
by: jsacrey | last post by:
Hello everybody, I've got a bit of a situation that I could use some guidance with if possible. I work for an auditing firm where my users audit electronic shipping data for customers to see if...
0
1978
by: Andy_Khosravi | last post by:
I'm having issues with updates being blocked due to some sort of record locking issue. The error does not occur consistently, so I've had a hard time nailing it down. It does happen enough to cause...
1
2215
by: Paul H | last post by:
I have an Employees table with the following fields: EmployeeID SupervisorID Fred Bob Bob John Bob Mary Bill Bill I have created a self join in...
0
7202
marktang
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,...
0
7086
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...
0
7330
jinu1996
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...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
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...
0
3167
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...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.