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

RECORD OUT OF SEQUENCE error on VSAM KSDS file..


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Jul 17, 2012 4:56 pm
Reply with quote

Peter, good point.

I have just noticed SHR(3 3) on the cluster definition
Back to top
View user's profile Send private message
chetanambi

New User


Joined: 21 Jan 2012
Posts: 58
Location: India

PostPosted: Tue Jul 17, 2012 7:56 pm
Reply with quote

I did try with EXEC PGM=IDCAMS but the result is same icon_sad.gif..

Ya.. in this case both VERIFY and REPRO are catching if there is something wrong with the file. I am really getting duplicate and out-of-sequence errors while copying to flat file. There is no question about it. As Peter and Bill are suspecting there might be an issue while adding/updating records into this file. I found that only 2 CICS programs are adding/updating the file. Most importantly this file being used by 2 different CICS regions and that's the reason share options (3,3).

Anyway I am going to look into these 2 programs what it is doing. I will not give up until this is solved of course you guys will be there to help me.

Lastly can anybody please explain me this:- VSAM should be handling out-of-sequence and duplicate conditions when record is getting added even if SHR(3,3). Why its not happening?. or anything wrong with cluster definition or something else?

Thanks,
Chetan
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jul 17, 2012 8:10 pm
Reply with quote

If you have two processes updating the same VSAM file at the same time you will make a mess of the file unless you use a seperaate method to control which process updates when.

If one has just read an index, the second reads the same index, the second inserts a record, the first inserts a record, then your index has been compromised, and possibly your data as well.

Without looking in detail at what particular sequence of events caused a particular problem, you won't be able to predict the outcome beyond how Peter has already described it. It's that one begining with the letter F.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jul 17, 2012 8:15 pm
Reply with quote

this info may help you fix the dataset Broken Dataset

as far as the problem is concerned,
there is a little blurb in VSAM Dym... (page 153) that states:
Quote:
 Sharing a data set across regions (cross-region) or across systems
(cross-system) without using proper enqueuing procedures to protect data set
integrity. For shareoptions shr(3 3) shr(4 3) shr(3 4) see related information in
OY36328.
 Sharing a data set across systems — even using the appropriated share
option — but without propagating ENQ name SYSVSAM around the GRS
ring. This is the *most* common user error. It results in duplicate index
pointers in the high level index records. See message IDC11705I
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Tue Jul 17, 2012 8:25 pm
Reply with quote

Quote:
VSAM should be handling out-of-sequence and duplicate conditions when record is getting added even if SHR(3,3).
Sorry, but you are making a false statement here. From the AMS for Catalogs manual on SHROPTIONS (with emphasis added by me):
Quote:

3
Specifies that the data set can be fully shared. With this option, each user is responsible for maintaining both read and write integrity for the data that user's program accesses. User programs that ignore write integrity guidelines can cause VSAM program checks, uncorrectable data set errors, and other unpredictable results. This option requires each user to be responsible for maintenance. The RESERVE and DEQ macros are required with this option to maintain data set integrity. (For information on using RESERVE and DEQ, see z/OS MVS Programming: Authorized Assembler Services Reference ALE-DYN and z/OS MVS Programming: Authorized Assembler Services Reference LLA-SDU.)

In other words, your site has caused this mess by not following IBM standards -- you're going to have to either change the SHROPTIONS or add enqueue / dequeue / reserve logic to the programs in each region to stop the problems -- or they will continue.
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Tue Jul 17, 2012 10:21 pm
Reply with quote

Hi.

Quote:
Vasanth,

Yes.. there are more steps in my job. This is what it doing:-
Step1: Copy VSAM fiel to flat file using REPRO.
Step2: Process the flat file and create o/p file out of it.
Step 3: Delete and Define the VSAM.
Step 4: Load data from o/p of step 2 to VSAM file using REPRO (with REPLACE option).


By the by first tell me on which step you are getting sequence error.

Points below can encounter:-

1. Check whether you correctly sorting on key field also on mentioned length of the key..
2. If this error arriving on every week or 2 months. Try to have powerful key after discussing with your peers. Also verify your input shouldn't vary on these days.
3. Since two CICS region involved adding/updating on VSAM file. verify any user adding messy data.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Tue Jul 17, 2012 10:38 pm
Reply with quote

Vasanth, the VSAM shareoptions are (3 3) -- unless all programs accessing the VSAM file in both CICS regions use enqueue / dequeue mechanisms, there is no need for "messy data" to have problems. Merely having both regions reading and writng to the VSAM file without using a queueing mechanism can cause the problems described.

