Skip to content

handle local disk full properly (affects data integrity) #2939

Closed

Description

@moscicki

Currently the client misses on handling of local disk full condition. This causes random crashes and is susceptible to corrupt data (or sync journal).

Client should require some minimal space being available on the disk hosting the sync folder(s) and enter "idle" mode when there is not enough disk space. For example, google drive pauses operation when free disk space is < ~1GB.

For implementation, one may use existing OS APIs, if not provided by Qt. Python example:

def get_free_space_mb(folder):
    """ Return folder/drive free space (in bytes)
    """
    if platform.system() == 'Windows':
        free_bytes = ctypes.c_ulonglong(0)
        ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(folder), None, None, ctypes.pointer(free_bytes))
        return free_bytes.value/1024/1024
    else:
        st = os.statvfs(folder)
        return st.f_bavail * st.f_frsize/1024/1024

This needs some additinal testing on less frequent filesystems (such as Windows DFS).

Activity

  1. dragotin commented on Mar 10, 2015

    @dragotin
    Contributor

    I agree, suggest to do it for 1.8.1, @MTRichards

  2. MTRichards commented on Mar 10, 2015

    @MTRichards
  3. moscicki commented on Mar 10, 2015

    @moscicki
    ContributorAuthor

    I though about some cases:

    • no activity in sync client, disk usage grows independently of the sync client -> a simple periodic check and a check before starting any update activity could suffice
    • disk space going low due to the sync client itself performing downloads -> this requires some check integrated into the propagator itself (to pause it, snapshot the state and then resume it at some later stage)...
    • there could be also a combination of these two factors, in which case a sufficiently high threshold could be enough to cover all real-world scenarios...
    • if we are really paranoid about zero bytes left and the sync journal we may also foresee to have a placeholder file to book the minimal space required to cleanly shutdown sqlite db (not sure if that's an issue)
  4. dragotin commented on Mar 10, 2015

    @dragotin
    Contributor

    I think after the discovery phase (which does not need disk space) we should be able to calculate how much space change need for performing the sync. A decent safety belt can be added and we should be able to estimate if space is sufficient or not.

    Notes:

    1. We need to find a efficient, cross platform way of getting the free disk space of the the partition on which the sync directory is located. That might be tricky.
    2. To do it perfectly nice, we would need to do the calculation about the available free space as we sync, as third party processes could eat up the space while we are working. Not sure if that is required...
  5. added this to the 1.8.1 - Bugfix milestone on Mar 27, 2015
  6. modified the milestones: , 1.8.1 - Bugfix on Apr 8, 2015
  7. guruz commented on May 5, 2015

    @guruz
    Contributor

    Related #3144

  8. modified the milestones: , 2.0 - Multi-account on Jul 29, 2015
  9. MTRichards commented on Sep 2, 2015

    @MTRichards

    As a user, I want the desktop client to recognize when the addition of new files and folders added to the server and synced to the desktop will fill the local disk space, to not sync these new folders and files, and to throw a notification of the failure so that the desktop I am using doesn't crash using the desktop client.

    Acceptance Criteria:

    • To start, the desktop client will not attempt to use the last 250MB of free disk space on a client
    • When the desktop client identifies that new or updated files downloaded from the server will reduce the free space on the desktop to under 250MB, the desktop client will not sync any files from that point forward until the sync run will fall below 250MB
    • The desktop client will throw a red check mark and the sync run gets a fatal error “The sync client needs to sync XGB/MB of files, but only has room for Y GB/MB. Please free space on the disk before syncing.”
    • The calculations for the disk size needed includes all meaningful consumers of disk by the client (for example, he temp file)
    • At a future date, a different algorithm (% of free disk space for example, or a higher disk limit) may be needed.
      untitled
  10. 30 remaining items

  11. removed
    ReadyToTest
    on Nov 5, 2015
  12. phil-davis commented on Nov 5, 2015

    @phil-davis
    Contributor

    I believe OWNCLOUD_CRITICAL_FREE_SPACE is in MB. So, if you have 100GB free space on your local disk (=100,000MB) then you have to set:
    OWNCLOUD_CRITICAL_FREE_SPACE=100000
    (or more)
    So that the actual free space on your local disk is less than OWNCLOUD_CRITICAL_FREE_SPACE

  13. Dianafg76 commented on Nov 6, 2015

    @Dianafg76

    My free space on my local i 737.54 GB drive, so I have to set
    OWNCLOUD_CRITICAL_FREE_SPACE=737540
    And What is the next step?

  14. phil-davis commented on Nov 6, 2015

    @phil-davis
    Contributor

    Now put some files on the server using the web interface. The client should start to sync and then report that there is not enough space on the local disk.
    You might need to increase OWNCLOUD_CRITICAL_FREE_SPACE even more, because it depends how your system measures 737.54 GB - maybe that is 737540 MB or maybe 737.54 * 1024 = 755241 MB - you can make it 800000 to be sure :)

  15. Dianafg76 commented on Nov 6, 2015

    @Dianafg76

    @guruz

    1. I set the OWNCLOUD_CRITICAL_FREE_SPACE= 703373
    2. Go to the Server web
    3. Upload some Files
    4. Go to the Desktop client
    5. Waiting to sync

    CURRENT BEHAVIOR

    The client is started to sync and I don't have the report.
    I don't have the report that there is not enough space on the local disk

  16. phil-davis commented on Nov 6, 2015

    @phil-davis
    Contributor

    I think you will need to set OWNCLOUD_CRITICAL_FREE_SPACE to a higher number. OWNCLOUD_CRITICAL_FREE_SPACE needs to be bigger than the free space on your local disk.

  17. ckamm commented on Nov 10, 2015

    @ckamm
    Contributor

    @Dianafg76 @phil-davis Actually, OWNCLOUD_CRITICAL_FREE_SPACE is in bytes (also says so here: https://github.com/owncloud/client/wiki/Testing-Scenarios-2.1)

    So you want to set it to something like 8589934592 (800GB).

  18. added
    ReadyToTest
    and removed on Nov 10, 2015
  19. ckamm commented on Nov 10, 2015

    @ckamm
    Contributor

    @Dianafg76 In new builds these env variables have been renamed to OWNCLOUD_CRITICAL_FREE_SPACE_BYTES and OWNCLOUD_FREE_SPACE

  20. phil-davis commented on Nov 10, 2015

    @phil-davis
    Contributor

    @ckamm Thanks, from the numbers @Dianafg76 was using at first I just assumed that they were KB - I should read the doc or the code :)

  21. removed
    ReadyToTest
    on Nov 11, 2015
  22. Dianafg76 commented on Nov 11, 2015

    @Dianafg76

    I tested this issue and finally is working OK for my.
    Many thanks to @ckamm and @phil-davis for helping me
    Desktop v ownCloud-2.1.0.2865-nightly20151110.pkg
    Server v {"installed":true,"maintenance":false,"version":"8.1.4.0","versionstring":"8.1.4 RC1","edition":""}

    Closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

p2-hightype:bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions