What is Opportunistic Locking?
Opportunistic locking (oplocks) is a Windows-specific mechanism for client/server databases to allow multiple processes to lock the same file while allowing for local (client) data caching to improve performance over Windows networks. Unfortunately, the default setting of the oplocks mechanism that enhances the performance of one type of database (client/server) also introduces data integrity issues for other database types (file system/ISAM).
Microsoft's documentation states "An opportunistic lock (also called an oplock) is a lock placed by a client on a file residing on a server. In most cases, a client requests an oplock so it can cache data locally, thus reducing network traffic and improving apparent response time. Oplocks are used by network redirectors on clients with remote servers, as well as by client applications on local servers" and "Oplocks are requests from the client to the server. From the point of view of the client, they are opportunistic. In other words, the server grants such locks whenever other factors make the locks possible."
You can read more about oplocks in Microsoft's documentation. Please see the Resources section below for more information.
What is Read Caching?
Read caching, sometimes referred to as read-ahead caching, is a feature of oplocks. It is a technique used to speed network access to data files. It involves caching data on clients rather than on servers when possible. The effect of local caching is that it allows multiple write operations on the same region of a file to be combined into one write operation across the network. Local caching reduces network traffic because the data is written once. Such caching improves the apparent response time of applications because the applications do not wait for the data to be sent across the network to the server.
Problems with read caching usually occur if something unforeseen happens, such as a workstation crash, where data is not properly flushed from the workstation, which can lead to data corruption.
Microsoft's documentation states that 'Under extreme conditions, some multiuser database applications that use a common data store over a network connection on a file server may experience transactional integrity issues or corruption of the database files and/or indexes stored on the server. This typically applies to some so-called "ISAMstyle", or "record oriented" multiuser database applications, not to a client/server relational system like SQL Server' and 'A hazard of local caching is that written data only has as much integrity as the client itself for as long as the data is cached on the client. In general, locally cached data should be flushed to the server as soon as possible.'
You can read more about read caching in Microsoft's documentation.
What Are SMB2 and SMB3?
SMB2 and SMB3 are the second and third generations, respectively, of server message block (SMB) communication on Windows networks. SMB2 was introduced in Windows Vista, 7 and Windows Server 2008 to enable faster communication between computers that are running Windows Vista, 7 and Windows Server 2008. SMB3 was introduced in Windows 8 and Windows Server 2012. SMB1, also called "traditional SMB", is still supported in current Windows versions for backward compatibility.
Disabling Oplocks on Windows Client PCs
To disable oplocks on a Windows client PC (a Windows PC that accesses an embedded database table hosted on
another PC), change or add the following DWord Registry value:
• HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MRXSmb\ParametersOplocksDisabled = 1
Disabling Oplocks on Windows Servers
To disable oplocks on a Windows server (a Windows PC that hosts an embedded database table accessed from another
PC), change or add the following DWord Registry value:
• HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\ParametersEnableOplocks = 0
Disabling Oplocks on SMB2 and SMB3
Oplocks cannot be turned off for SMB2 and SMB3. You can disable SMB2 and SMB3 themselves, how to do so is
documented by Microsoft in Knowledge Base article 2696547.
According to that article, SMB2 and SMB3 can be disabled on Windows operating systems that support these.
To disable SMB2 and SMB3 on a Windows Vista, 7, 8, Server 2008 or Server 2012 PC hosting embedded database
tables, change or add the following DWord Registry value:
• HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters SMB2 = 0
Once SMB2 and SMB3 are disabled, SMB1 should be re-enabled to be used again and the methods described above
applied to disable oplocks for SMB1.
To re-enable SMB1 on a Windows Vista, 7, 8, Server 2008 or Server 2012 PC hosting embedded database tables,
change or add the following DWord Registry value:
• HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters SMB1 = 1
To disable oplocks on a Windows client PC (a Windows PC that accesses an embedded database table hosted on
another PC), change or add the following DWord Registry value:
• HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MRXSmb\ParametersOplocksDisabled = 1
Disabling Oplocks on Windows Servers
To disable oplocks on a Windows server (a Windows PC that hosts an embedded database table accessed from another
PC), change or add the following DWord Registry value:
• HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\ParametersEnableOplocks = 0
Disabling Oplocks on SMB2 and SMB3
Oplocks cannot be turned off for SMB2 and SMB3. You can disable SMB2 and SMB3 themselves, how to do so is
documented by Microsoft in Knowledge Base article 2696547.
According to that article, SMB2 and SMB3 can be disabled on Windows operating systems that support these.
To disable SMB2 and SMB3 on a Windows Vista, 7, 8, Server 2008 or Server 2012 PC hosting embedded database
tables, change or add the following DWord Registry value:
• HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters SMB2 = 0
Once SMB2 and SMB3 are disabled, SMB1 should be re-enabled to be used again and the methods described above
applied to disable oplocks for SMB1.
To re-enable SMB1 on a Windows Vista, 7, 8, Server 2008 or Server 2012 PC hosting embedded database tables,
change or add the following DWord Registry value:
• HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters SMB1 = 1
The attached SMB2Fix.reg will fix both the server and workstation.
In Windows 10 you'll need to make sure SMB 1.0/CIFS File Sharing Support is supported by turning the windows feature on.
This video was very helpful
https://www.youtube.com/watch?v=5bIcJluf-0Q
I just came across a windows 7 machine that couldn't Thinstuff logon to the server(Simmons-1903) even though it was visible in explorer. I made the user a member of the "remote desktop user" group and it started working.