Home All Groups Group Topic Archive Search About

How do I stop opportunistic record locking from causing massive de

Author
21 May 2009 6:32 PM
Mark Schroeder
I am using a VB6 application on two workstations to concurrently access a
data file on a server. The exact steps that are happening are in the
following msdn article:
http://msdn.microsoft.com/en-us/library/aa365436(VS.85).aspx in the first
section, which is titled "Level 1 Opportunistic Lock". My problem is that at
Event 10 (in the example) the Write operation is transferring an enormous
amount of data. All my program does is opens the data file for random access
(read and write) and writes a 100 byte structure to record 2 150,000 times
(it's a benchmark program to figure out what is causing the slowdown). At
Event 3, the write takes 2-3 seconds and transfers no data (since, as the
only opened handle, the file is cached onto the workstation). At Event 10,
the same write takes about 60 seconds and transfers through the network
roughly 540 megabytes over the 60 seconds! The only requirement for the
solution is that closing the file before the second workstation opens the
file to write is NOT an option. Both programs need to keep the file open
indefinitely.

Things I have tried:
Changing the access parameters on the open statement.
Writing with a smaller record structure.
Writing a file of different file sizes.

Results were all the same: massive slowdown.

Please help!

Author
21 May 2009 8:16 PM
Schmidt
"Mark Schroeder" <Mark Schroe***@discussions.microsoft.com> schrieb im
Newsbeitrag news:F945E844-C9B9-46CB-A95C-708DB4F02587@microsoft.com...

> Things I have tried:
> Changing the access parameters on the open statement.
> Writing with a smaller record structure.
> Writing a file of different file sizes.
>
> Results were all the same: massive slowdown.

Hmm, seems as if the only solution to avoid these slowdowns
(which are caused by the implementation-specifics of the smb-
protocol and its locking-support-features) would be, to avoid
the smb-protocol. ;-)

Seriously - do you see any chance, that you can install
your own service at the server-host machine? Or is
that maybe a ?nix-machine running Samba?

And (since you said, you are using your own Record-Format
against "flat-files") - could a DB-Server eventually be an
alternative option?

What is the average volume of your typical write- and read-requests
(Record-Count * Record-ByteSize) in both directions?
What would be the max-timing you could live with for such
typical requests?
And how fast is your Network there (Gigabit or yet 100MBit)?

Olaf
Author
22 May 2009 5:25 PM
H-Man
On Thu, 21 May 2009 11:32:01 -0700, Mark Schroeder wrote:

Show quoteHide quote
> I am using a VB6 application on two workstations to concurrently access a
> data file on a server. The exact steps that are happening are in the
> following msdn article:
> http://msdn.microsoft.com/en-us/library/aa365436(VS.85).aspx in the first
> section, which is titled "Level 1 Opportunistic Lock". My problem is that at
> Event 10 (in the example) the Write operation is transferring an enormous
> amount of data. All my program does is opens the data file for random access
> (read and write) and writes a 100 byte structure to record 2 150,000 times
> (it's a benchmark program to figure out what is causing the slowdown). At
> Event 3, the write takes 2-3 seconds and transfers no data (since, as the
> only opened handle, the file is cached onto the workstation). At Event 10,
> the same write takes about 60 seconds and transfers through the network
> roughly 540 megabytes over the 60 seconds! The only requirement for the
> solution is that closing the file before the second workstation opens the
> file to write is NOT an option. Both programs need to keep the file open
> indefinitely.
>
> Things I have tried:
> Changing the access parameters on the open statement.
> Writing with a smaller record structure.
> Writing a file of different file sizes.
>
> Results were all the same: massive slowdown.
>
> Please help!

OP Locks can cause a number of problems, including data corruption.

From http://support.microsoft.com/kb/296264;

The location of the client registry entry for opportunistic locking has
changed from the location in Microsoft Windows NT. In later versions of
Windows, you can disable opportunistic locking by setting the following
registry entry to 1:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MRXSmb\Parameters\
OplocksDisabled REG_DWORD 0 or 1
Default: 0 (not disabled)
Note The OplocksDisabled entry configures Windows clients to request or not
to request opportunistic locks on a remote file.

You can also deny the granting of opportunistic locks by setting the
following registry entry to 0:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters
EnableOplocks REG_DWORD 0 or 1
Default: 1 (enabled)
Note The EnableOplocks entry configures Windows-based servers to allow or
to deny opportunistic locks on local files. These servers include
workstations that share files.


--
HK