Skip to content

Folder size not calculated (state 'pending') on 32-bit systems #28275

Closed

Description

@bcutter

Expected behaviour

Folder size gets calculated correctly for every (sub)folder

Actual behaviour

Since upgrade from v9.1.6 I was wondering why desktop client showed "0 KB is used" in account tab.

First, running occ files:scan made some improvement; now "only" two subfolders aren´t calculated - state "pending". Running occ files:scan for affected user account or even using "--path=/username/files/affected/path" option didn´t fix it.

In MySQL db "select COUNT(fileid) from oc_filecache where size like "-1"" gives 290 entries; most of them exactly in those two affected subfolders.

How can I fix that? Do I need to edit those database rows manually? Can I re-create them, only for the two affected subfolders? As already mentioned, occ files:scan with "--path=/username/files/affected/path" option doesn´t work.

Server configuration

Operating system:
Raspbian Jessie
Web server:
nginx
Database:
MySQL
PHP version:
5.6
ownCloud version: (see ownCloud admin page)
10.0.2.1
Updated from an older ownCloud or fresh install:
Updated from 9.1.6 to 10.0.2.1
Where did you install ownCloud from:
native package from website (no OS repositories)
Signing status (ownCloud 9.0 and above):
few errors

https://gist.github.com/bcutter/d43ca098412a1aed3bdc9170c31ffbcc

Are you using external storage, if yes which one: local/smb/sftp/...
No, everything local in /owncloud/data/
Are you using encryption: yes/no
no

