Salesforce

Save Cache option causes 6495 error

« Go Back

Information

 
TitleSave Cache option causes 6495 error
URL NameP57762
Article Number000138993
EnvironmentProduct: Progress
Version: 9.1D, 9.1E
Product: OpenEdge
Version: All supported versions
OS: All supported platforms
Other: -Mxs, SAVE-CACHE
Question/Problem Description
SAVE CACHE statement core dumps in multi user mode.
SAVE CACHE works in single user mode
Save Cache option causes 6495 error
Database crashes with error 6495 when the SAVE CACHE Option is used
Application uses mandatory fields
Steps to Reproduce
Clarifying Information
When the database is enabled for After-Imaging error 6495 is triggered more often
As more Storage Areas are added to the Database structure, error 6495 is triggered more often
Error MessageOut of free shared memory. Use -Mxs to increase. (6495)
SYSTEM ERROR: mtlatch <latch-num>, holding <lock>. (3712)
SYSTEM ERROR: mtlatch 2, holding 0xa0. (3712)
Defect NumberEnhancement OE00115915 / PSC00161855
Enhancement Number
Cause
Mandatory Fields are not part of the calculation for shared memory allocation. The 4GL statement, SAVE CACHE, causes the database manager to dynamically read all mandatory fields into shared memory. The database manager can experience a situation where it is unable to read the mandatory fields into shared memory because of insufficient shared memory space. This is because the number and size of mandatory fields for the database are not considered during the initial shared memory allocation on startup of the database Broker.

If the database has many mandatory fields and the -Mxs argument is not specified, it is possible that all shared memory will be consumed when the mandatory field array is built causing a database crash. Any time a client needs mandatory field information it requests the information from the database engine.  If the mandatory field information for the table in question is not in the shared memory cache the mandatory field list is dynamically added to the cache.  The shared memory must be allocated at this time.  If there is not enough shared memory available the database crashes.

The situation is exacerbated by databases with a large number of Areas as the shared memory required for area definitions may need to be allocated from the extra shared memory (-Mxs) thereby reducing the amount of additional shared memory for use by the mandatory field array.

The situation is exacerbated when the database being enabled for After-Imaging. When AI is enabled the database's shared memory requirements increase, but the memory required for AI is reserved at all times even if AI is not enabled.  
  • If AI is never enabled the reserved memory is available for use as needed, i.e. -Mxs is considered "extra" memory.  
  • If AI is enabled, the memory that was once considered "extra" is utilized by the AI subsystem.
  • If the database has a large number of mandatory fields and -Mxs is not specified and AI is not enabled the shared memory reserved for AI is used by the mandatory field array.  
  • If the database has a large number of mandatory fields and -Mxs is not specified and AI is enabled, the shared memory reserved for AI use is used by AI thus reducing the size of the "extra" shared memory pool for use by the mandatory field array.
  • Excess shared memory is also used by other memory structures such as the Lock Table which allocates +1 Lock entry to start undo-transaction from a Lock Table overflow (915)
Resolution
Enhancement OE00115915  / PSC00161855 was implemented in Progress 9.1E03, OpenEdge 10.1A, 10.0B04, where the initial shared memory for database Storage Areas was increased in order not to rely on excess shared memory.

​However, in all versions, if the database contains mandatory fields the amount of extra shared memory that should be specified when the database is started must be calculated. If enough excess shared memory is allocated up front, the database will not crash. The approximate memory requirements when using mandatory fields is as follows:
  • 480 bytes overhead
  •  48 bytes for each table that contains mandatory field(s)
  •    8 bytes for each mandatory field
These numbers are approximations and have been rounded up to account for the 32 bit and 64 bit datatype sizing differences.  In addition, the sizes may change from release to release.  The total number of bytes calculated must be added to the existing default -Mxs.

Use the following ABL program to determine the number of mandatory fields and the amount to increase -Mxs.  This program will:
  • Calculate the amount of shared memory that should be reserved based on the number of mandatory fields in the database.  
  • The total memory required takes into account a database that is started with a -n (number of users) of 100 or less.  If more than 100 users are required, the numusers program variable should be initialized appropriately.  For further information on how the database broker calculates the default value for -Mxs parameter refer to Article What does the 6495 'Out of free shared memory' error mean?    
 
DEFINE VAR mem AS INTEGER INIT 0  NO-UNDO.
DEFINE VARIABLE  man-file-count AS INTEGER INIT 0 NO-UNDO.
DEFINE VARIABLE man-field-count AS INTEGER INIT 0 NO-UNDO.
DEFINE VARIABLE mxs100 AS INTEGER NO-UNDO.

mxs100 = (16 * 1024) + (100 * 400).
mem = 480.

/*
Process each mandatory field in the _field table. When _file-recid
changes, add in the memory requirements for an additional table. Add
the memory requirements for each field.
*/

FOR EACH _field where _mandatory = yes BREAK BY _file-recid.

        IF FIRST-OF(_file-recid) THEN DO.
            mem = mem + 48.
            man-file-count = man-file-count + 1.
        END.

    man-field-count = man-field-count + 1.
    mem = mem + 8.
END.

DISPLAY "Mandatory tables" man-file-count WITH NO-LABELS 2 col FRAME a.
DISPLAY "Mandatory fields" man-field-count WITH FRAME a.
DISPLAY "Mandatory field array memory required" mem WITH FRAME a.
DISPLAY "Default -Mxs for 100 users " mxs100 WITH FRAME a.
DISPLAY "Total memory required including default -Mxs" (mem + mxs100) WITH FRAME a.
display "-Mxs value including mandatory field array" int(((mem + mxs100) / 1024)) + 1 with frame a.
Workaround
Notes
Keyword Phrase
Last Modified Date11/20/2020 7:23 AM

Powered by