Skip to content

Two pushes of the same file at about the same time result in no changes in the etag. #7802

Closed

Description

@ogoffart

Owncloud version: stable6 branch

As shown on this capture, two PUT request done in the same second lead to the same Etag.
(This bug make the client test fail from time to time)

PUT /~owncloud/remote.php/webdav/t1-0736/remoteToLocal1/kernelcrash.txt HTTP/1.1
Content-Type: application/octet-stream
OC-Total-Length: 0
X-OC-Mtime: 1395236757
Authorization: Basic ****=
User-Agent: Mozilla/5.0 (Linux) mirall/1.6.0
Content-Length: 0
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
Accept-Language: en-US,*
Host: localhost



HTTP/1.1 201 Created
Date: Wed, 19 Mar 2014 13:45:57 GMT
Server: Apache/2.2.26 (Unix) mod_ssl/2.2.26 OpenSSL/1.0.1f DAV/2 PHP/5.5.9
X-Powered-By: PHP/5.5.9
Set-Cookie: oca639a7e5c4=supirjc4f7am0fc9i85s5s81j2; path=/~owncloud; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
X-OC-MTime: accepted
OC-FileId: 00007464oca639a7e5c4
Content-Length: 0
ETag: "53299f9583680"
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html




PUT /~owncloud/remote.php/webdav/t1-0736/remoteToLocal1/kernelcrash.txt HTTP/1.1
TE: deflate,gzip;q=0.3
Connection: TE, close
Authorization: Basic ****=
Host: localhost:80
User-Agent: DAV.pm/v0.44
Content-Length: 57

This is more stuff
This is more stuff
This is more stuff


HTTP/1.1 204 No Content
Date: Wed, 19 Mar 2014 13:45:57 GMT
Server: Apache/2.2.26 (Unix) mod_ssl/2.2.26 OpenSSL/1.0.1f DAV/2 PHP/5.5.9
X-Powered-By: PHP/5.5.9
Set-Cookie: oca639a7e5c4=th31snq6m7eajm8495cqls0p67; path=/~owncloud; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
OC-FileId: 00007464oca639a7e5c4
Content-Length: 0
ETag: "53299f9583680"
Connection: close
Content-Type: text/html

Activity

  1. karlitschek commented on Mar 19, 2014

    @karlitschek
    Contributor

    Hmm. I´m not sure the server guarantees that etags are unique between files. @dragotin What do you think?

  2. ogoffart commented on Mar 19, 2014

    @ogoffart
    Author

    I Forgot to mention that it is the same file.

  3. changed the title [-]Two files pushed at the same time have the the same etag.[/-] [+]Two pushes of the same file at about the same time result in no changes in the etag.[/+] on Mar 19, 2014
  4. dragotin commented on Mar 19, 2014

    @dragotin
    Contributor

    The same etag for two subsequente PUTs on the same file is a bug of death. For two different files, it would probably be ok, but still not nice.

  5. DeepDiver1975 commented on Mar 19, 2014

    @DeepDiver1975
    Contributor

    The etag is generated using uniqid() - http://php.net/manual/en/function.uniqid.php

    And there is a big red warning on the documentation:

    Warning
    
    This function does not create random nor unpredictable string. This function must not be used for 
    security purposes. Use cryptographically secure random function/generator and cryptographically
     secure hash functions to create unpredictable secure ID.
    
  6. DeepDiver1975 commented on Mar 19, 2014

    @DeepDiver1975
    Contributor
    Gets a prefixed unique identifier based on the current time in microseconds. 
    
  7. DeepDiver1975 commented on Mar 19, 2014

    @DeepDiver1975
    Contributor

    Does that mean if one executes uniqid() in the same microsecond on two different php processes it can return the same value?

    @ogoffart this occurred while testing parallel upload I assume?

  8. ogoffart commented on Mar 19, 2014

    @ogoffart
    Author

    No, this was running the client tests perl scripts.
    the perl script is running some commands to upload files and then we sync.
    There must be more than a µs between the two calls.
    (about 400ms according to the wireshark timing)

  9. DeepDiver1975 commented on Mar 19, 2014

    @DeepDiver1975
    Contributor

    in this case I assume a server side issue where we use a not-yet-updated etag

  10. DeepDiver1975 commented on Mar 20, 2014

    @DeepDiver1975
    Contributor

    I'll take care of this

  11. DeepDiver1975 commented on Mar 20, 2014

    @DeepDiver1975
    Contributor

    uniqid() has some know limitation - we shall replace it with e.g. \OC_Util::generateRandomBytes(13)

    But this is not the root of this issue.

  12. PVince81 commented on Mar 20, 2014

    @PVince81
    Contributor

    Not directly related but it reminds me of a time where our unit tests were using the current time() timestamp value and when the machine was too fast, the same timestamp would come out and cause trouble.

    Will generateRandomBytes() affect performance in any way (compared to uniqid) ?
    I see that it first uses openssl if available, else /dev/urandom (on Linux), else a custom algorithm.

  13. PVince81 commented on May 6, 2014

    @PVince81
    Contributor

    @DeepDiver1975 did you find further useful information ?

  14. karlitschek commented on Dec 5, 2014

    @karlitschek
    Contributor

    @DeepDiver1975 Is this still valid?

  15. DeepDiver1975 commented on Mar 20, 2015

    @DeepDiver1975
    Contributor

    @ogoffart still an issue? we changed the etag generation function in OC8+ - I'd assume this issue is solved by now.

  16. PVince81 commented on Mar 23, 2015

    @PVince81
    Contributor

    @jnfrmarks this should be testable somehow with smashbox (and a bit of timing luck)

  17. PVince81 commented on Jun 22, 2015

    @PVince81
    Contributor

    Hopefully solvable with high level file locking: #16237

  18. MorrisJobke commented on Dec 11, 2015

    @MorrisJobke
    Contributor

    Please reopen this if this still happens with high level file locking enabled.

  19. added this to the 8.2 milestone on Dec 11, 2015
  20. lock commented on Aug 7, 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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions