Manage your shared message data set (SMDS) environment

If you select shared message data sets to offload large messages then we must also be aware of the information that IBM MQ uses to manage these data sets and the commands used to work with this information. Use this topic to understand how to manage shared message data sets.


SMDS objects

The properties and status of each shared message data set are tracked in a shared SMDS object which can be updated through any queue manager in the queue sharing group.

There is one shared message data set for each queue manager that can access each coupling facility application structure. The shared message data set is identified by the owning queue manager name, specified using the SMDS keyword, and by the application structure name, specified using the CFSTRUCT keyword. Note: When defining SMDS data sets for a structure, we must have one for each queue manager.

The SMDS object is stored in an array (with one entry per queue manager in the group) which forms an extension of the corresponding CFSTRUCT object stored in Db2 .

There is no command to DEFINE or DELETE the SMDS object because it is created or deleted as part of the CFSTRUCT object, but there is a command to ALTER it to change settings for an individual owning queue manager.

For further information on SMDS commands, see SMDS related commands


SMDSCONN information

It is possible for a shared message data set to be in a normal state, but for one or more queue managers to be unable to connect to it, for example because of a problem with a security definition or with direct access device connectivity. It is therefore necessary for each queue manager to keep track of connection status, and availability information for each shared message data set, indicating for example whether it can currently connect to it, and if not why not.

The SMDSCONN information represents a queue manager connection to a shared message data set. As for the shared message data set itself, it is identified by the queue manager which owns the shared message data set (as specified on the SMDS keyword for the shared object itself) combined with the CFSTRUCT name.

There is no parameter to identify the connecting queue manager because commands addressed to a specific queue manager can only refer to SMDSCONN information for that same queue manager.

The SMDSCONN information entries are maintained in main storage in the owning queue manager, and are re-created when the queue manager is restarted. However, if a connection from an individual queue manager has been explicitly stopped, this information is also stored as a flag in a connection array in the corresponding CFSTRUCT or SMDS object, so that it persists across a queue manager restart.


Status and availability information

Status information indicates the state of a resource or connection (for example, whether it is not yet being used, is in normal use or is in need of recovery). It is usually described using the STATUS keyword. The possible values depend on the type of object.

Status information is normally updated automatically, for example when an error is detected while using the resource or connection. However, in some cases a command can also be used to update the status, to allow for cases when it is not possible for a queue manager to determine the correct status automatically.

Availability information indicates whether the resource or connection can be used, and is usually primarily determined by the status information. For the resource or connection types used in shared message data set support, three levels of availability are implemented:

    Available
    This means that the resource is available to be used normally. This does not necessarily mean that it is in use at present (which can be determined instead from the STATUS value). For a data set, if it requires restart processing, this allows the owning queue manager to open it, but other queue managers must wait until the data set is back in the ACTIVE state.

    Unavailable because of error
    This means that the resource has been made unavailable automatically because of an error and is not expected to be available again until some form of repair or recovery processing has been performed. However, attempts to make it available again are permitted without operator intervention. Such an attempt can also be triggered by a command to mark the resource as enabled, or a command which changes the status in such a way as to indicate that recovery processing has been completed.

    The reason that the resource has been made unavailable is normally obvious from the related STATUS value, but in some cases there may be other reasons to make the resource unavailable, in which case a separate REASON value is provided to indicate the reason.

    Unavailable because of operator command
    This means that access to the resource has been explicitly disabled by a command. It can only be made available by using a command to enable it again.

    SMDS availability

    For the shared SMDS object, the availability is described by the ACCESS keyword, with the possible values ENABLED, SUSPENDED and DISABLED.

    The availability can be updated using a RESET SMDS command for the relevant shared object from any queue manager in the group to set ACCESS(ENABLED) or ACCESS(DISABLED).

    If the availability was previously ACCESS(SUSPENDED), changing it to ACCESS(ENABLED) will trigger a new attempt to use the shared message data set, but if the previous error is still present, the availability will be reset back to ACCESS(SUSPENDED).

    SMDSCONN availability

    For a local SMDSCONN information entry, the availability is described by the AVAIL keyword, with the possible values NORMAL, ERROR or STOPPED. The availability can be updated using a START SMDSCONN or STOP SMDSCONN command addressed to a specific queue manager to enable or disable its connection.

    If the availability was previously AVAIL(ERROR), changing it to AVAIL(NORMAL) will trigger a new attempt to use the shared message data set, but if the previous error is still present, the availability will be reset back to AVAIL(ERROR).


