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 ?
.png)
.png)
Thanks
Comments
Hi, you can try to call it using job:
j ##class(MSDS.Common.JobTimeStamps).deleteOldRecords()
It's already running and I want to stop or pause the current running one as attached
I don't think it's possible.
You can suspend the process, manually delete locks, run other tasks, and unsuspend the process. But that's definitely not a supported practice.
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
<INTERRUPT>
TLn:yournamespace>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(DELETEFROM Del WHERE Del_HangBool(1, id)=1)
set end = $zhw"Delete took: ", end-start,!
}
}Regardless of when you send the interrupt, the ^User.DelD global would have 10 records.
my short test now
USER>
USER>k^kav
USER>s^kav(1)="some", ^(2)="data..."
USER>ts k^kav(1) f h1
TS K^kav(1) F H1
^
<INTERRUPT>
TL1:USER>tc
USER>zw^kav^kav(2)="data..."
USER>
shows something else... the deleted node is gone
There are OS tools that allow you disconnect from a running session like screen.