Hi, Matt,
In your web application(s), add logic equivalent to what is described in this article:
https://www.mcpressonline.com/programming/rpg/techtip-preventing-record-lock-part-3
Then have the web page display to the user the "offending job" information ... that could help you to hunt down the offending program. You could also add logic to use the returned job name/job number/job user to invoke other APIs, for example to submit a job to run:
DSPJOB JOB(123345/USER/NAME) OUTPUT(*PRINT) OPTION(*ALL)
so you will have more diagnostic information available, when the web user(s) report an issue.
Or, you can use equivalent APIs to take corrective action such as sending a message to the offending user, asking them to press Enter or F12, etc.
Hope that helps,
Mark S. Waterbury
On Friday, June 28, 2019, 1:31:53 PM EDT, Matt Olson <Matt.Olson@xxxxxxxx> wrote:
Yeah we know how to fix it, the trouble is finding all the programs that are causing it. That is what I'm looking for a solution on.
Right now I have a loop in our web application continually reading a record, and trying every option in every screen looking for when my web application bombs.
Not very efficient...
-----Original Message-----
From: Mark Waterbury <mark.s.waterbury@xxxxxxxxxxxxx>
Sent: Friday, June 28, 2019 12:23 PM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Finding offending RPG program causing locks on files
Matt,
This happens because (stupid) RPG locks each record when read from an update-capable file, until either another record is read, or you do the corresponding UPDATE or DELETE of that record. This is called "Record locks".
There are several well-known techniques -- called "lock-free" processing, where you change the logic to issue the READ without a lock, into a data structure, then you present the screen to the user, let them make any changes, and when they press Enter, you then you re-read the record again, this time with a record lock, into another data structure, and you compare the old DS to the new DS to detect if anyone else changed that record in the meantime. If no other changes are detected, you go ahead and issue the UPDATE or DELETE. Otherwise, you give the user a message like:
Sorry, someone else has updated that record, please try again ...
and some F-key to let them re-try.
See:
https://www.mcpressonline.com/programming/rpg/avoid-record-lock-errors
and TechTip: Preventing Record Lock, Part 1
and
https://www.mcpressonline.com/programming/rpg/techtip-preventing-record-lock-part-2
Or, convert the RPG update programs to use embedded SQL to update only the columns (fields) changed by the user.
Hope that helps,
Mark S. Waterbury
On Friday, June 28, 2019, 12:42:21 PM EDT, Matt Olson <Matt.Olson@xxxxxxxx> wrote:
Is there a deadlock monitoring system built into DB2 like there is in SQL Server?
If so how do you enable it or view it?
We are finding some RPG programs that are maintaining exclusive locks on files for as long as you are in the screen, which then causes our end users of our website to not be able to login as the web program can't read their record. This exhibits itself in an not very helpful message of "[57014] [IBM][AS] Resource error - SQLSTATE 57014, SQLCODE -1044."
We have already fixed one RPG program which has helped the situation, but there appears to be more RPG screens doing this.
I'm wondering what the best strategy is for finding these RPG programs as the locks are released when they close out and we might not be able to do a WRKOBJLCK command in time on the four potential files that are typically required to login.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
https://amazon.midrange.com
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.