Shared message data set shared status and availability

The availability of each shared message data set is managed within the group using shared status information, which can be displayed using the DISPLAY CFSTATUS command with TYPE(SMDS). This displays status information for each queue manager that has activated a data set for each structure. Each data set can be in one of the following states:

    NOTFOUND
    This means that the corresponding data set has not yet been activated. This status only appears when a specific queue manager is specified, as data sets which have not been activated are skipped when all queue managers are selected.

    NEW
    The data set is being opened and initialized for the first time, ready to be made active.

    ACTIVE
    This means that the data set is fully available and should be allocated and opened by all active queue managers for the structure.

    FAILED
    This means the data set is not available at all (except for recovery processing) and must be closed and deallocated by all queue managers.

    INRECOVER
    This means that media recovery (using RECOVER CFSTRUCT) is in progress for this data set.

    RECOVERED
    This indicates that a command has been issued to switch a failed data set back to the active state, but further restart processing is required which is not yet complete, so the data set can only be opened by the owning queue manager for restart processing.

    EMPTY
    The data set contains no messages. The data set is put into this state if it is closed normally by the owning queue manager, at a time when it does not contain any messages. It can also be put into EMPTY state when the previous data set contents are to be discarded because the application structure has been emptied (using RECOVER CFSTRUCT with TYPE PURGE or, for a nonrecoverable structure only, by deleting the previous instance of the structure). The next time the data set is opened by its owning queue manager, the space map is reset to empty, and the status is changed to ACTIVE. As the previous data set contents are no longer required, a data set in this state can be replaced with a newly allocated data set, for example to change the space allocation or move it to another volume.

The command output includes the date and time at which recovery logging was enabled, if any, and the date and time at which the data set failed, if it is not currently active. A shared message data set can be put into a FAILED state either by a RESET SMDS command or automatically when any of the following types of error are detected:

  • The data set cannot be allocated or opened by the owning queue manager.
  • Validation of the data set header fails after it has been successfully opened by any queue manager.
  • A permanent I/O error occurs when the owning queue manager is reading or writing data.
  • A permanent I/O error occurs when another queue manager is reading data from a data set which had successfully completed open processing and validation.

When a data set is in the FAILED or INRECOVER state, it not available for normal use, so if the availability state is ACCESS(ENABLED) it is changed to ACCESS(SUSPENDED).

If a data set has been put into the the FAILED state but no media recovery is required, for example because the data was still valid but the storage device was temporarily offline, then the RESET SMDS command can be used to request changing the status directly to the RECOVERED state.

When the data set enters the RECOVERED state, either on completion of recovery processing or as a result of the RESET SMDS command, then it is ready to be used again once restart processing has been completed. If it was in the ACCESS(SUSPENDED) state, it is automatically switched back to the ACCESS(ENABLED) state, which allows the owning queue manager to perform restart processing. When restart processing completes, the state is changed to ACTIVE and all other queue managers can then connect to the data set again.


Shared message data set connection status and availability

Each queue manager maintains local status and availability information for its connection to each shared message data set owned by itself and by other queue managers in the group. This information can be displayed using the DISPLAY SMDSCONN command.

If it is unable to access a shared message data set in the ACTIVE state which belongs to another queue manager it flags the connection as being unavailable from its own point of view.

