[solved] litespeed files locking

Discussion in 'General' started by bobykus, Sep 4, 2013.

  1. bobykus

    bobykus Member

    We are using NFS for users data and now faced with issue. litespeed keeps files locked for a longer period, even correspondent php process is ended. It means, f.ex., you can not update Wordpress correctly. During update process WP deleting some files in folders. But it fails because of .nfs files present and locked. It is well known NFS feature called silly rename -http://nfs.sourceforge.net/ . So it looks like

    wp-content/themes/twentytwelve/js/.nfs0000000090a508c80000020f

    can not be removed. And yes, file is locked by web server process for some time.

    lsof | grep .nfs0000000090a508c80000020f
    litespeed 29471 httpd mem REG 0,23 863 2426734792 ..../wp-content/themes/twentytwelve/js/.nfs0000000090a508c80000020f (...:/mnt/data/.../home)

    even lsphp process is done and nobody else access web site. from WP point of view you have a broken site, because update process fails in theme deleting stage and you have no default theme at all!
    Is it possible to avoid web sites files locking by litespeed process?
    Last edited by a moderator: Sep 6, 2013
  2. mistwang

    mistwang LiteSpeed Staff

    LiteSpeed uses MMAP to optimize static file delivery. but in this case, MMAP has to be avoided. You need to change server configuration under tuning tab:
    Max MMAP File Size (bytes): 0
    Total MMAP Cache Size (bytes): 0
    Use Asynchronized disk I/O (AIO): Yes (Do not use "Keep file mapped")
  3. bobykus

    bobykus Member

    Perfect, thank you!
    BTW, do you think it can cause performance degradation?
  4. mistwang

    mistwang LiteSpeed Staff

    It depends, maybe a little bit.
  5. bobykus

    bobykus Member

    Well,

    The issue still exists - tried to update WP plugins and get

    The update process is starting. This process may take a while on some hosts, so please be patient.

    Enabling Maintenance mode…

    Updating Plugin Updater (1/2)
    Downloading update from http://downloads.wordpress.org/plugin/updater.1.10.zip…
    Unpacking the update…
    Installing the latest version…
    Removing the old version of the plugin…
    Plugin update failed.
    An error occurred while updating Updater: Could not remove the old plugin.


    lsof | grep wp-content/plugins/updater/css/.nfs00000000744e488700000001
    litespeed 11226 httpd 38r REG 0,23 3669 1951287431 ...wordpress361/wp-content/plugins/updater/css/.nfs00000000744e488700000001 (...)



    grep -i mmap /usr/local/lsws/conf/httpd_config.xml
    <maxMMapFileSize>0</maxMMapFileSize>
    <totalMMapCacheSize>0</totalMMapCacheSize>

    grep useAIO /usr/local/lsws/conf/httpd_config.xml
    <useAIO>1</useAIO>


    What else to adjust to avoid litespeed of locking files on NFS?
  6. mistwang

    mistwang LiteSpeed Staff

    It means that the file is opened with file handle #38, still being accessed by clients.
    It is not MMAPed. web server need to keep the file open in order to send the file back to clients. The css is a file used during performing the update. web server keep the file open when a file is accessed, and wait for a little while to close it up when nobody accessing the file to avoid repeatedly open/close the same file.

    And it is not possible to completely avoid this kind situation not matter we do in the web server, even we close the file more frequently, what if the file being accessed while update script trying to remove the directory?
    it should be addressed in the updater script to take that into account.
  7. bobykus

    bobykus Member

    Ah, OK - so it is all because of WP!
  8. bobykus

    bobykus Member

    Well,

    Looks like the issue still exists. It is reproducible when I' trying to update or deinstall w3 total cache plugin in WP. Files in js folder remains, .nfsxxx fines are locked by litespeed process. The settings are exactly as you recommend.
  9. mistwang

    mistwang LiteSpeed Staff

    Open a file is expensive as we have to go through all the security checks, so LiteSpeed will keep the file open when it was serving to someone, we already added logic to close the file as soon as LiteSpeed done serving that file.

    We will revisit it in our 5.0 release see if anything more we can do about it.

    So, when PHP script try to remove a folder under NFS, "rm -r folder_name" will fail if someone is till accessing a file under that folder even the file will be closed in timely manner. I do not think there is a perfect solution for it.
  10. bobykus

    bobykus Member

    It is possible to avoid file locking at all?
  11. mistwang

    mistwang LiteSpeed Staff

    You are asking if possible to serve content of a file without opening it. :)
    We will do more testing to make sure that server does not keep the file open for reuse.
    You can check if new NFS client implementation see if have implementation that does not rely on silly rename.
  12. mistwang

    mistwang LiteSpeed Staff

    Please try 4.2.12, it is more aggressive with closing open file descriptors.
    For user experiencing NFS silly rename trouble, can configure LSWS to cache small files in memory when possible to minimize open files by tuning
    "Max Cached Small File Size", "Total Small File Cache Size", can start from

    "Max Cached Small File Size" = 100K
    "Total Small File Cache Size" = 100M

    http://www.litespeedtech.com/docs/webserver/config/tuning#maxCachedFileSize
  13. bobykus

    bobykus Member

    yaaay... will do!
  14. bettinz

    bettinz Member

    I've tried with 100K, but this is the error:
    number valid range: 0 - 16384
    *number exceeds maximum allowed
  15. mistwang

    mistwang LiteSpeed Staff

    You can modify the configuration file directly. the webadmin console limit need to be changed.

Share This Page