Skip to content

At download the original modification time can be lost with a 1% chance #2252

Closed

Description

@VincentvgNn

Description

Uploading many files at one client and downloading (synchronizing) them at other clients leads to the loss of the modification date and time. It get's changed to the current date and time of the download.
The affected files are different for the clients that are downloading. So the date and time on the OC server are OK and it can be verified via the web UI as well.
This kind of change happens to about 1% of the files when simultaneously uploading and downloading many files.

For me the modification time is an important parameter that may never change until there is an intended change by one of the connected users.

Steps to reproduce

  1. Connect 3 client PC's, each with their own account to the OC server and use the web interface to let the Admin share a r/w folder with them.
    The server should be somewhere else on the internet, e.g. at some web-host.
  2. Copy a large amount of data (e.g. 500 MB, 3000 files, 300 folders) into the shared folder at client 1.
    The copying to the shared folder at client 1 will take about 10 minutes and meanwhile the uploading to the server will start.
    From the beginning on client 2 and 3 will start downloading the available files from the OC server.
  3. Due to quite some interrupts, a slow server and the large amount of files things can go wrong. The whole process might take about 5 hours. Deliberately disconnecting the home network from the internet can help to generate errors, but that is often not needed.
  4. Use the home network and a file comparison tool like Beyond Compare to compare all files and folders with the original non-shared folder at client 1 where the the files were copied from. Next the results in the shared folders at all 3 clients can be checked for errors. I always use an independent comparison on CRC and modification time.
    If client 2 and 3 do not have the same corrupted files, then the files are OK on the server.
  5. For about 1% of the downloaded files at client 2 and 3 the file modification time will be corrupted and have the time of the moment of download. The affected files are quite random and different for client 2 and 3.

Example of an equal file and a changed modtime:
4x new mod date on win8pc - small

Expected behavior

The original modification time should never be changed by ownCloud.

Client configuration

ownCloud version: 1.6.3
Operating system: Win XP, Win 7 or Win 8
Browser: Google Chrome (or Firefox or IE11)

Server configuration

ownCloud version: 7.0.2 (stable)
List of activated apps: default apps + encryption
External storage: no
Encryption: yes

OC server installed at a Dutch webhosting company. 4-5 GB storage.
Control via DirectAdmin and installation by using Installatron.
Own (non-shared) IP and using https.
Operating system: Linux Hosting Package
Web server: Apache
Database: MySQL
PHP version: native, 5.5.

