Ahh.. OK I missed that in the documentation.
In my defense that might be better as part of the usage information for the class rather than in the close method documentation.
I also assumed that the first error was a read error, followed by a close error. But with multiple threads it was the other way around - the close error happened first.
Original Message:
Sent: Thu February 23, 2023 12:14 PM
From: Gregory Lambert
Subject: JZOS RecordReader and multiple threads
Yes, the documentation for the JZOS RecordReader close API states:
Note: close() must be issued by the same thread as the factory method that creates the instance object (opening the dataset). Reading can occur on any thread.
------------------------------
Gregory Lambert
Original Message:
Sent: Thu February 23, 2023 02:38 AM
From: Andrew Rowley
Subject: JZOS RecordReader and multiple threads
More testing today, it appears that the SC03 abend happens when the RecordReader is closed from a different thread.
I was closing the RecordReader as soon as EOF was encountered because that avoided the problem of SC03 abends if you don't close the RecordReader.
My class that uses the RecordReader implements Closeable, so I think I will have to rely on that to perform the close and remove the close on EOF.
However, it would be nice if z/OS Java avoided the SC03 abends completely. Ending a program without closing files is probably a common case and a SC03 abend is a bit ugly and un-Javalike. I think it would be better to do some sort of close automatically.
(Maybe the SC03 when the program ends without closing a dataset is the same as my SC03, when Java attempts to close the dataset from some sort of shutdown thread???)
------------------------------
Andrew Rowley
Original Message:
Sent: Wed February 22, 2023 04:54 AM
From: Andrew Rowley
Subject: JZOS RecordReader and multiple threads
Thanks for the reply.
Based on your information I think I have identified the problem in my code... a thread is either reading after end of file or after the file is closed.
However it is very useful to confirm that the RecordReader is expected to work when accessed from multiple threads - I had been doing it and hoping it was valid, but then had doubts when I ran into problems.
I'm fairly confident now the problem is my code.
Thanks
Andrew Rowley
------------------------------
Andrew Rowley
Original Message:
Sent: Tue February 21, 2023 11:27 AM
From: Gregory Lambert
Subject: JZOS RecordReader and multiple threads
This is not a limitation and works in our testing. Can you provide us with the code or a similar sample to illustrate the problem you are seeing? If you cannot share that code in this forum you can open a support case.
------------------------------
Gregory Lambert
Original Message:
Sent: Thu January 19, 2023 05:27 AM
From: Andrew Rowley
Subject: JZOS RecordReader and multiple threads
Does JZOS RecordReader support multi-threading?
I am trying to read from a RecordReader from within a Java parallel stream. I get an exception followed by a SC03 abend. Partial stack trace:
Caused by: com.ibm.jzos.ZFileException: DD:????????: invalid JZOS BsamImpl handle; errno=-1 errno2=0xffffffff last_op=0
errorCode=0x0
at com.ibm.jzos.Bsam.readBlock(Bsam.java:203)
at com.ibm.jzos.BsamVRecordReader.readNextBlock(BsamVRecordReader.java:88)
at com.ibm.jzos.BsamVbsRecordReader.deblockSegmentsIntoRecord(BsamVbsRecordReader.java:73)
at com.ibm.jzos.BsamVbsRecordReader.read(BsamVbsRecordReader.java:50)
I have a lock around the actual read so it should be limited to one thread at a time, but the read is coming from a different thread to the thread that opened the dataset. It works OK when single threaded.
My best guess is that JZOS doesn't support reading dataset from a different thread, but I can't find documentation to confirm that. If this is a JZOS limitation I will stop looking for the problem in my code. On the other hand, if this is supposed to work maybe I have a different problem.
Can anyone confirm whether this is a JZOS limitation?
Thanks
Andrew Rowley
------------------------------
Andrew Rowley
------------------------------