The sort doesn't matter -- and could even be right at all times.
The user input doesn't matter -- and could even be right at all times.
The data quality doesn't matter -- and all data may be perfectly good at all times.
The only thing that matters is whether or not all programs accessing the VSAM file in both CICS regions use the proper way to ensure read and write integrity. If they don't, errors WILL occur.
Back to top
View user's profile Send private message
chetanambi

New User


Joined: 21 Jan 2012
Posts: 58
Location: India

PostPosted: Tue Jul 17, 2012 11:56 pm
Reply with quote

After reading Bill's description and info provided by dbzTHEdinosauer and Robert, now I am clear about what is causing the issue. This is indeed an issue with improper use of share-options or not following IBM standards on using ENQ/DEQ/RESERVE logic in the programs.

As of now I am not aware these commands on how to use in my CICS application. So I am going thru "VSAM demystified" to get clear picture. Please let me know if you know any useful links for these.

I will reply as I get any progress. I am very happy that even though issue is not resolved I have already learnt many things on VSAM.

Thanks,
Chetan
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed Jul 18, 2012 1:22 am
Reply with quote

In addition to VSAM Demystified, look at the CICS Application Programming Reference manual for the EXEC CICS ENQ and EXEC CICS DEQ commands.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 18, 2012 2:08 am
Reply with quote

Yup, after you get this fixed, it will happen again.

Alternatively, building/defining an FOR (File Owning Region) and defining this file in an FCT entry (along with others which are accessed similarly) would be beneficial in the long run.

If you go with the FOR, each current FCT entry in each given region (AOR), must specify the KEYLENGTH value, providing the program's file API doesn't, along with the SYSID of the FOR (REMOTESYSTEM). Without a KEYLENGTH in the API as well as being omitted from the FCT entry, an INVREQ will be raised. With that, it's much easier to specify the KEYLENGTH value along with the mandatory REMOTESYSTEM/SYSID value in the FCT entry.

FWIW, when restarting regions, the FOR is always the first one....
Back to top
View user's profile Send private message
chetanambi

New User


Joined: 21 Jan 2012
Posts: 58
Location: India

PostPosted: Wed Jul 18, 2012 12:00 pm
Reply with quote

Bill,
Even after changing the share-options or using those CICS commands to ensure read and write integrity, problem will occur again??. Is that what you want to say?

I am not very clear about other part of your reply. The VSAM file is already defined in both the CICS regions with KEYLENGTH and I have verfied this thru CEMT command. This is what I see there:-
Code:

File(xxxxxxx)                                         
Accessmethod(Vsam)                                   
Openstatus( Open )                                   
Enablestatus( Enabled )                               
Readstatus( Read )                                   
Updatestatus( Update )                               
Addstatus( Addable )                                 
Browsestatus( Browse )                               
Deletestatus( Delete )                               
Exclstatus(              )                           
Disposition( Share )                                 
Rlsaccess( Notrls )                                   
Emptystatus( Noemptyreq )                             
Dsname( XXXXX.XX.XXXX.XXXXXXX                      )
Table( Nottable )                                     
Loadtype( Noload )                                   
Cfdtpool(          )                                 
Tablename(          )                               
Updatemodel( Locking )         
Maxnumrecs( 00000000 )         
Keylength( 014 )               
Recordsize( 00106 )           
Rbatype(Notextended)           
Remotesystem()                 


Thanks,
Chetan
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jul 18, 2012 12:14 pm
Reply with quote

No, I'm not saying that.

Your shareoptions allows multiple concurrent opens-for-update.

If you change your shareoptions to allow only one open-for-update at a time, you won't get the problem (but won't have simultaneous access in two CICS regions).

If you do the enqueing process as outlined by people above then you can have the file open in multiple programs but you will have a method whereby only one update of any type (add/change/delete) can be done at any one time (presuming coded correctly). As only one update can be done at a time, there is no possibility of "losing" an chunk of the index through two or more updates being done at the same time.

Don't get worried about "performance". It is pretty zippy and it is the way everyone does it and it has to be done.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jul 18, 2012 1:17 pm
Reply with quote

Bill O'Boyle wrote:
Yup, after you get this fixed, it will happen again.

Alternatively, building/defining an FOR (File Owning Region) and defining this file in an FCT entry (along with others which are accessed similarly) would be beneficial in the long run.


