Page 1 of 2 12 LastLast
Results 1 to 35 of 36

Thread: Error happening - "No locks available"

  1. #1
    on hiatus
    Join Date
    Nov 2003
    Location
    UK
    Posts
    963
    Rep Power
    0

    Error happening - "No locks available"

    A script that I've run unchanged for years is failing with an error "No locks available".

    On looking at my logs I can see this error has happened before and seems to occur in 'patches', and then goes away. Seems I've just happened to access it myself during one of these patches!

    Any idea what this message might be suggesting?


    EDIT: It's now resolved itself... But from the error logs I can see it will seemingly happen again? Some sort of locking limit being hit on the box?

  2. #2
    HalfaBee's Avatar
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    7,266
    Rep Power
    26
    It is a limit set by the operating system, your script should check if the lock was not created and try again.
    I don't suffer from laziness, I enjoy every minute!
    Edit your php.ini here
    http://members.powweb.com/member/cgi...nt/PHPplus.bml

  3. #3
    on hiatus
    Join Date
    Nov 2003
    Location
    UK
    Posts
    963
    Rep Power
    0
    Quote Originally Posted by HalfaBee View Post
    It is a limit set by the operating system, your script should check if the lock was not created and try again.
    I could do that, but I suspect - from what I witnessed - it would be there for a few minutes...

    When I was trying to run the script, it failed on every attempt for a few minutes...

  4. #4
    HalfaBee's Avatar
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    7,266
    Rep Power
    26
    If your script retrys for a limited number of retrys, it should pick an empty lock.

    Locks should only exist for a short time, so multiple retrys increase the odds.
    I don't suffer from laziness, I enjoy every minute!
    Edit your php.ini here
    http://members.powweb.com/member/cgi...nt/PHPplus.bml

  5. #5
    on hiatus
    Join Date
    Nov 2003
    Location
    UK
    Posts
    963
    Rep Power
    0
    Quote Originally Posted by HalfaBee View Post
    If your script retrys for a limited number of retrys, it should pick an empty lock.

    Locks should only exist for a short time, so multiple retrys increase the odds.
    Hmm... So maybe try for 3 times with a second pause between each attempt before reporting an error?

    But as I said, I tried running my application a number of times over a number of minutes and got the error every time! I really don't believe if it tried repeatedly X times it would have succeeded?

    It had more the feel the doors were just shut!

  6. #6
    on hiatus
    Join Date
    Nov 2003
    Location
    UK
    Posts
    963
    Rep Power
    0
    Just witnessed another 20min period where I could not run my script at all. Every attempt resulted in the error. Looking at logs it could have been happening for hours before hand to? Not sure!

    Looking at my logs, I only had one occurrence of the problem this year, until Sep 16th, where it then started to become an almost daily occurrence... Getting worse and worse recently.

  7. #7
    on hiatus
    Join Date
    Nov 2003
    Location
    UK
    Posts
    963
    Rep Power
    0
    Anyone have any clues/suggestions of a way of getting around this?

    Best I've had from support so far is suggesting I clear my browser cache...

    Is FLOCK basically flocked?

  8. #8
    YvetteKuhns's Avatar
    Join Date
    Feb 2003
    Location
    Allentown, PA USA
    Posts
    15,244
    Rep Power
    34
    We had to find other methods rather than use flock since 2006. You and I have both had issues in the past that were not resolved. Why can't someone from staff post in the forum or knowledge base if this is still supported? I don't believe it is or most people just gave up trying to use it.
    Yvette Kuhns
    Power Pages Web Design
    Customized Internet Advertising Solutions

  9. #9
    HalfaBee's Avatar
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    7,266
    Rep Power
    26
    Neil, you probably need to create your own lock file system.

    basically just a lock dir where you write the filename if it is not there, if it is there, wait a while.
    Once you are finished writing remove the file from the lock dir.
    I don't suffer from laziness, I enjoy every minute!
    Edit your php.ini here
    http://members.powweb.com/member/cgi...nt/PHPplus.bml

  10. #10
    on hiatus
    Join Date
    Nov 2003
    Location
    UK
    Posts
    963
    Rep Power
    0
    Quote Originally Posted by YvetteKuhns View Post
    We had to find other methods rather than use flock since 2006. You and I have both had issues in the past that were not resolved. Why can't someone from staff post in the forum or knowledge base if this is still supported? I don't believe it is or most people just gave up trying to use it.
    I'm in the comical position now of:-
    Me - Here are logs show FLOCK failing to work 90 times yesterday...
    Support - Your site is working fine now... Clear your cache...
    Next day...
    Me - Here are logs show FLOCK failing to work 90 times yesterday...
    Support - Your site is working fine now... Clear your cache...
    Next day...
    Me - Here are logs show FLOCK failing to work 90 times yesterday...
    Support - Your site is working fine now... Clear your cache...

    I've even encountered the problem, got support to try it, and they've seen the problem... Still doesn't help!

    The only other variation I get is:-
    Support - Your application is at fault... Contact your vendor...

  11. #11
    on hiatus
    Join Date
    Nov 2003
    Location
    UK
    Posts
    963
    Rep Power
    0
    Quote Originally Posted by HalfaBee View Post
    Neil, you probably need to create your own lock file system.

    basically just a lock dir where you write the filename if it is not there, if it is there, wait a while.
    Once you are finished writing remove the file from the lock dir.
    Looking that way. But I'd prefer Powweb to admit FLOCK is <<not working>> so everyone knows where they stand first of all, rather than suggesting scripts are at fault, or you need to clear your cache
    Last edited by IanS; 12-3-08 at 05:09 AM. Reason: Moderated language!

  12. #12
    Former Spam Filter (EU) IanS's Avatar
    Join Date
    Mar 2004
    Location
    Washington (THE original UK one!)
    Posts
    12,964
    Rep Power
    30
    Your preferences are shared by many, but you know that here isn't the official place to present those views!
    This is a Powweb customer
    helping Powweb customer forum.

    I am a customer just like you!!

    Some matters can only be answered by staff or support.
    Give it a go - ask here first!

  13. #13
    on hiatus
    Join Date
    Nov 2003
    Location
    UK
    Posts
    963
    Rep Power
    0
    Quote Originally Posted by IanS View Post
    Your preferences are shared by many, but you know that here isn't the official place to present those views!
    I basically just want to find out if FLOCK is actually not usable?

    I'll continue with the ticket and see what happens. ie: If I can get a proper answer.


    I've now got a 10 line test script, so the next time I encounter the problem, if the test script also gives a problem, I'll point them to that, rather than a 5,000 line application.

    You never know it might just be a setting that needs changing!

    Before Sept 16th I basically never had the problem. After then it's a daily occurrence

  14. #14
    powweb staff mjandreau's Avatar
    Join Date
    Dec 1969
    Location
    Burlington, MA
    Posts
    0
    Rep Power
    0
    Check out http://us2.php.net/flock

    Towards the bottom it says that flock does not work on NFS file systems. At pow web ALL of your files that you access on the cgi servers are mounted up via nfs.

    I guess when they say it doesnt work. They mean they tested it and it doesnt work well. Knowing this I guess powweb can take the offical stance that It will not work on the servers.

  15. #15
    YvetteKuhns's Avatar
    Join Date
    Feb 2003
    Location
    Allentown, PA USA
    Posts
    15,244
    Rep Power
    34
    I basically just want to find out if FLOCK is actually not usable?
    I thought I remembered someone saying it was no longer usable, but I couldn't find proof of it. Isn't there a simple test that support could do and monitor to see if FLOCK works? If they can get something to work, they can tell you there is a problem with YOUR script. But that hasn't happened yet. And why did your script suddenly stop after all this time? Did something happen at that time?

    I've now got a 10 line test script, so the next time I encounter the problem, if the test script also gives a problem, I'll point them to that, rather than a 5,000 line application.

    You never know it might just be a setting that needs changing!
    Good idea. I hope it is just a setting that can fix the problem for you and anyone else.
    Yvette Kuhns
    Power Pages Web Design
    Customized Internet Advertising Solutions

  16. #16
    on hiatus
    Join Date
    Nov 2003
    Location
    UK
    Posts
    963
    Rep Power
    0
    Quote Originally Posted by YvetteKuhns View Post
    And why did your script suddenly stop after all this time? Did something happen at that time?
    My logs show there were a couple of occurrences of it early in the year on one day... Then nothing till September, and since then it's been happening basically every day to smoe degree - and recently is seems to be getting worse - hence my personally encountering it, and discovering it!

    Quote Originally Posted by YvetteKuhns View Post
    Good idea. I hope it is just a setting that can fix the problem for you and anyone else.
    Indeed... Next time I encounter it, I'll run my test script (that just opens, flocks and reads a file), and if that encounters a problem, then it seems quite black and white to me...

  17. #17
    YvetteKuhns's Avatar
    Join Date
    Feb 2003
    Location
    Allentown, PA USA
    Posts
    15,244
    Rep Power
    34
    Indeed... Next time I encounter it, I'll run my test script (that just opens, flocks and reads a file), and if that encounters a problem, then it seems quite black and white to me...
    I still think support should replicate this test if they won't run the test first. Then give a definitive answer to your question: Can we use flock here?
    Yvette Kuhns
    Power Pages Web Design
    Customized Internet Advertising Solutions

  18. #18
    Rick
    Join Date
    May 2002
    Location
    Minneapolis, MN
    Posts
    1,753
    Rep Power
    19
    I'd hesitated to chime in on this thread earlier because I wasn't sure if this was the same issue that, as Yvette mentions, we faced several years ago on the old Powweb. flock() doesn't work on systems like this where the filesystem is replicated across several servers because the locks are created at the OS level which doesn't get replicated. You have to replace flock() with the file or directory creation method that HalfABee describes to insure you have exclusive access to a data file.
    Rick Trethewey

  19. #19
    on hiatus
    Join Date
    Nov 2003
    Location
    UK
    Posts
    963
    Rep Power
    0
    Quote Originally Posted by rainbore View Post
    flock() doesn't work on systems like this where the filesystem is replicated across several servers because the locks are created at the OS level which doesn't get replicated.
    Aha! This rings a bell!

    But it still doesn't explain the error message does it?

  20. #20
    Former Spam Filter (EU) IanS's Avatar
    Join Date
    Mar 2004
    Location
    Washington (THE original UK one!)
    Posts
    12,964
    Rep Power
    30
    We now have an 'official' stance: Post #14 above. Unfortunately, Mike seems to be having a little technical problem here on the forums (he's recorded as having only made one post at present) and his post needed moderating whilst subsquent posts were made.
    This is a Powweb customer
    helping Powweb customer forum.

    I am a customer just like you!!

    Some matters can only be answered by staff or support.
    Give it a go - ask here first!

  21. #21
    YvetteKuhns's Avatar
    Join Date
    Feb 2003
    Location
    Allentown, PA USA
    Posts
    15,244
    Rep Power
    34
    Thanks, Mike and Ian. Neil keeps trying to make flock work here and this thread helps anyone who wanted the latest info on this subject.
    Yvette Kuhns
    Power Pages Web Design
    Customized Internet Advertising Solutions

  22. #22
    on hiatus
    Join Date
    Nov 2003
    Location
    UK
    Posts
    963
    Rep Power
    0
    Quote Originally Posted by IanS View Post
    We now have an 'official' stance: Post #14 above. Unfortunately, Mike seems to be having a little technical problem here on the forums (he's recorded as having only made one post at present) and his post needed moderating whilst subsquent posts were made.
    Maybe this forum is using FLOCK

    OK... I take FLOCK out of my scripts... It's worked for years though

  23. #23
    Former Spam Filter (EU) IanS's Avatar
    Join Date
    Mar 2004
    Location
    Washington (THE original UK one!)
    Posts
    12,964
    Rep Power
    30
    Quote Originally Posted by NeilFawcett View Post
    Maybe this forum is using FLOCK
    Or maybe he should come here and claim his site has been hacked , complain to support and to flush his cache!
    This is a Powweb customer
    helping Powweb customer forum.

    I am a customer just like you!!

    Some matters can only be answered by staff or support.
    Give it a go - ask here first!

  24. #24
    YvetteKuhns's Avatar
    Join Date
    Feb 2003
    Location
    Allentown, PA USA
    Posts
    15,244
    Rep Power
    34
    OK... I take FLOCK out of my scripts... It's worked for years though
    I still recall when there were changes that broke php pagination scripts for some of us. I couldn't understand why it stopped working and I had to hard code the page links for pages dynamically generated through php and MySQL. Things don't stay the same forever.
    Yvette Kuhns
    Power Pages Web Design
    Customized Internet Advertising Solutions

  25. #25
    on hiatus
    Join Date
    Nov 2003
    Location
    UK
    Posts
    963
    Rep Power
    0
    Quote Originally Posted by YvetteKuhns View Post
    I still recall when there were changes that broke php pagination scripts for some of us. I couldn't understand why it stopped working and I had to hard code the page links for pages dynamically generated through php and MySQL. Things don't stay the same forever.
    This is of course talking about things from MANY years ago.

    If I look at my scripts, FLOCK is being used as a last defense. Locking has typically been done using archaic directory creation methods etc, and then FLOCK is additionally being used as another layer of defense.

    That worked seemingly for many years...

    Then as of mid-september, FLOCK sometimes locks out for several minutes at a time with "No locks available".

    I can turn FLOCK usage off by switching a single flag in my scripts... But this of course means a change in behaviour in scripts that were written years ago, and have always run (fine) with the flag enabled...

    ie: Risk! Possible problems, and at worse data corruption.

  26. #26
    on hiatus
    Join Date
    Nov 2003
    Location
    UK
    Posts
    963
    Rep Power
    0
    Quote Originally Posted by mjandreau View Post
    Check out http://us2.php.net/flock

    Towards the bottom it says that flock does not work on NFS file systems. At pow web ALL of your files that you access on the cgi servers are mounted up via nfs.

    I guess when they say it doesnt work. They mean they tested it and it doesnt work well. Knowing this I guess powweb can take the offical stance that It will not work on the servers.
    Is this not down to the issue that the locking is done at OS level, so if two requests come in, hit different servers, they don't know each other have the file locked?

    But, I think that's quite a different issue to 'No locks available'? Which to me sounds like a server/OS hitting a locking limit?

  27. #27
    Former Spam Filter (EU) IanS's Avatar
    Join Date
    Mar 2004
    Location
    Washington (THE original UK one!)
    Posts
    12,964
    Rep Power
    30
    Whether this is the reason or not, we've been given an 'official' answer on this un-official method of communication.
    This is a Powweb customer
    helping Powweb customer forum.

    I am a customer just like you!!

    Some matters can only be answered by staff or support.
    Give it a go - ask here first!

  28. #28
    Custom User Title tpoynton's Avatar
    Join Date
    Sep 2004
    Location
    Mass
    Posts
    2,177
    Rep Power
    17
    Interestingly, I was advised here a while ago to use flock to prevent another problem. I'm not posting to complain, but inform.

  29. #29
    Former Spam Filter (EU) IanS's Avatar
    Join Date
    Mar 2004
    Location
    Washington (THE original UK one!)
    Posts
    12,964
    Rep Power
    30
    The architecture may have changed since then, the version of the OS has certainly changed.
    This is a Powweb customer
    helping Powweb customer forum.

    I am a customer just like you!!

    Some matters can only be answered by staff or support.
    Give it a go - ask here first!

  30. #30
    on hiatus
    Join Date
    Nov 2003
    Location
    UK
    Posts
    963
    Rep Power
    0
    Quote Originally Posted by IanS View Post
    The architecture may have changed since then, the version of the OS has certainly changed.
    As far as I'm concerned:-
    1) I think we know FLOCK has the issue that different servers may not know each other are locking the same file. So two requests which happen to hit different servers can none-the-less manipulate a file at the same even though the locks should prevent it - I'd forgotten about this. But I see my code is using FLOCK as another line of defense. ie: If archaic directory creation locking fails for some odd reason, hopefully FLOCK will catch it. It seems I left it as defensive programming (for a reason?).
    2) For me, as of some point around Sep 16th, something changed meaning FLOCK could (for minutes at a time) result in the error this thread is talking about. I see this as an entirely different matter (to 1). One that can hopefully be resolved, because I'd like to continue to use FLOCK in the defensive manner I have been for years. I have a horrible fealing that by losing this last line of defense (I put it in for a reason all those years ago), corruptions will occur.

    Anyway, I've given support screen shots of my little flock test program failing, hopefully somewhere someone will realise a setting is wrong or a spanner's been left in a machine

  31. #31
    PowWeb Staff Dbrazzell's Avatar
    Join Date
    Nov 2008
    Location
    Burlington
    Posts
    489
    Rep Power
    20
    Ill see if I can try and explain why we dont recommend flock here.

    Your site is hosted by a pool of cgi servers. Usually 5 or so are in the pool. At any one time you and your visitors are pretty evenly spread across the 5 servers in the pool. To you though it looks like just a single server on a single ip address. You cant see this easily from the outside looking in.

    Flock is a system that can alert the file system that some other process is using the file. However this type of data can not be transmitted over nfs which is what is used here. The other issue is that there is a pool of servers but the same filesystem is mounted up to all of them. Since flock doesn't work well and multiple people can be visiting your site at once on different servers. All kinds of strange behaviors will start to crop up. flock defiantly wont be able to do its job. I would imagine it gets worse the more people that use the site simultaneously.

  32. #32
    Custom User Title entrecon's Avatar
    Join Date
    Aug 2006
    Location
    Michigan
    Posts
    2,742
    Rep Power
    17
    So, when the problem started to get worse on the 16th it could have been the result of that server needing to balance the load more, or a need to balance more at the times that the error message is received?
    ________________________________
    Find me on twitter: @entrecon

  33. #33
    on hiatus
    Join Date
    Nov 2003
    Location
    UK
    Posts
    963
    Rep Power
    0
    Quote Originally Posted by Dbrazzell View Post
    Ill see if I can try and explain why we dont recommend flock here.

    Your site is hosted by a pool of cgi servers. Usually 5 or so are in the pool. At any one time you and your visitors are pretty evenly spread across the 5 servers in the pool. To you though it looks like just a single server on a single ip address. You cant see this easily from the outside looking in.

    Flock is a system that can alert the file system that some other process is using the file. However this type of data can not be transmitted over nfs which is what is used here. The other issue is that there is a pool of servers but the same filesystem is mounted up to all of them. Since flock doesn't work well and multiple people can be visiting your site at once on different servers. All kinds of strange behaviors will start to crop up. flock defiantly wont be able to do its job. I would imagine it gets worse the more people that use the site simultaneously.
    So just as I described in (1) above?

    As an alternative, can anyone guarentee creating a dir, and checking its existance, is water tight?

  34. #34
    on hiatus
    Join Date
    Nov 2003
    Location
    UK
    Posts
    963
    Rep Power
    0
    Quote Originally Posted by entrecon View Post
    So, when the problem started to get worse on the 16th it could have been the result of that server needing to balance the load more, or a need to balance more at the times that the error message is received?
    Who knows... Feels to me like a locking limit is being reached on the server(s). So when a lock is requested (by FLOCK) it is turned down resulting in an error?

    But I could be completely wrong...

  35. #35
    on hiatus
    Join Date
    Nov 2003
    Location
    UK
    Posts
    963
    Rep Power
    0
    Out of interest, my FLOCKTEST program is returning the error pretty frequently now (as if it's getting worse/more common still)...

    flocktest.pl
    Code:
    #!/usr/bin/perl
    use Fcntl qw(:DEFAULT :flock);
    print "Content-type: text/html\n\nFlock Test<BR>";
    
    sysopen(AC,'flocktest.txt',O_RDONLY) or return;
    flock(AC,1) or &die('Failure to lock file',$!);
    $rec=<AC>;
    close(AC) or &die('Failure to close file',$!);
    
    print "Record read fine! = $rec";
    
    exit;
    
    sub die{
    	my ($a,$b)=@_;
    	print "ERROR : $a | $b";
    	exit;
    }
    flocktest.txt:-
    Code:
    Here is some text for FLOCKTEST to read

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •