$ZMAXTPTIme

$ZMAXTPTI[ME] contains a value between zero (0) and 60 in seconds with millisecond precision indicating the time duration GT.M should wait for the completion of all activities fenced by the current transaction's outermost TSTART/TCOMMIT pair. Values outside the accepted range leave the current value unchanged.

$ZMAXTPTIME can be SET but cannot be NEWed.

$ZMAXTPTIME takes its value from the environment variable gtm_zmaxtptime. If gtm_zmaxtptime is not defined, the initial value of $ZMAXTPTIME is zero (0) seconds which indicates "no timeout" (unlimited time). The value of $ZMAXTPTIME when a transaction's outermost TSTART operation executes determines the timeout setting for that transaction.

When a $ZMAXTPTIME expires, GT.M executes the $ETRAP/$ZTRAP exception handler currently in effect.

[Note] Note

Negative values of $ZMAXTPTIME are also treated as "no timeout". Timeouts apply only to the outermost transaction, that is, $ZMAXTPTIME has no effect when TSTART is nested within another transaction.

Example:

Test;testing TP timeouts
  set $ZMAXTPTIME=6,^X=0,^Y=0,^Z=0
  write "Start with $ZMAXTPTIME=",$ZMAXTPTIME,":",!
  for sleep=3:2:9 do
  . set retlvl=$zlevel
  . do longtran;ztrap on longtran 
  ;continues execution
  ;on next line
  . write "(^X,^Y)=(",^X,",",^Y,")",!
  write !,"Done TP Timeout test.",!
 quit
longtran ;I/O in TP doesn't get rolled back
  set $etrap=" goto err"
  tstart ():serial
  set ^X=1+^X
  write !,"^X=",^X,",will set ^Y to ",sleep
  write " in ",sleep," seconds..."
  hang sleep
  set ^Y=sleep
  write "^Y=",^Y
  tcommit
  write "...committed.",!
  quit
err;
  write !,"In $ETRAP handler. Error was: "
  write !," ",$zstatus
  if $TLEVEL do ;test allows handler use outside of TP
  . trollback
  . write "Rolled back transaction."
  write !
  set $ecode=""
  zgoto retlvl

Results:

Start with $ZMAXTPTIME=6:
^X=1,will set ^Y to 3 in 3 seconds...^Y=3...committed.
^X=2,will set ^Y to 5 in 5 seconds...^Y=5...committed.
^X=3,will set ^Y to 7 in 7 seconds...
In $ETRAP handler. Error was:
150377322,longtran+7^tptime,%GTM-E-TPTIMEOUT, Transaction timeoutRolled back transaction.
^X=3,will set ^Y to 9 in 9 seconds...
In $ETRAP handler. Error was:
150377322,longtran+7^tptime,%GTM-E-TPTIMEOUT, Transaction timeoutRolled back transaction.
Done TP Timeout test.