If the error definitely indicates a problem with the data set itself, the queue manager also automatically changes the shared status to indicate that the data set is now in a FAILED state. However, if the error could be caused by an environmental problem, such as not being authorized to open the data set, the queue manager issues error messages and treats the data set as being unavailable, but it does not modify the shared data set status. If the environmental error turns out to be a problem with the data set anyway (for example it has been allocated on a device which cannot be accessed by some of the queue managers) then an operator can use the RESET SMDS command specifying STATUS(FAILED) to allow the data set to be recovered or repaired as necessary.

If a connection to a shared message data set could not be established but the data set appears to be valid, a new attempt to use it can be triggered by issuing a START SMDSCONN command for the owning queue manager.

If there is an operational need to terminate the connection between a specific queue manager and a data set temporarily, but the data set itself is not damaged, then the data set can be closed and deallocated using the STOP SMDSCONN command. If the data set is in use, the queue manager will close it normally (although any requests for data in that data set will be rejected with a return code). If it is the owned data set, the queue manager will save the space map during CLOSE processing, avoiding the need for restart processing.

If a data set needs to be taken out of service temporarily from all queue managers (for example to move it) but is not damaged, then it is best to use STOP SMDSCONN for the relevant data set with the option CMDSCOPE(*) to stop the queue managers using it first, as this will avoid the need for restart processing when the data set is brought back into service. In contrast, if the data set is marked as FAILED this tells queue managers that they must stop using it immediately, which means that the space map will not be saved and will need to be rebuilt by restart processing.

Access to any shared message data sets previously in the ACCESS(SUSPENDED) state will be retried if the queue manager is restarted.


Shared message data set recovery logging

Persistent shared messages are logged for media recovery purposes. This means that the messages can be recovered after any failure of coupling facility structures or shared message data sets, provided that the recovery logs are still intact. Persistent messages can also be re-created from the recovery logs at another site for disaster recovery purposes.

When the message data is written to a shared message data set, each block written to the data set is logged separately followed by the message entry (including the data map) as written to the coupling facility. The recovery process always recovers the coupling facility structure, but it does not need to recover individual shared message data sets except when the data set status is FAILED, or when the status is ACTIVE but the data set header record is no longer valid, indicating that the data set has been re-created. A data set is not selected for recovery if its status is ACTIVE and the data set header is still valid, nor if its status is EMPTY, indicating that no messages were stored in it at the time of the failure.


Shared message data set backups

When BACKUP CFSTRUCT is used to make a backup of the shared messages in an application structure, any data for persistent messages stored in shared message data sets is backed up at the same time, as for persistent shared messages previously stored in DB.


Shared message data set recovery

If a shared message data set is corrupted or lost, then it needs to be put into the FAILED state to stop the queue managers from using it until it has been repaired. This normally happens automatically, but can also be done using the RESET SMDS command specifying STATUS(FAILED).

If the shared message data set contained any persistent messages, these can be recovered using the RECOVER CFSTRUCT command. This command first restores any persistent message data for that shared message data set from the most recent BACKUP CFSTRUCT command, then applies all logged changes since that time. If no BACKUP CFSTRUCT command has been performed since the time that the data set was first activated, it is reset to empty then all changes since activation are applied.

If the CFSTRUCT contents and all of the shared message data sets are unavailable, for example in a disaster recovery situation, they can all be recovered in a single RECOVER CFSTRUCT command.

If a shared message data set is damaged but recovery was not active for the CFSTRUCT, or the log containing the latest BACKUP CFSTRUCT is unavailable or unusable, then the messages offloaded to that data set cannot be recovered. In this case, the RECOVER CFSTRUCT command with the parameter TYPE(PURGE) can be used to mark the shared message data set as empty and delete any messages from the structure which had data stored in that data set.

When the RECOVER CFSTRUCT command is issued, the shared message data set status is changed from FAILED to INRECOVER. If recovery completes successfully, the status is automatically changed to RECOVERED, otherwise it changes back to FAILED.

