Knowledgebase
How do I disable write-behind caching to help prevent data corruption?
Posted by Jesse Chieppa on 20 Jun 2012 10:47 AM

How do I disable write-behind caching to help prevent data corruption?



If you are receiving duplicate bookings or corrupted records when working on a Peer to Peer LAN (Local Area Network), then your network may need the following settings to disable 'write behind cache' on the Windows machines on your network.

Disabling write-behind caching

Turning off Write-behind caching is one of the two most important things that you can do to help ensure that your files will not become scrambled by the operating system.

This is especially important when running programs which allow more than one user to access the same disk file data simultaneously or which access a record more than once within a relatively short time period. Word processing programs and spreadsheets generally cannot access a file any faster than the operator can type in relatively long commands directing them to do so. However, database programs, even when used by only one operator on a single workstation, frequently allow several different parts of the program to access the same file, or make repeated accesses to the same file within a very short time.

With "Write-behind Caching" enabled, it would be possible for the Workstation A to get different Guest, Booking or Availability information from Workstation B, resulting in a duplicate booking or corrupted guest record.

Disk Caching programs which are allowed to "hold" data records cannot always recognize that another program, or even another part of the same program needs the updated version of the data. Also, during the time a Disk Caching program is "holding" an updated data record, any momentary power interruption or any error in the system or any application which causes a temporary interruption in processing can cause the updated data record to be irrecoverably lost without any warning or operator notification.

There have been claims that "Write-behind Caching" feature (Microsoft also calls the feature "Lazy Write") improves perfomance. The perfomance improvement was always very, very small: much too small to be noticeable for business applications. And if you are using modern disk drives which contain their own full-track buffer, there will be NO performance improvement. Virtually all PATA, SATA, and USB drives purchased since 2005 have a built-in full-track (or larger) buffer. In any case the recovery time you will spend the first time you experience data corruption due to "Write-Behind Caching" will wipe out at least 10 years of any performance time "savings."

HOW TO TURN WRITE-BEHIND CACHING OFF IN WINDOWS 95/NT/98/ME/2000:

1. From the DeskTop select the "Start" Button.

2. From the menu that appears, select "Settings".

3. From the second menu that appears, select "Control Panel".

4. In the resulting window, double click on "system". This displays the "System Properties" window.

5. In the "System Properties" window, select the "performance" tab.

6. At the bottom of the Performance tab select "File System".

7. In the resulting "File System Properties" window, the "Hard Disk" tab will be displayed. Ensure that the two items shown on this tab are set as follows:

a. "Typical role of this machine:" should be set to "Desktop computer". If it is not, then left click on the down-pointing arrow and select "Desktop computer".

b. "Read-ahead optimization:" should be set to the "full" or right-most position. If it is not, then left-click on the pointer and, holding the left mouse button down, drag the pointer to the "Full" (right-most) position. Then release the mouse button.

c. If you have changed any of the settings on this tab, then left-click the "Apply" button on the bottom of this window to save the changes.

8. You are still in the "File System Properties" window.

a. Left-click on the "Troubleshooting" tab. Ensure that the "Disable write-behind caching for all drives" box has a check mark in it. If this box already has a check mark in it, then Write-behind caching is already turned off. Select "OK" and then "Close" to exit the properties setup windows. You do not have to complete the remaining directions in this section.

b. If "Disable write-behind caching for all drives" does not have a check mark then, place the pointer (cursor) over the box to the left of the appropriate line and left click the mouse. A check mark will appear in the box. If the check mark does not appear then left click on the box until it does. NOTE: DO NOT CHANGE ANY OTHER SETTINGS ON THIS TAB. DOING SO COULD CAUSE MAJOR PROBLEMS WITH YOUR SYSTEM.

c. Left click on "Apply".

d. Left click on "OK". The "File System Properties" window will disappear.

e. Left click on "OK" again. The "File System Properties" window will disappear.

f. Left click on "OK" again. The "System Properties window will disappear.

g. Windows will display a message stating that you must restart your computer before the new settings will take effect and ask if you want to restart the computer now. Select "Yes" to restart the computer now. Write-behind caching is now turned off. Close the "Control Panel" window by left clicking on the"X" in the upper right-hand corner of the window.

HOW TO TURN WRITE-BEHIND CACHING OFF IN WINDOWS XP:

1. From the DeskTop select the "Start" Button.

2. From the menu that appears, select "Settings".

3. From the second menu that appears, select "Control Panel".

4. In the resulting window, double click on "system".

5. In the resulting window, click on the 'Hardware' tab (at the top of the window), then click on the 'Device Manager' button.

6. Expand the 'Disk Drives' icon, then right-click each drive individually:

7. Select Properties.

8. On the 'Policies' tab, UN-check the box labeled 'Enable write caching on the disk.' This turns this dangerous feature off on the selected drive.

Repeat steps 7-8 for each drive in your system. Windows XP does not prompt you to reboot after completing this change.
HOW TO TURN WRITE-BEHIND CACHING OFF IN WINDOWS 7:

1. From the DeskTop select the "Start" Button.

2. On the menu that appears, right-click "Computer" and select "Properties".

3. In the left pane, click "Device Manager."
4. In the list of devices, expand "Disk Drives," right-click on a disk drive, and click "Properties."
5. Click the "Policies" tab and Un-Check "Enable Write Caching on the device." This turns this dangerous feature off on the selected drive

Repeat steps 4-5 for each drive in your system. Windows 7 does not prompt you to reboot after completing this change.

ALL WINDOWS SYSTEMS:

If ANY drives are found to have 'Write Delay Caching' or 'Write Caching' enabled we strongly recommend that you perform the following after changing this setting:

Close all applications and then Restart your system.
Run ScanDisk (START->Programs->Accessories->System Tools->ScanDisk) and allow ScanDisk to fix any problems found (there usually WILL be problems if Write Caching has been used). On Windows XP or Windows 7, run "CHKDSK /F" from a Command prompt instead of running ScanDisk.
Reboot again. At this point, your file system directories should be 'clean' so that your programs should run properly unless the program files have been corrupted. If you suspect that your program files are corrupt, restore your programs by reinstalling them in accordance with the instructions for your program.

Disabling Opportunistic locking is a good idea to do as well.

Disabling Opportunistic locking

'Opportunistic locking' is another issue that seems to affect networked database usage on Windows LANs, and it is an issue with Win 2000 and XP.  Microsoft has a good support article on this: Configuring Opportunistic Locking in Windows 2000 (Q296264) which I would recommend a read of.

If you are having troubles with double-bookings on your LAN after un-setting 'Write-behind cache', we recommend

Client side (BookingCenter client PC):
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MRXSmb\Parameters - OplocksDisabled REG_DWORD 0(default) or 1.  Set to 1 to disable.

Server side  (BookingCenter server PC):
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters - EnableOplocks REG_DWORD 0 or 1(default).  Set to 0 to disable.
Theoretically, I guess you just need to set the server side as it is the one controlling the distribution of the op locks, but do it for both if required.