Activity

  1. bcutter commented on Jul 1, 2017

    @bcutter
    Author

    Guys I need a fix for this. Even a (temporary) workaround would be good at the moment. What is the problem here? How does file and folder size calculation work internally in owncloud? What about the database I mentioned above?

  2. PVince81 commented on Jul 3, 2017

    @PVince81
    Contributor
  3. bcutter commented on Jul 3, 2017

    @bcutter
    Author

    Yes, that's what we do here right? OwnCloud central sent me over here. I already put in a lot of research and testing time, without success. So the last alternative is to ask the experts. That's why we're here.

    Similar but not exactly same problems: #16742, #13876

  4. PVince81 commented on Jul 3, 2017

    @PVince81
    Contributor

    Can you link to your posts on central if they contain information about your research ?

  5. PVince81 commented on Jul 11, 2017

    @PVince81
    Contributor

    @FCTURNER were this old folders that suddenly switched to "Pending" ? Or are these newly added big folders ?

    Are you running on a 32-bit system ? (to exclude potential "large folder handling" issues)

    Normally for existing local folders (assuming no shares not federated shares), the state should never switch back to "Pending" after the value was already set to something. The code that updates the value runs when modifying the contents of the folder and only adds or substracts integers from that column. So not sure what could cause this.

    You could check the DB before and after the update: select * from oc_filecache where size=-1 (size -1 is the "pending" value)

  6. PVince81 commented on Jul 11, 2017

    @PVince81
    Contributor

    and... apologies for my brief moment of weakness.

  7. bcutter commented on Jul 11, 2017

    @bcutter
    Author

    No problem @PVince81, we all are humans (most of us :-) ) and I really believe you guys have a lot of work to do here - and I´m happy you do this work for us (users).

    In my case, OC is running on a Raspberry Pi 2. To add further information, here some of external posts (from OwnCloud Central), so we have all possibly relevant information here:

    Same problem with v10.0.2.1. Since upgrade from v9.1.6 I was wondering why desktop client showed "0 KB is used" in account tab.

    Running occ files:scan made some improvement; now "only" two subfolders aren´t calculated - state "pending". Running occ files:scan for affected user account or even using "--path=/username/files/affected/path" option didn´t fix it.

    In MySQL db "select COUNT(fileid) from oc_filecache where size like "-1"" gives 290 entries; most of them exactly in those two affected subfolders.

  8. PVince81 commented on Jul 11, 2017

    @PVince81
    Contributor

    @bcutter ok so in your case it's about a SMB external storage.

    @FCTURNER can you confirm whether you observe the problem only on external storages or also local storage ?

    @bcutter there is a cron / background job that should process the "size = -1" items in the database in small batches. You could try running php cron.php or sudo -uwww-data php cron.php a few times and see if the number of "size = -1" entries in the DB is getting down.

    I do find it strange that occ files:scan with path doesn't help. Did you try adding -vvvvvv at the end of the command ? It should show you what folders it's scanning into, see if it goes into the "Pending" folder at all.

  9. bcutter commented on Jul 11, 2017

    @bcutter
    Author

    Thanks for your input, I can work on that.

    1. No it´s local storage, in standard data directory (/.../owncloud/data).
    2. I will try running the cron a few times, having a look at "sudo watch -n1 'mysql select statement'".
    3. I didn´t use the -vvvvvv (I guess 'verbose' = debug?) option so far; I will do so and come back with the results in a few hours.
  10. PVince81 commented on Jul 11, 2017

    @PVince81
    Contributor

    No it´s local storage, in standard data directory (/.../owncloud/data).

    If the folders were created over Webdav or OC web UI, they should already have the correct size, not "Pending". Are you modifying/adding folders into "owncloud/data" outside of the ownCloud interfaces ? Usually it's not recommanded to use OC that way as OC has no way to detect such changes and you need to resort to occ files:scan. Let's see what the verbose mode says...

  11. bcutter commented on Jul 11, 2017

    @bcutter
    Author

    @PVince81: The affected folders are pretty old (static folder structure) and I´m pretty sure they were created using OC Desktop-Client = WebDAV.

    Ha, good point, there might be an event related to that scenario ("modifying/adding folders into "owncloud/data" outside of the ownCloud interfaces"): A few days after the update to OC v10 there was a full system (file and folder structure 1:1 from tar backup) and MySQL database restore. Both things (files + database) were exactly the same as before (so files and oc_filecache table fit together). And - important! - I already detected the pending state after the update from OC v9.1.6 to v10.0.2.1, so I´m pretty sure the backup restore isn´t relevant. But to be fair I of course want to provide all information available.

    So, to summarize: No, adding/modifying/deleting files from the user´s data folders not using standard channels like web or OC desktop client is NOT performed.

  12. PVince81 commented on Jul 31, 2017

    @PVince81
    Contributor

    Hmmm but the size column is a bigint, so it's 64 bits, it shouldn't be able to wrap back to negative values. That is, unless it's your PHP version that is wrapping back to negative values ? Are you using a 32-bit PHP version by any chance ? There used to be issues with values bigger than 2 GB.

  13. 41 remaining items

  14. phil-davis commented on Aug 8, 2017

    @phil-davis
    Contributor

    Whenever an is_numeric() string is put into a calculation, it is made into a number and the calculation is done. If small enough to fit into the platform MAXINT it happily works like an int. If bigger, then it goes in a float/double. If it overflows double then the answer is double(INF)
    So an is_numeric() string all the time should work just as well as it being a proper "int" when small and a "string" when big. I guess there will be a little bit of performance difference in what is mostly an int being converted to a string to be passed back and forth, then automagically type-converted to int when used in a calculation.

  15. jvillafanez commented on Aug 8, 2017

    @jvillafanez
    Member

    I think the best solution is to return numeric strings as @mrow4a has said. For calculations with sizes, we could try the BC Math extension: http://www.php.net/manual/en/book.bc.php

    Note that anyway, I expect a lot of changes.

  16. phil-davis commented on Aug 8, 2017

    @phil-davis
    Contributor

    bcadd() works nicely - feed it 2 is_numeric() strings or int in any combination and length/size and it gives you back the sum as an is_numeric() string
    when you need to store the number in a database, then you have to think how best to do it - packed-BCD anyone :)
    and there would be some performance overhead for 99.99% of cases where there is 64-bit int available, or a 32-bit system with a small install.

  17. jvillafanez commented on Aug 8, 2017

    @jvillafanez
    Member

    If the performance loss of using the BC match extension is negligible in every system, I'd just use it without any check.

    We can create a FileSizeOperations class, or something like that, to wrap all of the size operations and work with the BC match extension transparently. If it really make sense, we can optimize the class to use integers under several circumstances, but anyway, the class would work with string and would return string.
    Note that working with integers there might be an overoptimization that might not be worthy: the performance gain we could have by using integers could be lost due to the extra checks we'll need to do. In addition, the code will be more complex and difficult to maintain.

  18. individual-it commented on Aug 8, 2017

    @individual-it
    Member

    well, PHP returns a string instead of an int based on the platform for big numbers... so much for consistency. Doesn't make it possible to have consistent interfaces.

    I thought Doctrine would always return strings regardless of the system (32/64bit) if we use BIGINT in the database https://doctrine-orm.readthedocs.io/projects/doctrine-dbal/en/stable/reference/types.html#bigint
    so that getSize() would always return a string

  19. PVince81 commented on Aug 9, 2017

    @PVince81
    Contributor

    We can create a FileSizeOperations class

    this might go a bit too far just for quick 32-bit compatibility

  20. PVince81 commented on Aug 9, 2017

    @PVince81
    Contributor

    especially for something that worked before but somehow was just inconsistent with the interfaces.

    It seems that with all this type weirdness it is not possible to have a clean typed interface and at the same type 32-bit compatibility.

  21. PVince81 commented on Aug 11, 2017

    @PVince81
    Contributor

    Revert PR here #28649 for the short term

  22. bcutter commented on Sep 1, 2017

    @bcutter
    Author

    I just wanted to confirm: I changed the FileInfo.php manually. The PR revert worked, everything back normal now.

    I´m just wondering what happens on the update to OC v10.0.3... is this revert merged to master or will I need to do the modification of FileInfo.php again after next update? Thank you all so far for your efforts.

  23. jvillafanez commented on Sep 4, 2017

    @jvillafanez
    Member

    There is a backport to stable10 so it will be for 10.0.3, no need to change anything.

  24. removed this from the triage milestone on Apr 10, 2018
  25. lock commented on Jul 30, 2019

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  26. locked as resolved and limited conversation to collaborators on Jul 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions