I'll confirm what several others have suggested.  In job 1, Allocation gets the 
ENQ on the GDG base name (MANAGED.TEST.GDG in this case) before allocating the 
generation data set.  Since NEW was specified, the ENQ is obtained exclusive.  
We'll also get the ENQ for the GDS (MANAGED.TEST.GDG.GxxxxV00) exclusive, and 
we hold both until you unallocate it.  Job 2 also tries to get the ENQ on the 
GDG base name, and since Job 1 holds it exclusive, you get S99ERROR 0210 (data 
set unavailable.)

Holding both ENQs keeps things somewhat "sane" - if multiple jobs are trying 
create or delete generations at the same time, then generations might not get 
rolled in properly or duplicate data sets can occur or "holes" can be created 
where some generations are missing.

Batch JCL will wait for ENQs, so if these DDs were coded in JCL, job 2 would 
end up waiting for job 1 to unallocate the GDG.  Batch allocation has more 
information to work with when it comes to deadlock prevention than dynamic 
allocation, so dynamic allocation is a little different - you can wait if you 
ask for it (and are an authorized program), but waiting isn't the default.  I'm 
not sure if BPXWDYN supports waiting for data sets, but I suspect it doesn't.

There's a few tricks you can try.  Job 2 can have its own wait and retry logic 
(like others have already suggested.)  Allocating the GDS using the ...GxxxxV00 
name does not get the ENQ for the base name, so you could do something like 
allocate the (+1), get the ...GxxxxV00 name, unallocate it, and then reallocate 
with the GxxxxV00 name and write your data.  That doesn't eliminate the window 
where the base name is held, but it could significantly shrink it.  (There is a 
chance that somebody could play with your data set in the window where it is 
unallocated, so this might not be a viable option - that's for you to decide 
based on what your application is doing.)

-Scott Ballentine (sbal...@us.ibm.com)
 z/OS Device Allocation Development

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to