hmmmm, I wonder why Bill brought this up?

probably because when you have an enq/deq from every request
within an Appllication Owning Region,
having two regions with implicit FOR (as your site is set-up)
is the same as having no enq/deq.

you can only effectively enq/deq a resource one place,
in this case an FOR.

hmmmm, wonder why IBM came up with the idea of AOR and FOR?

Hmmm???

can both regions have cause to access the same records?
if not, maybe divide the VSAM into two VSAMs based on the logic driving each region.
Then you don't have to have you storage management people learn about AOR and FOR.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Jul 18, 2012 8:06 pm
Reply with quote

This thread is a keeper - but, why not redefine VSAM with SHR(2 3)? If you want to do batch update processing on a VSAM file that is used by CICS, use CEMT to close it within CICS, so allowing a batch job to be the single permitted writer, no?
Back to top
View user's profile Send private message
chetanambi

New User


Joined: 21 Jan 2012
Posts: 58
Location: India

PostPosted: Wed Jul 18, 2012 8:24 pm
Reply with quote

I have gone thru some of the links provided. For the devices shared between multiple z/OS systems, enqueuing is accomplished though RESERVE and DEQ. and if one system ENQ and DEQ can be used. I know about ENQ and DEQ commands but didn't find any info on RESERVE from the net. Please provide me if you have any information on RESERVE. or if I use ENQ or DEQ commands is that ok?

Thanks,
Chetan
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Wed Jul 18, 2012 8:26 pm
Reply with quote

Reserve :


MVS Programming: Authorized Assembler Services Reference, Volume 3 (LLACOPY-SDUMPX)
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 18, 2012 8:33 pm
Reply with quote

If you have more than one region attempting to UPDATE and you're using ENQ/DEQ, they will only be known in the region issuing the UPDATE. In other words, REGIONA won't know about REGIONB's ENQ/DEQ's because they're not GLOBAL/SHAREABLE within an LPAR or two or more REGION's.

This is why an FOR (in the same LPAR) could centralise access and give you better file integrity.
Back to top
View user's profile Send private message
chetanambi

New User


Joined: 21 Jan 2012
Posts: 58
Location: India

PostPosted: Wed Jul 18, 2012 9:08 pm
Reply with quote

Quote:

This thread is a keeper - but, why not redefine VSAM with SHR(2 3)? If you want to do batch update processing on a VSAM file that is used by CICS, use CEMT to close it within CICS, so allowing a batch job to be the single permitted writer, no?

No we can't redefine file with SHR(2,3) because dataset should be fully shared among number of users (but the programs which are adding/updating the records in the file are not maintaing the read and write integrity and is causing the issue). Howewer we did try with SHR(2,3) sometime back and it worked for somedays but issue started occuring again after that.

Thanks,
Chetan
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: Wed Jul 18, 2012 10:23 pm
Reply with quote

Hello,

Probably not what you are looking for, but maybe it is time to convert this to a database. . .

And we appear to have gone far away from the "out of sequence" icon_smile.gif

d
Back to top
View user's profile Send private message
chetanambi

New User


Joined: 21 Jan 2012
Posts: 58
Location: India

PostPosted: Thu Jul 19, 2012 12:56 pm
Reply with quote

Quote:
If you have more than one region attempting to UPDATE and you're using ENQ/DEQ, they will only be known in the region issuing the UPDATE. In other words, REGIONA won't know about REGIONB's ENQ/DEQ's because they're not GLOBAL/SHAREABLE within an LPAR or two or more REGION's

Bill, Yes. more than one regions (in our case 2 regions) may try to update the data. Since more than one regions are involved here how to make it GLOBAL/SHAREABLE?. I found some information in VSAM demystified about GSR (Global Shared Resource) but no explanation how to use. Is that what you mean by GLOBAL/SHAREABLE?. Could you please explain me how can i use it for better file integrity?

So I am gonna try by changing share-options(2,3) once more time AND/OR with GLOBAL/SHAREABLE after I get information on it.

I have noticed that CEMT command for file is showing RLSACCESS as below. How about using the file in RLS (Record Level Sharing) mode across LPAR. Will that solve the problem?
Code:
Rlsaccess( Notrls )
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Jul 19, 2012 1:30 pm
Reply with quote