When the data set is changed to the RECOVERED state, this tells the owning queue manager that it can now try to open the data set and perform restart processing.


Shared message data set recovery and syncpoints

The shared message data set recovery process reapplies the changes for all complete log records up to the end of the log, regardless of syncpoints.

If changes were made within syncpoint, restart or recovery processing for the CFSTRUCT may result in backing out of uncommitted requests, so some of the recovered changes may not actually be used, but there is no harm in recovering them anyway.

It is also possible that an uncommitted MQPUT message may have been written to the structure but the corresponding data may not have been written to the data set or the log (as I/O completion is only forced at the start of syncpoint processing). This is harmless because restart processing will back out the message entry in the structure, so the fact that it refers to unrecovered data does not matter.


Shared message data set restart processing

If a queue manager connection to a CFSTRUCT terminates normally, the queue manager writes out the free block space map for each shared message data set to a checkpoint area within the data set, just before the data set is closed. The space map can then be read in again at connection restart time, provided that neither the CFSTRUCT nor the shared message data set require any recovery processing before the next restart.

However, if a queue manager terminates abnormally, or the structure or data set require any recovery processing, then additional processing is required to rebuild the space map dynamically when the queue manager connection to the structure is restarted.

Provided that the data set itself did not need to be recovered, queue manager restart simply scans the current contents of the structure to locate references to message data owned by the current queue manager, and marks the relevant data blocks as owned in the space map. Other queue managers can continue to use the structure and read the data owned by the restarting queue manager while the space map is being rebuilt.


Shared message data set restart after recovery

If a shared message data set had to be recovered from a backup, then all nonpersistent messages stored in the data set will have been lost, and if the data set was recovered using TYPE(PURGE) then all messages stored in the data set will have been lost. Until recovery has completed, the data set will be marked as FAILED or INRECOVER so any attempt to read one of the affected messages from another queue manager returns an error code indicating that the data set is temporarily unavailable.

When the data set has been recovered, the status is changed to RECOVERED, which allows the owning queue manager to open it for restart processing, but the data set remains unavailable to other queue managers. Queue manager restart scans the structure to rebuild the space map for any remaining messages. The scan also checks for messages for which the data has been lost, and deletes them from the structure (or if necessary flags them as lost, to be deleted later).

The data set status is automatically changed from RECOVERED to ACTIVE when this restart scan completes, at which point other queue managers can start using it again.


Shared message data set usage information

The DISPLAY USAGE command now also shows information about shared message data set space and buffer pool usage for any currently open shared message data sets. This information is displayed if either the new option TYPE(SMDS) or the existing option TYPE(ALL) is specified.


