Interthread Locking in dbExpress driver for SQL Server

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
martin
Posts: 52
Joined: Mon 07 Nov 2005 09:48

Interthread Locking in dbExpress driver for SQL Server

Post by martin » Mon 11 Jun 2012 20:30

We are currently working on a heavily multithreaded server application which reads BLOBs from the database with 48 workerthreads.

I can see in the windows task manager, that a lot of locking (kernel time) is taking place and I have broken it down, it must happen inside the dbExpress (Driver) code. If I comment out the Open() part of the query, everything works just fine and without any locking.

So our question is: Does the dbExpress driver perform some internal synchronization/locking between threads given that each thread has it's own TSQLConnection and TClientDataset.

AndreyZ

Re: Interthread Locking in dbExpress driver for SQL Server

Post by AndreyZ » Tue 12 Jun 2012 08:30

Hello,

dbExpress drivers don't perform any synchronization or locking between threads. Please note that SQL Server performs locking itself. Please take a look at these articles:
http://msdn.microsoft.com/en-us/library/ms190615.aspx
http://msdn.microsoft.com/en-us/library/ms184286.aspx
By default, dbExpress driver for SQL Server waits infinitely to a command to be executed. That's why if you try to modify the same data from several threads at the same time, these threads will execute modifying commands in the order of the SQL Server logic. You can change the amount of time that dbExpress driver for SQL Server waits for a command to be executed by using the CommandTimeout option. For more information about the CommandTimeout option, please read the dbExpress driver for SQL Server documentation (the Readme.html file).

martin
Posts: 52
Joined: Mon 07 Nov 2005 09:48

Re: Interthread Locking in dbExpress driver for SQL Server

Post by martin » Tue 12 Jun 2012 08:45

Hi,

Thanks for the reply. But I'm not talking about any SQL Server locking (like row-/,pagelevel locking etc.) but kernel locking that is visible in the task manager when locking at my process. This must happen inside the dbExpress Code.

Are there any special memory allocations you are peforming (e.g. VirtualAllocEx) that would circumvent any 3th party memory manager installed by the host application ?

AndreyZ

Re: Interthread Locking in dbExpress driver for SQL Server

Post by AndreyZ » Wed 13 Jun 2012 15:02

Our dbExpress driver for SQL Server doesn't perform threads locking. Please check if such problem occurs using the standard driver for SQL Server. If yes, it means that dbExpress interface performs threads locking. In this case we cannot influence such dbExpress interface behaviour. If there is no such problem with the standard driver for SQL Server, please try creating a small sample that demonstrates the problem and send it to andreyz*devart*com . Also, please specify the following:
- the exact version of dbExpress driver for SQL Server;
- the exact version of your IDE.

Post Reply