Kbase P126484: How to maintain the schema cache on the client regularly updated?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/22/2007 |
|
Status: Verified
GOAL:
How to maintain the schema cache on the client regularly updated?
GOAL:
How to programmatically maintain the schema cache file on a large number of clients regularly updated?
FACT(s) (Environment):
All Supported Operating Systems
Progress 8.x
Progress 9.x
OpenEdge 10.x
FIX:
When a client initiates database activity, the Progress client reads the database schema from a database file that resides on disk.
After reading the schema from disk the client saves a copy of the database schema (called the schema cache) in its local memory pool.
The time taken to build this schema cache is minimal, but when connections are established across a WAN, or when several clients connect
to the database simultaneously, use of the "-cache" parameter can increase connection performance.
However, there can be several changes that require building a new schema cache file:
- Database schema has changed,
- schema permissions have changed, or
- database dump and load has been performed.
It is possible that one or more of the following errors will appear :
The file <filename> is not a valid local cache file. (823)
CRC error in -cache <filename>. The file has been corrupted. (825)
The time stamp in the database does not match the time stamp in the -cache file: <filename>. (840)
Error while reading -cache file. ret=<return-code> errno=<errno>. (844)
WARNING: The -cache <filename> parameter was used. An error occurred while attempting to read the schema cache from the named file. The schema cache will be read from the database instead. (6126)
In these cases building a new schema cache file is necessary. This task can be a burden especially if a large number of clients have to be updated.
The following code enables to update automatically the local cache file only when errors 823, 825, 840, 844, or 6126 are met.
/* The sample program code that attempts to connect the database */
/* using the cache file and if there are cache related errors */
/* then it re-generates the cache file. */
DEFINE VARIABLE cDbName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cCsh AS CHARACTER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE lCacheProblem AS LOGICAL NO-UNDO.
cDbName = "sports2000".
cCsh = cDbName + ".csh" .
cCsh = SEARCH(cCsh) .
IF cCsh = ? THEN ASSIGN cCsh = "".
ELSE ASSIGN cCsh = "-cache " + cCsh.
IF cCsh = "" THEN lCacheProblem = TRUE.
CONNECT VALUE(cDbName) -H hostname -S servicename -N tcp VALUE(cCsh) NO-ERROR.
IF ERROR-STATUS:NUM-MESSAGES > 1 THEN
DO i = 1 TO ERROR-STATUS:NUM-MESSAGES :
/* We are trapping the errors that have to do with the cache file */
/* being used for this specific connection attempt... */
/* These errors are most probably: */
/* The file <filename> is not a valid local cache file. (823) */
/* CRC error in -cache <filename>. The file has been corrupted. (825) */
/* The time stamp in the database does not match the time stamp in the */
/* -cache file: <filename.>. (840) */
/* Error while reading -cache file. ret=<return-code> errno=<errno>. (844) */
/* WARNING: The -cache <filename> parameter was used. An error */
/* occurred while attempting to read the schema cache from the named file. */
/* The schema cache will be read from the database instead. (6126) */
IF ERROR-STATUS:GET-NUMBER(i) = 823 OR
ERROR-STATUS:GET-NUMBER(i) = 825 OR
ERROR-STATUS:GET-NUMBER(i) = 840 OR
ERROR-STATUS:GET-NUMBER(i) = 844 OR
ERROR-STATUS:GET-NUMBER(i) = 6126 THEN
lCacheProblem = TRUE.
/* If none of the cache related errors where reported, then it might be */
/* a genuine problem with connecting the database so we should log these. */
MESSAGE "Error " ERROR-STATUS:GET-NUMBER(i) ": " ERROR-STATUS:GET-MESSAGE(i) .
END.
IF CONNECTED(cDbName) THEN
DO:
/* If we are connected and there was a problem with the cache file, */
/* then we have to re-generate it ... */
IF lCacheProblem THEN
SAVE CACHE COMPLETE VALUE(cDbName) TO VALUE(cDbName + ".csh") .
/* Else, we are connected and there were no errors with the schema */
/* file so we don't need to generate it, or we were already connected */
/* and received message 1012 so we have already used the -cache file */
/* that was correct, or we are going to re-generate it on the next */
/* connection. */
END.
ELSE MESSAGE "Problem connecting to the database" .
.