IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Restart Batch DB2 Pgm @ Abend - After The Last Commit.


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
shitij

New User


Joined: 09 Sep 2005
Posts: 31
Location: Delhi

PostPosted: Wed Dec 05, 2007 11:08 pm
Reply with quote

Hi,

I would like to know what is/are the method(s) by which we can start the batch DB2 pgm. which has abended...after the last commit (eg if I commit after every 1000th insert - and it abends at 1002nd insert).

I mean how will the program know that it has to be restarted after/from the last commit point i.e it has to start inserting from 1001st record of the file.

Could someone please give me an example - A code snippet will do.


Thanks,
Shitij
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Dec 05, 2007 11:30 pm
Reply with quote

Are you looking for someway for your program to magically know where to restart without any manual intervention in the restart process? Are you doing any kind of tracking to know where the last commit happened or are you just looking at job output? If you have tracking, like writing the record number of the last commit to a file or job log, you could use a parm as input to your program telling it what record the inserts should restart on.


Very Bad:
You could check every record you want to insert for existence with a SELECT with a full WHERE on the record before executing an INSERT. Note that this is very inefficient because if it is a clean run you would be doing many unneeded SELECTs.
Back to top
View user's profile Send private message
anjani shanker

New User


Joined: 26 Jan 2007
Posts: 37
Location: USA

PostPosted: Wed Dec 05, 2007 11:51 pm
Reply with quote

Hi,

Why dont you try a hand with Multi Row fetching.Your task would become easier.In this you have facility to Diagnose for errors as well.


Anjani..
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Dec 06, 2007 12:40 am
Reply with quote

Hello Anjani and welcome to the forums,

How does multi-row fetching provide an easier restart?

Shitij,
Quote:
Could someone please give me an example - A code snippet will do.
Restart/recovery processing should cover an application or an entire database environment. Restarts should not be some "put together" stuff - it needs to be planned at higher than the program level. There are no generic snippets.

Your organization must decide how restarts will be handled. There is usually much more to a restart than merely processing the correct database rows. If this is some school assignment, you may be able to use some incomplete restart process, but if this is a business requirement, you need to learn more about what is necessary.
Back to top
View user's profile Send private message
shitij

New User


Joined: 09 Sep 2005
Posts: 31
Location: Delhi

PostPosted: Thu Dec 06, 2007 1:03 am
Reply with quote

Thanks Stodolas/Anjani/Dick for your reply,

I know my question is not that generic (I have tried to search this topic in previous posts also).

Currently what we do is :

Say insertion in the master table is going on and it abends during the process, we can check the sysout to find out how many records inserted (it commits after every 1000th insert) and we clean up the master table of these inserted records before re-starting the job again.

I liked the idea where if we can pass the value/figure (of data inserted) through the PARM we will be able to tell the program from where it should start, but - In that case do I have to make my program logic in such a way that it skips the number of Detail records which are given in the PARM value?

Eg:-

PARM='2000 '

...Is it that I read (and insert) records after the first 2000 detail records - as the first 2000 are already inserted or I can use some other logic?

Thanks,
Shitij
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Dec 06, 2007 1:13 am
Reply with quote

Hello,

If the only ting the program does is read qsam input and insert database rows, you can do what you want with the parm.

If the program does anything else (writes some kind of output file(s), accumulates any totals for use in reporting or some eoj database summaries, creates any report(s), you will have to include code to re-sync all of these operations.

With the extremely faster processors and database engines in use today, many places do not incorporate restart logic as it is easier and faster to let the updates automatically back out when the process abends and re-run from the beginning. Keep in mind that the more complex the restart, the likelier there will be errors committed which will waste even more time getting the system back to where it needs to be.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Dec 06, 2007 1:17 am
Reply with quote

Usually in well eshtablished checkpoint restart environment there is
a data base with the info about the running processes/programs
the key is some assigned id, and it will contain all the info needed for the restart

a sample logic would be ...

read the table...
if no record found ... start from the beginning..

if a record is there fill from the checkpoint record all the program variables
which change as the program proceeds

at the specified frequency
update the table and commit ..

if anything happens and the environment is set up the proper way.
the restart will be completely transparent..

for VERY CRITICAL applications also the syouts should be tables
so there will not be any duplicate records , and a stupid select will print everything at the proper time
Back to top
View user's profile Send private message
Aniyaa

New User


Joined: 07 Dec 2007
Posts: 26
Location: Bangalore

PostPosted: Mon Dec 10, 2007 6:02 pm
Reply with quote

Hi , the restart logic in short is given below.

things to do before abend
populate the last record number key after the commit into an abend file.

things to do after the abend
read from the abend file.
populate the key-field
read in-rec file (using the key field)
update into the table

This is basically what is checkpoint restarting
Please correct me if I am incorrect
Back to top
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 148
Location: Ottawa Canada

PostPosted: Tue Dec 11, 2007 2:51 am
Reply with quote

Enrico says it well. One thing to add is this.

Just before your program terminates you must update your RESTART table to note the fact that your job ended successfully. That way - the next time the job executes it will know that it should start in FIRSTRUN mode as opposed to RESTART mode.

Your RESTART table could be defined with the following columns:

Job name (KEY field 1)
Step Name (KEY field 2)
Main line Program ID
VARCHAR(1000) to hold your counters and key values.

We use a 3rd party package to make our sequential files behave like DB2 tables with respect to Commits, Rollbacks and abends.

Other places that don't have 3rd party packages use GDGs instead of sequential files. Everytime they commit, they close the file and open a new generation. When the job terminates all the generations are consolidated back into a single output file.

I could go on and on here - big topic...
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts ISAM and abend S03B JCL & VSAM 10
No new posts How to get a stack trace on a looping... ABENDS & Debugging 5
No new posts Calling Java method from batch COBOL ... COBOL Programming 5
No new posts Help in Automating Batch JCL jobs mon... JCL & VSAM 3
No new posts Batch install term/printer CICS 2
Search our Forums:

Back to Top