Shared message data performance and capacity considerations

    Monitor data set usage

    The current percentage full of each owned shared message data set can be displayed by the DISPLAY USAGE command with the option TYPE(SMDS).

    The queue manager will normally automatically expand a shared message data set when it reaches 90% full, provided that the option DSEXPAND(YES) is in effect for the SMDS definition. This applies when either the SMDS option is set to DSEXPAND(YES) or the SMDS option is set to DSEXPAND(DEFAULT) and the CFSTRUCT default option is set to DSEXPAND(YES).

    If the expansion attempt fails because no secondary allocation size was specified when the data set was created (giving message IEC070I with reason code 203 ) the queue manager repeats the expansion request using an override secondary allocation of approximately 20% of the current size.

    When a data set is expanded, the new data set extents are formatted as part of the expansion processing, which can take tens of seconds, or even minutes for very large extents. The new space becomes available for use after formatting is complete and the catalog has been updated to show the new high used control interval.

    If new messages are being created very rapidly, it is possible for the existing data set to become full before expansion processing completes. In this case, any request which could not allocate space is temporarily suspended until the expansion attempt completes and the new space becomes available for use. If the expansion was successful the request is retried automatically.

    If an expansion attempt fails, because of a lack of available space or because the maximum extents have already been reached, a message is issued giving the reason for the failure, then the override option for the affected SMDS is automatically altered to DSEXPAND(NO) to prevent further expansion attempts. In this case, there is a risk that the data set may become full, in which case further action may be needed as described in Data set becomes full.

    Monitor application structure usage

    The usage level of an application structure can be displayed using the MVS DISPLAY XCF,STRUCTURE command specifying the full name of the application structure (including the queue sharing group prefix). The IXC360I response message shows current usage of elements and entries.

    When the structure usage exceeds the FULLTHRESHOLD value specified in the CFRM policy, the system issues message IXC585E and may perform automatic ALTER actions if specified, which may either alter the entry to element ratio or increase the structure size.

    Optimising buffer pool sizes

    Each buffer in a shared buffer pool is used to read or write a contiguous range of pages for one message of up to the logical block size. If the message spills over into further blocks, each range of pages in a separate block requires a separate buffer.

    Buffers containing message data after a write or read operation are retained in storage and reused using a least-recently-used (LRU) cache scheme so that a request to read the same data again shortly afterwards will not need to go to disk. This provides a significant optimization when shared messages are written and then read back soon afterwards by applications running on the same system. If messages owned by another queue manager are browsed for selection purposes then retrieved, this also avoids the need to reread the message from disk.

    This means that the number of buffers required for each application structure is one for each concurrent API request which reads or writes large messages for that application structure plus some number of additional buffers which will be used to save recently accessed data in order to optimize subsequent read accesses.

    For shared buffer pools, if there are insufficient buffers, API requests will simply wait if a buffer is not immediately available. However, this situation should be avoided as it can cause significantly degraded performance.

    The statistics from the DISPLAY USAGE command for shared buffer pools show whether there have been any buffer waits within the current statistics interval, and also shows the lowest number of free buffers (or a negative value indicating the maximum number of threads which waited for a buffer at any time), the number of buffers which have saved data, and the percentage of the times that a buffer request has successfully found saved data on the LRU chain ( LRU hits ) instead of having to read it ( LRU misses ) 1 .

    • If there have been any waits, the number of buffers should be increased.
    • If there are many unused buffers, the number of buffers may be reduced to make more storage available in the region for other purposes.
    • If there are many buffers containing saved data but the proportion of reads which were hits against that saved data is very small, the number of buffers may be reduced if the storage could be better used for other purposes. The number of buffers should not however be reduced by more than the lowest number of free buffers, as that could trigger waits, and it should preferably be high enough that the lowest free buffer count is normally well above zero.


Delete shared message data sets

The DELETE CFSTRUCT command (which is only allowed when all shared queues in the structure are empty and closed) does not delete the shared message data sets themselves, but they can be deleted in the usual way after this command has completed. If the same data set is to be reused as a shared message data set, it must be reformatted first to reset it to the empty state.


Exception situations for shared message data sets

