PRB: Updated Data Delayed by Five (5) Millliseconds in Jet 3.xID: Q153046
|
When two users are trying to gain access to the same Access database using Jet 3.x, there is a delay before data modified by one user becomes visible to the other user even if the code re-queries the database.
In order to improve performance, Microsoft Jet version 3.x uses threads to
process read-ahead and write-behind caches asynchronously. Jet 3.0 defines
a key in the registry that determines the delay before the internal cache
is refreshed.
The PageTimeout property specifies the length of time, in milliseconds,
between when data is placed in an internal cache and when it is checked to
be potentially invalidated. Jet 3.x has a default value for the PageTimeout
property of five (5) seconds, which means that the shared data will be
refreshed after no more than five (5) milliseconds.
To ensure that the data is being written out to the disk, set PageTimeout
to a value that is appropriate for your system and wait at least that
amount of time before checking for the updated data.
Note that setting the value of PageTimeout too low may adversely affect
system performance.
There are two techniques for setting the PageTimeout value:
This behavior is by design.
There are two factors involved in determining when updated data becomes
visible to another user: the data must be written to the database and the
updated data must become visible to the other user. The PageTimeout
property addresses only the second issue; it specifies when the updated
data becomes visible to another user after it has been written to the
database.
The simplest way to ensure that the data is written to the database is to
wrap the update in a transaction. The issue of when updated data is written
to a database is affected by:
Q153491 PRB: Jet 3.0 UserCommitSync & ImplicitCommitSync Values Wrong
#include <winreg.h>
int SetPageTimeoutInSystemRegistry( )
{
HKEY hkey = HKEY_LOCAL_MACHINE;
HKEY hResult;
char szSubKey[]=_T( "Software\\Microsoft\\Jet\\3.0\\Engines\\Jet" );
char szValue[]=_T( "PageTimeout" );
char szClass[]=_T( "" );
DWORD TimeOut = 20; // set to desired timeout value, in milliseconds
LONG lRetVal;
DWORD dwDisp;
// If key doesn't exist, it will be created.
lRetVal = RegCreateKeyEx( hkey, szSubKey, 0, szClass,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, 0, &hResult, &dwDisp );
// check the return value
switch( lRetVal )
{
case ERROR_SUCCESS:
case ERROR_FILE_NOT_FOUND:
if( ERROR_SUCCESS != RegSetValueEx( hResult, szValue, 0,
REG_DWORD, (const unsigned char *)&TimeOut, 4 ) )
{
::MessageBox( NULL, _T("error"), _T("error"), MB_OK );
return 0;
}
break;
// default is error condition
default:
::MessageBox( NULL, _T("error"), _T("error"), MB_OK );
break;
} // end of switch
// Must close the key.
if( ERROR_SUCCESS != RegCloseKey ( hResult ) )
{
::MessageBox( NULL, _T("error"), _T("error"), MB_OK );
return 0;
}
// Success!
return 1;
}
Microsoft Jet Database Engine Programmer's Guide.
Additional query words: 4.00 4.10
Keywords : kbprg kbusage kbDAO kbDatabase kbMFC kbODBC kbVC kbprb
Version : winnt:4.0,4.1
Platform : winnt
Issue type : kbprb
Last Reviewed: July 29, 1999