Serializing transactions

You might need to serialize the execution of one or more transactions. This typically occurs when the application logic was not designed to deal with concurrency and in cases where the risk of deadlocks is high.

About this task

You must allow serialization only for low-volume transactions because of potential queueing time.

The following methods each have different serialization start and end times:
  • CICS transaction classes. The CICS facility of letting only one transaction execute at a time in a CLASS is useful to serialize the complete transaction.
  • DB2 thread serialization. In cases where the serialization may be limited to an interval from the first SQL call to syncpoint (for terminal-oriented transactions, and nonterminal-oriented transactions if NONTERMREL=YES is defined), you can use your DB2ENTRY specifications to ensure that only one thread of a specific type is created at one time. This technique allows concurrency for the first part of the transaction, and is useful if the first SQL call is not in the beginning of the transaction. Do not use this technique if your transaction updated other resources before it issues its first SQL statement.
  • CICS enqueue and dequeue. If you know that the serialization period necessary is only a small part of the programs, then the CICS enqueue and dequeue technique can be useful. The advantage is that only the critical part of the transaction is serialized. This part can be as small as just one SQL statement. It allows a higher transaction rate than the other methods, because the serialization is kept to a minimum.

    The disadvantage compared to the other techniques is that the serialization is done in the application code and requires the programs to be changed.

  • LOCK TABLE statement. It is recommended that you do not use the LOCK TABLE statement.

    The LOCK TABLE statement can be used to serialize CICS transactions and other programs, if EXCLUSIVE mode is specified. Note that it is the whole table space that is locked, not the table referenced in the statement.

    The serialization starts when the LOCK statement is executed. The end time for the serialization is when the table space lock is released. This can be at syncpoint or at thread deallocation time.

    Use this technique with care, because of the risk of locking the table space until thread deallocation time. However, this technique is the only one that works across the complete DB2 system. The other techniques are limited to controlling serialization of only CICS transactions.