· Jan 27, 2023

Exiting terminal without loosing job

Hi Guys,

Sealy question but I'm between a hard and rock :)

I've a running method that deletes a list of records and its has been running for hrs and did place locks so other processes can't progress, and to what I can see it will still run for a few more hours, so how can I stop this process at this point without losing what already has been deleted?

If I close the terminal all records that has been deleted will roll back as it happened to before ?



Product version: Ensemble 2014.1
Discussion (7)1
Log in or sign up to continue

If I interpret the situation correctly, you started a (direct mode) job in a terminal session and want to stop it without loosing (i.e. avoiding a rollback) the already deleted records. I think (but not tested) a simple Ctrl + C should be do the trick. After typing "Ctrl+C" you should see


Now type TC+<Enter>. This commits the already deleted item and you can exit your terminam session with the usual Halt command.  As above said, not tested but maybe some of the Gurus here can agree (or disagree) with this procedure.

Interrupt causes rollback, try this code:

Class User.Del Extends (%Persistent, %Populate) [ Final ]

ClassMethod HangBool(seconds, id) As %Boolean [ SqlProc ]
    hang seconds
    quit $$$YES

/// do ##class(User.Del).Test()
ClassMethod Test()
    do ..%KillExtent()
    do ..Populate(10,,,,$$$NO)
    set start = $zh 
    &sql(DELETE FROM Del WHERE Del_HangBool(1, id)=1)
    set end = $zh
    w "Delete took: ", end-start,!

Regardless of when you send the interrupt, the ^User.DelD global would have 10 records.