When a thread will not commit, holds a claim that blocks STOP DATABASE, or sits in DDF until morning, operators reach for -CANCEL THREAD. This is the Db2 CANCEL command family on z/OS: one command with several options, plus the network-level follow-ups IBM documents when the thread is not inside DB2 at all. It is not the SQL ROLLBACK statement, and it is not z/OS CANCEL of a job—though you may need both in that order.
-CANCEL THREAD (abbreviation -CAN THD) cancels processing for specific local or distributed threads. Db2 schedules the thread to terminate. Threads that are not currently in Db2 terminate when they next make a Db2 request—or immediately from Db2’s point of view if they have already left. Data sharing scope is member: you cancel on the member that owns the thread.
Issue it from a z/OS console, TSO DSN session, DB2I COMMANDS, IMS or CICS, or IFI. Authorization without LOCAL: SYSOPR, SYSCTRL, or SYSADM. With LOCAL, no Db2 authorization is required (IFI, same address space, RRSAF).
Before you cancel, DISPLAY THREAD (often DETAIL, and LOCATION for DDF). Each thread has a token: a one- to six-digit decimal number, unique on that subsystem but not necessarily unique across a data sharing group. The token also appears after the equal sign in messages that display an LUWID. IFI READS for IFCID 147 or 148 can return the same token.
A logical unit of work identifier (LUWID) is:
If you type three fields separated by periods, Db2 treats the value as an LUWID. Two or more distributed threads can share an LUWID—for example package-based continuous block fetch opens a secondary connection per statement, and the server DBATs share the requester LUWID. Cancelling that LUWID cancels all of them. If the thread is part of a global transaction, the command runs against all threads in that global transaction.
| Option | Meaning |
|---|---|
| THREAD(token) | Cancel the thread with this 1–6 digit token. Token 0 cannot be canceled. |
| DDF THREAD(luwid|token) | Cancel distributed threads. An LUWID is network.luname.12-hex-instance. All threads with that LUWID are canceled (including package-based continuous block fetch secondaries). |
| DUMP | SVC dump if the thread is active in Db2 at cancel time. |
| LOCAL | IFI-only soft cancel in the same RRSAF address space. |
| NOBACKOUT | Do not back out data during rollback. Objects can be left inconsistent. |
| FORCE | Second attempt to purge a remote connection hung in the network. |
Requests a dump when CANCEL THREAD is issued and the thread is active in Db2. If the thread left Db2 to run application code, Db2 performs a hard cancel and does not provide that dump.
Search the allied agent’s home address space for a matching token and perform a soft cancel. Valid only for CANCEL THREAD through IFI. The IFI application must run in the same address space as the thread, and the thread must use the RRS attachment facility.
Db2 does not attempt to back out data during transaction rollback. That can leave objects inconsistent. Do not use it unless you already plan to repair the data. If back out later fails, objects are marked REFRESH PENDING (REFP) and either RECOVER PENDING (RECP) or REBUILD PENDING (RBDP or PSRBD). Resolve REFP with the RECOVER utility to a prior point in time or LOAD REPLACE. Message DSNI032I indicates a failed request; you may retry.
Attempts to purge the thread of a remote connection from the Db2 server. FORCE is accepted only after a CANCEL THREAD without FORCE. IBM’s attention statement: FORCE can affect the subsystem; use it for threads that hurt Db2 and will not cancel otherwise. FORCE can help a thread hung in the network. It cannot help a thread hung while Db2 is processing it.
12345-DISPLAY THREAD(*) -CANCEL THREAD(123) DUMP -CANCEL DDF THREAD(DB2NET.LUND0.C4B23F1F4D06) -CANCEL THREAD(123) -CANCEL THREAD(123) FORCE
If you need to cancel or purge jobs that have active Db2 threads, issue CANCEL THREAD first. Db2 then abnormally terminates the thread at predictable locations, which is an orderly termination from the database’s point of view. Purging the job first can leave Db2 holding resources or create a messier abend.
DISPLAY THREAD(*) LUWID(token) DETAIL. Session IDs appear under SESSID. An N in the status column means the thread is processing in VTAM. Record positions 3–16 of SESSID, match them on DISPLAY NET for the LU, then VARY NET,TERM for those VTAM SIDs.
DETAIL shows the partner IP and ports. Use D TCPIP,,NETSTAT,CONN,IPADDR= to find CONN, then V TCPIP,,DROP,CONN=. Requester and server threads differ in which port is local versus foreign—match the DISPLAY THREAD IP pair carefully. The same DROP technique applies to accelerated threads: DISPLAY THREAD(*) ACCEL(*) DETAIL, look for ST AC, then DROP the connection to the accelerator IP.
Cancelling an updater of a NOT LOGGED table space can put the space in the LPL. Recover that space before you treat the incident as closed.
A thread is a person standing at the checkout with a basket. CANCEL THREAD is the manager tapping that person on the shoulder and saying “please leave.” If they are still in the aisle (inside the application, not at the register), they might not hear until they walk back to the register (the next SQL call). DUMP is taking a photo while they are at the register so you can see what they were doing. FORCE is calling security for someone stuck in the revolving door (the network). NOBACKOUT is letting them leave without putting the groceries back—which makes a mess you must clean up later.
1. How do you identify the thread to cancel in most cases?
2. Should you z/OS CANCEL a job before -CANCEL THREAD?
3. What does DUMP on CANCEL THREAD do?
4. When is FORCE accepted on CANCEL THREAD?
5. Why is NOBACKOUT dangerous?