chetanambi wrote:
No we can't redefine file with SHR(2,3) because dataset should be fully shared among number of users (but the programs which are adding/updating the records in the file are not maintaing the read and write integrity and is causing the issue). Howewer we did try with SHR(2,3) sometime back and it worked for somedays but issue started occuring again after that.
Well, if you use SHR(3 3), the main concern is the potential for file corruption. As they say, your mileague may vary and if you don't deploy what Bill O'Boyle and Robert has told in their excellent explnations, one is entiteled to get the errors you're expericing.

As has been mentioned earlier too - if both batch and online can write to the file, you must incorporate enqueuing and dequeuing methods in your batch and online programs to guarantee read and write integrity - let alone the concept of differnt regions. If you do not, the file is quite easily corrupted and if you're lucky, file must be restored from a back up to recover. Form fhe VSAM Demystified about cross-region option 3:
Quote:
VSAM allows many OPENs to the data set for output and/or input. The user application programs must ensure both read and write integrity through their own ENQs (including Open and Close processing on them).
so you still need to care about ENQs.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jul 19, 2012 2:07 pm
Reply with quote

be careful about saying enq/deq and batch.

one of the reasons most batch activity is performed on a VSAM file after the file has been closed and disabled in cics
is due to the fact that CICS does not always immediately update the physical file,
but instead maintains the updated CI in the buffer.
and until the file is CLOSED in CICS, the buffers are not flushed.
the file also needs to be disabled in CICS is to prohibit re-opening the file in cics
by any transaction that may attempt to read the file,
is the file is defined by the FCT to allow a read to open an closed/enabled file.


also, since enq/deq are part of the CICS API's,
the only way a Batch program could enq/deq a CICS resource
is to invoke a CICS module in an active CICS Region
(via CICS LINK - exci or any other batch to cics interface)
to perform the enq/deq
or if the interface supports the enq/deq API directly.

also, keep in mind, that the enq/deq is for a resource name,
and unless all enq/deq (for a vsam file in this case) use the same resource name (or id)
then effectively there is no enq/deq of a resource.

good post Anuj, allows for misconceptions to be addressed.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Jul 19, 2012 2:13 pm
Reply with quote

You could investigate the use of DFSMStvs at your site, although that would be a pay for addition from IBM. It allows simultaneous multiple access to the same VSAM file through both batch and online.

Another possibility may be RLS via SMS but you would need to talk to your storage management / sysprogs about it.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jul 19, 2012 3:07 pm
Reply with quote

db2 databases are the only data repositories that allow for concurrent batch and CICS update.

even though DFSMStvs with RLS allows and protects the integrity of VSAM datasets
during concurrent multi-CICS-Region updates,
this does not include batch.
the literature states:
a batch job updating a vsam dataset
must be disabled/closed and then re-opened in CICS in a non-RLS mode.

there maybe 3rd party tools (read more bucks) that allow for concurrent batch and CICS updates,
but, personally, i doubt it. CICS controls vsam datasets in cics buffers,
even dfsmstvs functions under CICS.
and since these buffer can/will contain modified data that will not be positively written to the dataset until disable/close,
these buffers are not available to batch.

the only way around this problem,
would to have the batch update interfacing with something like exci
which means that the updating would be performed by CICS
and not a batch allocation of the file.

as with all cics vsam enhancements to allow for 24/7,
there are caveats,
the biggest hurdle being you can't update an open cics vsam file in RLS mode from a batch allocation of the file ....

the solution provided by Bill o'boyle concerning AOR/FOR allows
for the easiest method of implementing data integrity in CICS.
But, even that does not address the problem of concurrent batch/cics update.

by the time you add RLS (required for dfsmstvs) and dfsmstvs to your system
(normally, more iron required)
you are starting to enter the point where your scale of cost
approaches DB2,
which allows for concurrent batch/cics update
mainly because CICS does not control db2, as it does control VSAM.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jul 19, 2012 3:18 pm
Reply with quote

I got out of the vsam business long ago (and migrated to db2)
because there is no growth future.
the more you add to a vsam system, especially the 24/7 requirements,
you are contantly fighting the same battles,
and the TS is plagued with a CICS/datamanagment support group
that does not even know the basics.
otherwise the TS would not have created this thread.

another reason for the direct vsam image to db2 row conversions.
they were basically trying to get around the problem inherent in vsam
with 24/7 online and batch updating
on the cheap (read direct conversion of vsam record to db2 row).
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 -> JCL & VSAM Goto page Previous  1, 2, 3  Next

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Error to read log with rexx CLIST & REXX 11
Search our Forums:

Back to Top