There are a number of exception situations which can occur during normal use, even when no software or hardware error is present.

    Data set becomes full

    If a data set becomes full but cannot be expanded, or the expansion attempt fails, applications using the corresponding queue manager to write large messages to the corresponding application structure will receive error 2192, MQRC_STORAGE_MEDIUM_FULL (also known as MQRC_PAGESET_FULL ).

    A data set could become full because of a failure in the application which is supposed to process the data, causing a large backlog of messages to accumulate. If so, expanding the data set any further will only be a temporary solution, and it is important to get the processing application going again as soon as possible.

    If more space can be made available the ALTER SMDS command can then be used to set DSEXPAND(YES) or DSEXPAND(DEFAULT) (assuming that YES has been set or assumed as the DSEXPAND default for the CFSTRUCT definition) to trigger a retry. If the reason for the failure was however that maximum extents had been reached, the new expansion attempt will be rejected with a message and DSEXPAND(NO) will be set again. In this case, the only way to expand it any further is to reallocate it, which involves making it temporarily unavailable, as described next.

    Data set needs to be moved or reallocated

    If a data set needs to be moved or expanded but is otherwise in normal use, it can be taken out of use temporarily to allow it to be moved or reallocated. Any API request which attempts to use the data set while it is unavailable will receive the reason code MQRC_DATA_SET_NOT_AVAILABLE.

    1. Use the RESET SMDS command to mark the data set as ACCESS(DISABLED). This will cause it to be closed normally and deallocated by all currently connected queue managers.
    2. Move or reallocate the data set as necessary, copying the old contents to the newly allocated data set, for example using the Access Method Services (AMS) REPRO command.

      Do not attempt to preformat the new data set before copying the old data into it, as this would result in the copied data being appended to the end of the formatted data set.

    3. Use the RESET SMDS command to mark the data set as ACCESS(ENABLED) again, to bring it back into use.

      If the old contents are smaller than the size of the new data set, the rest of the space will be preformatted automatically when the new data set is opened.

      If the old contents were larger than the size of the new data set then the queue manager has to scan the messages in the coupling facility structure and rebuild the space map to ensure that none of the active data has been lost. If any reference is found to a data block which is outside the new extents, the data set is marked as STATUS(FAILED) and must be repaired by replacing the data set with one of the correct size and either copying the old data set into it again or using RECOVER CFSTRUCT to recover any persistent messages.

    Coupling facility structure is low on space

    If the coupling facility structure is running out of space, causing message IXC585E, it is worth checking whether the offload rules have been set to ensure that the maximum amount of data is being offloaded in this case. If not, the offload rules can be modified using the ALTER CFSTRUCT command.


Error situations for shared message data sets

