iSeries - Record lock by same job/session

1.7k Views Asked by At

I am having trouble with below scenario.

There is a record lock on a file MYFILE from Program A. Later Session gets disconnected abruptly with a record lock on MYFILE and it executes cancel handler routine. In cancel handler program routine (Program B) it tries to delete the record locked in MYFILE and session hangs because the file MYFILE is compiled with WAITRCD time of NOMAX. Now nobody can access the account for any update action from other sessions as well.

Program flow is given below:

.... .... Program A (Record lock) .... Program X (Cancel Handler) ->OVRDBF WAITRCD(3) added .... Program B (Session Freeze) ->After adding OVRDBF above, session didn't freeze Program C (Session Freeze happens) -> I still see the overrides are there and it's the same default activation group and no commitment control and no triggers

Scenario here is: Record lock by the same job/session.

I have tried below solution to fix the issue:

In cancel handler program (Program B), I did a OVRDBF with WAITRCD of 3 to 5 seconds. Later executed above steps and when it came to cancel handler program, it tired to delete the locked record and after 3 to 5 seconds, it continued processing with next steps and wrote error message for locked record. There was no screen freeze. Later it went on to execute another program C where it tried to delete the locked record in MYFILE. But now the session hangs again.

I have checked the call stack and all the programs are under Default activation group and there is no committment control and no triggers. Any idea, why it overcame the record lock situation from Program B and not from Program C. Please let me know.

Regards, Suri

2

There are 2 best solutions below

0
On

The right way to handle this is to have Program A use commitment control. Then the rollback would be automatic or the cancel handler could trigger the rollback.

Assuming that's not an option.

Have your cancel handler submit a job that delays for a few seconds (giving the cancel handler/original job time to end) then deletes the record.

0
On

Do not compile files with WAITRCD = *NOMAX. if a job needs to wait for locks, use OVRDBF to adjust the wait time. I'm guessing that you are waiting because there are batch jobs waiting on interactive jobs and timing out because someone keeps a record open on thier desktop. The interactive programs should not lock the record until it is ready to update it. This will prevent this issue in the first place.