IBM i Access Client Solutions

 View Only
  • 1.  Does qsys2.ifs_read lock file?

    Posted Fri September 22, 2023 08:47 AM

    When attempting to read a large log file (25+ MB) using QSYS2.IFS_READ in Run SQL Scripts, a java process attempted to write to the file while the statement was running and received an error:

    java.io.FileNotFoundException (The requested resource is busy.)

    SQL statement:

    select *
    from table(
        qsys2.ifs_read(
            path_name => '/home/logs/log-2023-09-21.txt',
            end_of_line => 'LF'
        )
    );

    Does QSYS2.IFS_READ lock the file being read? If so, is there a way to avoid this?



    ------------------------------
    David Hammond
    ------------------------------


  • 2.  RE: Does qsys2.ifs_read lock file?

    IBM Champion
    Posted Sat September 23, 2023 10:14 PM
    Edited by Satid Singkorapoom Sun September 24, 2023 07:59 AM

    Dear David

    You can use IFS_OBJECT_LOCK_INFO table function (available as of IBM i 7.3) in another Run SQL Script session to find out the answer. Look for the lock type in column SHARE_R..., SHARE_W..., SHARE_RW...., and SHARE_NONE.....

    SELECT JOB_NAME, SHARE_R_COUNT, SHARE_W_COUNT, SHARE_RW_COUNT, SHARE_NONE_COUNT    FROM TABLE(QSYS2.IFS_OBJECT_LOCK_INFO(PATH_NAME => '<full path to the file>'))

    If you are running pre-7.3, use this : Sample Program to List Lock Information for IFS Objects at  https://www.ibm.com/support/pages/sample-program-list-lock-information-ifs-objects. 

    ------------------------------
    Chance favors only the prepared mind.
    -- Louis Pasteur
    ------------------------------
    Satid S.
    ------------------------------



  • 3.  RE: Does qsys2.ifs_read lock file?

    IBM Champion
    Posted Sun September 24, 2023 05:07 AM

    On second thought, reading a 25+MB file should not take long to finish unless the disk response time is particualrly bad.  Does your IBM i server still use hard disk and you happen to read the file at issue during high workload period when disk response time degrades badly?  If so, you are well advised to do this in low workload period instead. 



    ------------------------------
    Chance favors only the prepared mind.
    -- Louis Pasteur
    ------------------------------
    Satid S.
    ------------------------------



  • 4.  RE: Does qsys2.ifs_read lock file?

    Posted Tue September 26, 2023 09:59 AM
    Edited by David Hammond Tue September 26, 2023 09:59 AM
    Thanks for your answers.
     
    We were attempting to read a production IFS file that is being written to 24 hours a day without impacting the production job. Unfortunately, using qsys2.ifs_read caused the production job to fail due to not being able to write to the log file that was being read by ifs_read.
     
    We have alternatives, but were hoping to determine if the ifs_read table function locks the file being read by design or if it is a bug.



    ------------------------------
    David Hammond
    ------------------------------



  • 5.  RE: Does qsys2.ifs_read lock file?

    IBM Champion
    Posted Wed September 27, 2023 01:57 AM

    Dear David

    I'm guessing here but any OS function that does just a read should exert just the lowest level of lock here such as shared for update.  But another user job wanting to exert an exclusive lock should fail.  I suggest you ask someone who knows about this user job if it really needs an exclusive lock?  Can it use a lower level of lock such as "exclusive allow read" which would solve your issue ?    But I do not really know if exclusive allow read lock is available for an IFS object or not. Could not find it with Google search.



    ------------------------------
    Chance favors only the prepared mind.
    -- Louis Pasteur
    ------------------------------
    Satid S.
    ------------------------------