There are a number of problems to be aware of, which can only be caused by errors and not occur in normal operational situations.

    Owned data set cannot be opened

    If the queue manager which owns a shared message data set cannot allocate it or open it, or the data set attributes are not supported, the queue manager sets an appropriate SMDSCONN status value of ALLOCFAIL or OPENFAIL and sets the SMDSCONN availability to AVAIL(ERROR). It also sets the SMDS availability to ACCESS(SUSPENDED). When the error has been corrected, use the RESET SMDS command to set ACCESS(ENABLED) to trigger a retry, or issue the START SMDSCONN command to the owning queue manager.

    Read-only data set cannot be opened

    If a queue manager cannot allocate or open a shared message data set owned by another queue manager and marked as STATUS(ACTIVE), it assumes that this is probably due to a specific problem with its connection to the data set (represented by the SMDSCONN object) rather than a problem with the data set itself.

    It marks the SMDSCONN as STATUS(ALLOCFAIL) or STATUS(OPENFAIL) as appropriate and marks the SMDSCONN availability as AVAIL(ERROR) to prevent further attempts to use it.

    If the problem can been corrected without affecting the status of the data set itself, use the START SMDSCONN command to trigger a retry.

    If the problem turns out to be a problem with the data set itself, then the RESET SMDS command can be used to mark the data set as STATUS(FAILED) until it it has been recovered. When the data set has been recovered, the action of changing the status back to STATUS(ACTIVE) will cause other queue managers to be notified. If the SMDSCONN is marked as AVAIL(ERROR), it will automatically be changed back to AVAIL(NORMAL) to trigger a new attempt to open the data set.

    Data set header is corrupt

    If the data set was successfully opened but the format of the header information is incorrect, the queue manager closes and deallocates the data set and sets the status set to STATUS(FAILED) and the availability to ACCESS(SUSPENDED). This allows RECOVER CFSTRUCT to be used to recover the contents.

    If the error arose because the data set contained residual data from another use and had not been subsequently preformatted, then preformat the data set and use the RESET SMDS command to change the status to STATUS(RECOVERED).

    Otherwise, the data set must be recovered.

    Data set is unexpectedly empty

    If the queue manager opens a data set which is marked as STATUS(ACTIVE) but finds that it is uninitialized or newly preformatted but otherwise valid, the queue manager closes and deallocates the shared message data set then sets the status to STATUS(FAILED) and the availability to ACCESS(SUSPENDED).

    Data set has permanent I/O errors

    If a data set has permanent I/O errors after successful OPEN processing, it probably needs recovery. The queue manager will mark the data set as STATUS(FAILED) so that all currently connected queue managers will close and deallocate it.

    Data set has recoverable I/O errors

    If there are hardware problems with the data set, it is possible that this might result in recoverable I/O errors which are not reflected back to the queue manager but which cause significant performance degradation, and also indicate a risk of permanent I/O errors in the near future.

    In this case, the data set may be taken off line for recovery by using the RESET SMDS command to mark it as STATUS(FAILED). This will cause it to be closed and deallocated by all queue managers, so for example it could be moved to a new volume before being made available again.

    When a data set is made unavailable in this way, the space map is not saved so the queue manager connection restart processing will need to scan the coupling facility structure to locate messages in the data set and rebuild the space map before the data set can be made available again. As an alternative, if the shared message data set is still usable, it set can be made unavailable more gently by using the RESET SMDS command to mark the data set ACCESS(DISABLED) until it is ready to be made available again.

    Data set contents are incorrect

    The queue manager cannot detect directly that a data set contains incorrect data or is not up to date, for example because a volume including that data set had to be restored from backups. However, it performs integrity checks which make it very unlikely that any such errors could result in incorrect message data being seen by application programs.

    For integrity checking purposes, each message block in the data set is prefixed with a copy of the corresponding coupling facility entry ID, including a unique time stamp, which is checked whenever the message block is read, before the message data is passed to the user program. If the message block prefix does not match the entry ID (and the coupling facility entry was not deleted in the mean time) the message block is assumed to be damaged and unusable.

    If the damaged message was persistent, the data set is marked as STATUS(FAILED) and the structure contents must be recovered using the RECOVER CFSTRUCT command. If the damaged message was non-persistent, there is no way to recover it, so a diagnostic message is issued and the corresponding coupling facility message entry is deleted.

    If no saved space map is available when the data set is opened, it is rebuilt by scanning the coupling facility structure for references to data in the data set. During this scan, the queue manager performs a number of actions:
    1. The queue manager determines the location of the most recent message (if any) currently remaining in the data set.
    2. The queue manager then reads that message from the data set to ensure that the block prefix matches the message entry id

    These actions ensure that the queue manager detects any case where the data set is down-level, and marks the data set as FAILED. This check does however tolerate the case where the data set was restored from a previous copy and either no new messages had been added since then or all messages added since that copy had been subsequently read and deleted. To protect against down-level data in the case where the data set was closed normally, the queue manager performs a number of actions:

    1. The queue manager saves a copy of the space map time stamp in the SMDS object within Db2 when the data set is closed normally.
    2. The queue manager then checks the space map time stamp is the same, when the data set is opened again

    If the time stamp does not match, this suggests that a down-level copy of the data set might have been used, so the queue manager ignores the existing space map and rebuilds it, which will succeed only if no message data was actually lost. Note: These integrity checks do not guarantee to detect a down-level or damaged data set in all theoretically possible cases. For example, they will not detect a case where the start of a message block is valid but the rest of the data has been partly overwritten.


Recovery scenarios for shared message data sets