Activity

  1. moscicki commented on Sep 26, 2014

    @moscicki
    Contributor

    What happens with the mtime of the files on the server? Are these also "corrupted" or are they all good?

    Secondly, have you tried to reproduce this scenario with 3 clients of the same user syncing a normal folder (non-shared one)? If you look at the server's implementation of sharing then hmm... everything's possible. I regularly see Shared files re-downloaded for no real reason (albeit with oc 5 server -- that may be very outdated sharing code on the server).

    A possible bug in a client would show up due to some race conditions with the new propagator downloading in parallel or possibly in case of some interrupted transfer. However, given the fact the the mtime is part of the reply headers of server's response the second thing is less likely. You may rule out the first possibility by forcing all clients to use single-threaded propagator (either by bandwidth throttling in the Settings or by env variable OWNCLOUD_MAX_PARALLEL=1).

    I would also try to rule out encryption from this picture.

    I guess what would help the devs are the client logs for the files with incorrect mtime.

  2. added this to the 1.7.1 milestone on Sep 27, 2014
  3. VincentvgNn commented on Sep 27, 2014

    @VincentvgNn
    Author

    @moscicki
    I checked 2 files on the exact mtimes:
    File 1:
    6x new mod date - 1x corrupt on win7pc-2-s2
    mtime client 1: 15-02-2012, 15:56:34
    mtime encrypted file on server: 15-02-2012, 15:56:34 (mtime is OK)
    mtime client 3: 24-09-2014, 12:06:26

    ctime client 1: 24-09-2014, 11:44:46
    ctime encrypted file on server: 24-09-2014, 12:06:29
    ctime client 3: 24-09-2014, 12:06:53 (24 sec from server to client 3 is quite short)

    File 2:
    6x new mod date - 1x corrupt on win7pc-2-s1
    mtime client 1: 5-12-2011, 19:04:00
    mtime encrypted file on server: 5-12-2011, 19:04:00 (mtime is OK)
    mtime client 3: 24-09-2014, 12:22:47

    ctime client 1: 24-09-2014, 11:45:28
    ctime encrypted file on server: 24-09-2014, 12:22:48
    ctime client 3: 24-09-2014, 12:23:31 (43 sec from server to client 3)

    At core issue #10975 I reported on Sept 12th a test with 3 clients on one Admin account, so no shared folders. There I found missing files on one of the clients. Unfortunately I did not record and keep all logging data. As far as a remember I got no files with the wrong mtime.
    And if you talk about re-downloading files with shared folders, ......., I found a bunch of them. Up to 5% on Sept 22th at that same issue. I reported it there, but I'm aware that I have to create a separate issue for that.

    The less features I use, the better things get. So I can rule out the encryption, but finally I want to use it in my users group. Besides ownCloud I have a website and a mail-system running at that same webhost on the same server, so I need the encryption just to make all files not too easy readable for those who do the website maintenance. And yes, I know that all needed for the decryption is unfortunately on the OC server.
    When talking about race conditions and bandwidth throttling, yes lowering the speed at some places can help, but I'm getting nervous from bugs that always can pop-up again. So I don't want to hide them, but discover them by creating more difficult conditions.
    Sooner or later the OC software should become more robust.

    If needed, I will redo the test and let the full logging run on all clients.

  4. dragotin commented on Sep 29, 2014

    @dragotin
    Contributor

    Is it possible that the download requests of the files in question timed out? There have been problems with that. Can you check the apache access log?

  5. moscicki commented on Sep 29, 2014

    @moscicki
    Contributor

    Even if they did than I am still puzzled why mtime would not be set? Unless we are talking about the file that was not downloaded at all to the client (so @VincentvgNn sees old file content with old mtime). @dragotin: is this what you mean?

  6. VincentvgNn commented on Sep 30, 2014

    @VincentvgNn
    Author

    File 1, I could trace down the following logged info:

    ctime client 1: 24-09-2014, 11:44:46
    upload at:
    [24/Sep/2014:12:06:24 +0200] "PUT /owncloud/remote.php/webdav/ ... /SdA%20Ledenlijst%20voor%20Bestuur%20per%2015-02-2012.xls HTTP/1.1" 201 802 "-" "Mozilla/5.0 (Windows) mirall/1.6.3"
    ctime encrypted file on server: 24-09-2014, 12:06:29
    download to client 3 at:
    [24/Sep/2014:12:06:52 +0200] "GET /owncloud/remote.php/webdav/ ... /SdA%20Ledenlijst%20voor%20Bestuur%20per%2015-02-2012.xls HTTP/1.1" 200 71631 "-" "Mozilla/5.0 (Windows) mirall/1.6.3"
    ctime client 3: 24-09-2014, 12:06:53
    download later to other client 2 at:
    [24/Sep/2014:12:15:10 +0200] "GET /owncloud/remote.php/webdav/ ... /SdA%20Ledenlijst%20voor%20Bestuur%20per%2015-02-2012.xls HTTP/1.1" 200 71631 "-" "Mozilla/5.0 (Windows) mirall/1.6.3"
    

    File 2, I could trace down the following logged info:

    ctime client 1: 24-09-2014, 11:45:28
    upload at:
    [24/Sep/2014:12:22:46 +0200] "PUT /owncloud/remote.php/webdav/ ... /Procedure%20aanname%20nieuwe%20leden%20V1.docx HTTP/1.1" 201 941 "-" "Mozilla/5.0 (Windows) mirall/1.6.3"
    ctime encrypted file on server: 24-09-2014, 12:22:48
    download to client 3 at:
    [24/Sep/2014:12:23:23 +0200] "GET /owncloud/remote.php/webdav/ ... /Procedure%20aanname%20nieuwe%20leden%20V1.docx HTTP/1.1" 200 20763 "-" "Mozilla/5.0 (Windows) mirall/1.6.3"
    ctime client 3: 24-09-2014, 12:23:31
    download later to other client 2 at:
    [24/Sep/2014:12:23:30 +0200] "GET /owncloud/remote.php/webdav/ ... /Procedure%20aanname%20nieuwe%20leden%20V1.docx HTTP/1.1" 200 20763 "-" "Mozilla/5.0 (Windows) mirall/1.6.3"
    

    @dragotin
    Is this the right apache access log info that you asked for?

    In the log file there were no more lines related to the specific 2 files during the next 12 hours..
    So the whole timing seems to be logical and there were no time-outs or retries.

    The error got at client 3 at just one first download.

  7. added a commit that references this issue on Nov 5, 2014
  8. VincentvgNn commented on Nov 27, 2014

    @VincentvgNn
    Author

    @ckamm
    Update:
    Some days ago I did a new test on file corruption.

    On PC2 I found 1 file where the original mtime was lost. New mtime 23-11-2014.
    On PC1 I found 2 other files where the original mtime was lost. New mtime 23-11-2014.

    Conclusion: Between OC server 7.0.3 and OC client 1.7.0 the problem of loosing the original mtime still exists.

    Test method:

    Same data set as in previous tests: 500 MB, 3000 files, 300 folders.
    OC server 7.0.3 at webhost
    OC client 1.7.0 if it can work. (On Win XP OC client 1.7.0 does not work.)
    3 PC's, each with an own account, connected to a shared folder, encryption was on.

    1. PC3: user3 WinXP OC client 1.6.4 got the 500 MB copied at once from a source folder into the shared folder and started uploading.
    2. PC2: user2 Win8 OC client 1.7.0 started downloading.
    3. PC1: user1 Win7 OC client 1.7.0 started downloading.
  9. dragotin commented on Nov 28, 2014

    @dragotin
    Contributor

    Hmm, some clearifications:

    • Only file modification time is synced. owncloud does not touch any ctime
    • Encryption is in use
    • There is no bandwith limiting in the client, right?

    So what happens is that the mtime that has to be set to the server file is transmitted as Header in the PUT request and the server is supposed to set it as atomar as possible. Maybe because of the encryption, there is a timegap between writing the file and making it visible to other clients and setting the timestamp.

    @PVince81 @schiesbn any opinion on this?

  10. self-assigned this
    on Nov 28, 2014
  11. PVince81 commented on Nov 28, 2014

    @PVince81

    As long as there is no high level file locking (owncloud/core#11804), no operation will be really atomic.

    Here is the code where the mtime is adjusted by touch: https://github.com/owncloud/core/blob/master/lib/private/connector/sabre/file.php#L144

    After the part file is assembled, it will not be visible to other clients yet.
    But as soon as the rename happens here https://github.com/owncloud/core/blob/master/lib/private/connector/sabre/file.php#L128 it will be available. Not sure if the rename itself could cause a delay, maybe if share keys are moved around.

  12. PVince81 commented on Nov 28, 2014

    @PVince81

    The rename + file_exist calls could also be slower if they happen on an external storage.

  13. dragotin commented on Nov 28, 2014

    @dragotin
    Contributor

    @PVince81 the question is: Is the file visible to other PROPFINDs after the file was assembled, but the timestamp was not yet adjusted? Note that moving of a file does not alter the modification time, so it should be fine to touch the file before the move happens - yet that might be not correct for external storage without posix move.

  14. VincentvgNn commented on Nov 28, 2014

    @VincentvgNn
    Author

    @dragotin
    There is no bandwidth limiting in the clients.
    I have OC running at a webhost where the server hardware is as usual shared with (many) other customers. So for me the speed limitation is on the server side. Interrupts in the connection happen sometimes.

    If needed I can make a timing analysis of the 3 latest November 23rd file samples where the original mtime was lost. In the same way as I did on 30-09-2014.
    So ctimes on all 3 clients, ctime of the server file and timing as in the PUT (1x) and GET (2x) commands.

  15. 9 remaining items

  16. modified the milestones: , 1.8 - UI Enhancements on Jan 19, 2015
  17. guruz commented on Jan 19, 2015

    @guruz
    Contributor

    Moving to 1.9 while waiting for the server guys to reply.

  18. VincentvgNn commented on Jan 19, 2015

    @VincentvgNn
    Author

    @guruz
    On January 17th I found again an example of a file where the mtime was changed to the current time.

    Meanwhile I'm using OC server 7.0.4 and OC client 1.8.0.4536-nightly20150108.

    On the server I can also find some files like: "filename".ocTransferId1566750467.part. These remaining partial files are not cleaned-up. Maybe this is another issue?

  19. PVince81 commented on Jan 20, 2015

    @PVince81

    I just raised owncloud/core#13498 to address this on the server side.

  20. VincentvgNn commented on Jan 20, 2015

    @VincentvgNn
    Author

    @PVince81
    Thanks a lot for moving ahead with this issue.

  21. PVince81 commented on Feb 9, 2015

    @PVince81

    Experimental fix here: owncloud/core#13985

  22. assigned and unassigned on Mar 13, 2015
  23. ogoffart commented on Mar 23, 2015

    @ogoffart
    Contributor

    Closing the client issue, it is being tracked on the server: owncloud/core#13498

  24. VincentvgNn commented on Mar 23, 2015

    @VincentvgNn
    Author

    @ogoffart
    OK to close it here.
    I hope that issue 13498 will be solved in server 8.1 after introduction of the solution discussed at
    owncloud/core#13823 .

  25. added a commit that references this issue on Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions