Adaptive apply

Adaptive apply processing manages data conflicts that can arise while writing changes to target databases.

Adaptive apply processing is the default apply type for a replication mapping. If you choose to override the default and use standard apply, replication for the subscription stops when an error is encountered.

Example: A record insertion is replicated and a database record with a matching key is found that already exists in the target database
  • With standard apply processing, this situation results in an error. In this case, a message is written to the log and the replication process stops and returns an error condition.
  • With adaptive apply processing, this situation does not result in an error. In this case, a message is written to the log, the insert operation for the current change is skipped, and replication continues with the next change.

Adaptive apply is necessary in exceptional cases where your replication environment processes the same unit of recovery (UOR) more than once. Reprocessed UORs occur only during restart processing, when a parallel subscription is catching up to real-time processing after an immediate stop or system failure.

When you reprocess a UOR, apply processing can encounter data inconsistencies that generate errors:
  • Missing records
  • Missing parent segments
  • Missing target segments
  • Target segments that contain data that does not match before image data

Conflict handling

In most situations, adaptive apply processing discards changes that generate errors due to data inconsistencies:
  • Insert (ISRT) processing encounters a duplicate segment, cannot locate the correct parent under which to insert, or cannot locate the correct target segment
  • Delete (DLET) processing or update (REPL) processing cannot locate the correct parent or target segment
  • Delete (DLET) processing or update (REPL) processing encounters a mismatch between the before image data and the data in the target segment

If adaptive apply processing encounters a status code for a condition other than one of those listed above, replication stops for the subscription.

Warning: When a conflict is detected while processing an insert, update, or delete operation the target database generally does not get updated when the inconsistency is detected. Partial target modifications might occur if the source application performed a path update operation and a conflict is detected for a child segment since apply processing updates each segment in a separate operation.

An exception to this general rule exists when you are replicating subset pointer updates, a segment with subset pointers has a sequence field, and an application uses a get call to modify or set the subset pointer. Because the target of the operation has a unique sequence field, the apply processing generates a qualified SSA to retrieve the segment and perform the subset pointer operations in a single call. When the call completes the data in the target segment image is compared against the source which can result in the detection of a conflict. But at that point the target subset pointer updates already occurred and since adaptive apply is enabled the inconsistency is ignored.

Exception: When replication is restarted for a subscription, changes can be applied by using adaptive apply processing regardless of the apply type setting for the replication mappings. Adaptive apply processing occurs for any UOR that existed during the parallel apply window that existed at restart.

The target server prevents target database corruption if completed UOR tracking is active and DONEUORS tracking information exists for a subscription. As UORs are received from the source server during the parallel apply window, the target server simply discards any UOR that exists on the DONEUORS list since it has already been applied at the target.

Conflict reporting

For standard apply, the first conflict encountered is reported as an error. A summary error message is written to the event log. Hexadecimal dumps of the appropriate records and record images involved in the conflict are written to the diagnostic log.

For adaptive apply, conflicts are reported as informational messages and written to the event log based on the value of the CONFLICTRPTLVL configuration parameter.

When a subscription is restarted after an immediate stop or system failure, adaptive apply is temporarily in effect for all replication mappings within a subscription until all UORs in an unknown state are applied, regardless of the apply type setting for a replication mapping.

Parallel apply and restart processing

To preserve data integrity and maintain the match between source and target databases, Data Replication for IMS applies changes to a given record in the correct order during normal operations. However, an immediate stop or a system failure can result in unprocessed changes on the source server that fail to replicate, which can lead to processing the same changes twice.

For example, say that your replication environment is processing six sequential UORs (U1 to U6) when replication stops:

U1

U2

U3

U4

U5

(update RA)

U6

(delete RA)

  restart point      

In this example, the UORs in bold (U1, U2, U5, and U6) have dependencies because they update the same record. In addition, U5 updates Record A and U6 deletes Record A. U3 is a long UOR, and for this reason Data Replication for IMS applies the UORs in bold but fails to apply U3 and U4 before replication stops.

Because the apply server sets a new restart time after applying the last contiguous change (U2), processing begins with U3 when the subscription restarts. Consistent with restart processing behavior, adaptive apply is in effect until the target server writes U6, which is the most recent change that completed before replication stopped.

When the target server tries to reprocess U5, the record is missing because U6 already deleted it. Adaptive apply handles the conflict by discarding the update. When the target server reprocesses U6, it also discards the delete.

In summary, adaptive apply processing discards conflicting changes on the assumption that they are a result of previous Data Replication for IMS processing. Adaptive apply discards other types of changes for similar reasons:

  • Changes to missing segments
  • Changes where the before image data does not match the data in the target segment