$ZMAXTPTI[ME] contains a value in seconds with millisecond precision specifying the time duration GT.M should wait for the completion of all activities fenced by the current transaction's outermost TSTART/TCOMMIT pair. A SET to a value outside the accepted range of .005 and 300 leaves 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 or outside the supported range, the initial value of $ZMAXTPTIME is 30 seconds. 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 |
---|---|
GT.M handles attempts to assign values outside the supported range to $ZMAXTPTIME by leaving the value unhanged. Timeouts apply only to the outermost transaction, that is, neither a SET of $ZMAXTPTIME within a TP transaction nor a TSTART nested within another transaction has any effect on the duration established by the value $ZMAXTPTIME at the time of the initial TSTART. Times such as those associated with $ZMAXTPTIME are not precise, but rather subject to interactions among the application, deployed environment, and processing load, which can cause actual times to vary slightly, but possibly materially relative to a given use case, especially for very small settings. Such variations may require thoughtful attention in unusual cases. Certain actions such as Instance freeze, Online Rollback, and Direct Mode (which does not work appropriately within a TP transaction) do not count against the $ZMAXTPTIME. |
Example:
tptimeout ;testing TP timeouts set $ZMAXTPTIME=1.2,^X=0,^Y=0,^Z=0 write "Start with $ZMAXTPTIME=",$ZMAXTPTIME,":",! set $etrap=" goto err",retlvl=$zlevel+1 for sleep=3:2:9 do . do longtran;$etrap in longtran . ; continues execution on next line . write "(^X,^Y)=(",^X,",",^Y,")",! write "Done TP Timeout test - ",$text(+0),! quit longtran ;I/O in TP doesn't get rolled back 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: ",$zstatus,! if $TLEVEL do ;test allows handler use outside of TP . trollback . write "Rolled back transaction.",! set $ecode="" zgoto retlvl
Results:
Start with $ZMAXTPTIME=6: ^X=1,will set ^Y to 3 in 3 seconds...^Y=3...committed. (^X,^Y)=(1,3) ^X=2,will set ^Y to 5 in 5 seconds...^Y=5...committed. (^X,^Y)=(2,5) ^X=3,will set ^Y to 7 in 7 seconds... In $ETRAP handler. Error was: 150377322,longtran+5^tptimeout,%GTM-E-TPTIMEOUT, Transaction timeout after 0 restart(s) and 5 grace period(s) from longtran+5^tptimeout routine_path Rolled back transaction. (^X,^Y)=(2,5) ^X=3,will set ^Y to 9 in 9 seconds... In $ETRAP handler. Error was: 150377322,longtran+5^tptimeout,%GTM-E-TPTIMEOUT, Transaction timeout after 0 restart(s) and 5 grace period(s) from longtran+5^tptimeout routine_path Rolled back transaction. (^X,^Y)=(2,5) Done TP Timeout test - tptimeout