BookmarkSubscribeRSS Feed
bentleyj1
Quartz | Level 8

We're running on a Linux OS with SAS 9.4 M5.  FILEWAITLOCKMAX is set to 0 and FILELOCKS is set to FAIL.

 

We have to solve a problem of jobs failing because PROC COPY is trying to copy data sets that users are I guess reading.  I know there are coding workarounds but it sure would be easier to use FILELOCKWAIT= as a LIBNAME option. This is the first time I've worked with it so maybe I don't understand how it works.

 

To test it, I had a friend run this code on the server to create a file and lock it (we work with the SAS Editor on the desktop and use SAS/Connect to work on the server).

 

 

RSUBMIT WFAUTO;  

      libname shared  '/sasapp/datamart/data/dev' filelockwait=300;

 

      ** Create a dummy data set. ;

      data shared.lockTest;

            x=1;

      run;

 

      ** Be sure I can write to it. ;

      X 'chmod 774 /sasapp/datamart/data/dev/lockTest.sas7bdat';

     

      ** Set an exclusive lock on the data set so no one else can access it. ;

      lock shared.lockTest;

 

      ** When we are done testing, run this to release the lock.;

      ** lock shared.lockTest clear;

ENDRSUBMIT;

 

So then I run this code shouldn't SAS wait for the lock to release?  But it immediately throws an error.   Any ideas what's going on and how I can fix it?  Do I not understand how FIELOCKWAIT works?

 

 

RSUBMIT WFAUTO;  

      libname check '/sasapp/datamart/data/dev/ filelockwait=300;;

 

      data read; set check.lockTest;

      run;

ENDRSUBMIT;

 

85   data read; set check.lockTest;

ERROR: A lock is not available for CHECK.LOCKTEST.DATA.

ERROR: Lock held by process 22282672.

86   run;

 

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.READ may be incomplete.  When this step was stopped there were 0 observations and 0 variables.

WARNING: Data set WORK.READ was not replaced because this step was stopped.

NOTE: DATA statement used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

 

3 REPLIES 3
Reeza
Super User

There's a note in the docs about it not working as expected with SAS/CONNECT.

 

Not super helpful, but probably what is causing your issue. You may want to check with Tech Support on this to find a suitable workaround.

 

FILELOCKWAIT=n

specifies the number of seconds SAS waits for a locked file to become available to another process. If the locked file is released before the number of seconds specified by n, then SAS locks the file for the current process and continues. If the file is still locked when the number of seconds has been reached, then SAS writes a "Locked File" error to the log and the DATA step fails.

Default 0
Range 0 – 600
Interactions Specifying the FILELOCKWAIT= option can have an adverse effect on one or more SAS/SHARE server and client sessions that are waiting for the release of a SAS file that is locked by another process. One or more wait conditions could lead to failed processes for a SAS/SHARE server and clients.
To prevent the possibility of a failed SAS/SHARE process, you can set FILELOCKWAIT=0, which cancels the amount of time that a SAS/SHARE server and clients would wait for the release of a locked file. Canceling the wait time would prevent a failed process. For more information, see FILELOCKWAITMAX= System Option: Windows.

 


@bentleyj1 wrote:

We're running on a Linux OS with SAS 9.4 M5.  FILEWAITLOCKMAX is set to 0 and FILELOCKS is set to FAIL.

 

We have to solve a problem of jobs failing because PROC COPY is trying to copy data sets that users are I guess reading.  I know there are coding workarounds but it sure would be easier to use FILELOCKWAIT= as a LIBNAME option. This is the first time I've worked with it so maybe I don't understand how it works.

 

To test it, I had a friend run this code on the server to create a file and lock it (we work with the SAS Editor on the desktop and use SAS/Connect to work on the server).

 

RSUBMIT WFAUTO;  

      libname shared  '/sasapp/datamart/data/dev' filelockwait=300;

 

      ** Create a dummy data set. ;

      data shared.lockTest;

            x=1;

      run;

 

      ** Be sure I can write to it. ;

      X 'chmod 774 /sasapp/datamart/data/dev/lockTest.sas7bdat';

     

      ** Set an exclusive lock on the data set so no one else can access it. ;

      lock shared.lockTest;

 

      ** When we are done testing, run this to release the lock.;

      ** lock shared.lockTest clear;

ENDRSUBMIT;

 

So then I run this code shouldn't SAS wait for the lock to release?  But it immediately throws an error.   Any ideas what's going on and how I can fix it?  Do I not understand how FIELOCKWAIT works?

 

RSUBMIT WFAUTO;  

      libname check '/sasapp/datamart/data/dev/ filelockwait=300;;

 

      data read; set check.lockTest;

      run;

ENDRSUBMIT;

 

85   data read; set check.lockTest;

ERROR: A lock is not available for CHECK.LOCKTEST.DATA.

ERROR: Lock held by process 22282672.

86   run;

 

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.READ may be incomplete.  When this step was stopped there were 0 observations and 0 variables.

WARNING: Data set WORK.READ was not replaced because this step was stopped.

NOTE: DATA statement used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

 


 

SASKiwi
PROC Star

Could it be that having FILELOCKWAITMAX set to 0 is overriding your filelockwait=300? Here is a snippet from the documentation:

 

A system administrator can change the maximum value using the FILELOCKWAITMAX= system option. Setting FILELOCKWAITMAX=0 effectively turns off the FILELOCKWAIT= option.

 

Documentation link:

http://documentation.sas.com/?docsetId=hostunx&docsetTarget=n01t25byodimrrn0zjsjz49t9l19.htm&docsetV...

 

Try changing your FILELOCKWAITMAX setting as well.

bentleyj1
Quartz | Level 8

Thanks SASKiwi.  I did read that in the documentation but it didn't register.  It seems clear enough.  If the max wait time is zero then telling it to wait for a couple minutes won't work.  I'll ask our SAS IT people to set FILELOCKWAITMAX to 600 in the configuration file.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 3560 views
  • 2 likes
  • 3 in conversation