This section described shared message data set recovery scenarios.

    Data set recovery where no data was lost

    In some cases, the correct contents of a failed data set can be restored without needing actual recovery. One example is where a data set contains residual data from a previous use and has not been preformatted again, which can be fixed by preformatting it. Another case is when a data set has been moved, but there was an error in the process of copying the data across, which can be fixed by copying the data again correctly.

    In such cases, the corrected data set can be made available again by using the RESET SMDS command to set STATUS(RECOVERED). If the availability is currently ACCESS(SUSPENDED) this will automatically set it back to ACCESS(ENABLED).

    When the owning queue manager is notified that the data set has been recovered, it scans the structure contents to reconstruct the space map, then changes the status to STATUS(ACTIVE). The other queue managers can then start reading the data set again.

    Data set recovery with TYPE(NORMAL)

    If the contents of a data set have been lost, but the application structure was defined with RECOVER(YES) and the appropriate recovery logs are available, the RECOVER CFSTRUCT command can be used to recover any persistent messages stored in the structure including persistent message data offloaded to shared message data sets. This command restores the current state using information logged by the BACKUP CFSTRUCT command plus all logged changes to persistent messages since the backup time.

    The RECOVER CFSTRUCT command always recovers all persistent messages in the coupling facility structure together with offloaded message data stored in Db2. For offloaded data stored in shared message data sets, each data set is only selected for recovery processing if it is already marked as STATUS(FAILED) or if it is found to be unexpectedly empty or otherwise invalid when opened by recovery processing. Any shared message data set which is marked as active and which passes the validation checks does not need to be recovered, as the existing message data is already correct, but the header is updated to indicate that any saved space map will need to be rebuilt after recovery.

    Recovery processing is only possible when the structure has been marked as failed, as the complete contents of the structure need to be reconstructed by recovery processing. However, if at least one shared message data set has been marked as failed the RECOVER CFSTRUCT command will automatically mark the structure as failed if necessary to allow recovery processing to proceed.

    Recovery may be performed from any queue manager in the queue sharing group, provided that it has been given write access to the relevant data sets.

    Only persistent messages are backed up and logged, so normal recovery processing will restore all persistent messages, but will cause any non-persistent messages in the structure to be lost.

    When recovery has completed, any data set which was selected for recovery is automatically changed to STATUS(RECOVERED), and if the availability was ACCESS(SUSPENDED) it is changed to ACCESS(ENABLED). The queue manager rebuilds the space map for each data set by scanning the messages in the coupling facility, then marks the data set as STATUS(ACTIVE) so that it can be used again.

    Data set recovery with TYPE(PURGE)

    For a recoverable structure, if the data set contents have been lost, but recovery is not possible for some reason, for example because recovery logs are not available or recovery would take too long, the RECOVER CFSTRUCT command can be used with TYPE(PURGE) to get the structure back to a usable state. This resets the structure to the empty state and marks all of the associated data sets as STATUS(EMPTY).

    Delete the application structure

    If a non-recoverable application structure is deleted using the MVS SETXCF FORCE command, or as a result of structure failure, then the next time the structure is connected, message CSQE028I is issued to say that the structure has been reset and all existing messages have been discarded, and any existing data sets are automatically reset to STATUS(EMPTY) as well. This action makes a non-recoverable structure usable again after loss of data either in the structure or in any of the associated data sets.

    If a recoverable application structure is deleted, it will be treated in the same way as if the structure had failed.

    Data set recovery fails

    If RECOVER CFSTRUCT cannot complete for some reason, for example because a log data set is no longer available, or because the queue manager terminated while recovery was in progress, then any data set for which recovery was at least started will be marked in the header to show that partial recovery has been attempted, and the data set will be left in the STATUS(FAILED) state.

    In this case, the options are to repeat the original recovery request or to recover with TYPE(PURGE) instead, discarding the existing data.

    If an attempt is made to mark the data set as STATUS(RECOVERED) without actually recovering it, then the next time it is opened the queue manager will see that the header indicates incomplete recovery and mark it as STATUS(FAILED) again.

    Off site disaster recovery

    For off site disaster recovery, persistent shared messages can be re-created using only the logs and the Db2 shared objects containing the CFSTRUCT definitions and associated SMDS status information.

    After setting up the Db2 tables containing the definitions, the application structure and the shared message data sets can be set up as empty. When a queue manager connects to them and finds that they are unexpectedly empty, it will mark them as failed, after which a single RECOVER CFSTRUCT command can be used to recover all persistent messages for all affected structures.

Parent topic: Where are shared queue messages held? 1 (Hits / (Hits+Misses))* 100