Skip to content

sync --checksum asumes equality if the requested hash is empty #5821

Closed

Description

@flyingflo

The associated forum post URL from https://forum.rclone.org

What is the problem you are having with rclone?

We sync RPM repos to minio with sync --checksum to avoid unecessary uploads due to fresh mtimes by git checkouts.
When minio metadata is not complete, it responds with an empty value for some files.

% rclone md5sum ps-minio:repos/dev/repos/AppStream/repodata
870a2871e9bb074c7bee9a0e8dd5d099  2c21ee95c4666fe64267acb68c2b3d7119fd95d7393a02f6e31ba0caf140ad1d-filelists.sqlite.bz2
a6143db0cf21f71512047373c8573907  3a4fce216624a6e9cdeb689989d8abb20854444ce2ccb2778dc0229c4b48895a-modules.yaml.gz
41b2623dbc708e1f0c79e82f8f5808d8  090387daa0e0d83fdd769f5a1c33a608a19b916689793e1acc0c84a45dcf15d3-other.xml.gz
674d8f62cafe1f001ce1fdad5216fe28  4dd86446f177292433f3f95ebc358f202d37fda2afa2b55627520e6134a548cf-other.sqlite.bz2
89ea26e50e956a7ee8ff6b961e9ec2d2  0337b80d5a3ae2e7f759dd977c580e9ab321e4c15c941580a5bb3f3f25b1373c-primary.sqlite.bz2
6105f54484102f330edabd6899160397  c439f06fc11bac7280db2d9e93b07e1670a8b3e0cfac7561e65bc7c09c299a39-filelists.xml.gz
90d3b828aea88859efb334710a93794a  557436444ced37a69e09b3eafb8e3a8e7cbf4928fa5ea0c39e702104983d255b-primary.xml.gz
                                  repomd.xml
                                  repomd.xml.asc
                                  27909a5cbe5e4aa4f1bca0a20d26beab30feffab222d4c08e48daf49732abdba-AppStream.xml.gz
                                  dd55118cafc6f88c45c5823398998b6b7dfa7eb136e5c0260ac62845d09fcc87-AppStream.xml

With --checksum rclone falls back to checking only file size (even if modification time differs), which happens to be identical with repomd.xml files, even if the content is different. This leads to an incomplete sync with --checksum with the message

<7>DEBUG : repomd.xml: Size of src and dst objects identical
<7>DEBUG : repomd.xml: Unchanged skipping

from

fs.Debugf(src, "Size of src and dst objects identical")

even if there was no hash comparison.

Quite surely, it is Minio's task to deliver hashes.
However, I think, rclone should rather upload the file, assuming there is a difference, than assuming no difference, if the backend doesn't deliver a proper hash for the file. This would lead to a synced state. (And minio does deliver a hash the next time).

I think the behaviour is defined here

return true, hash.None, srcHash, dstHash, nil
, where an empty value for the hash causes true as the return value, regardless of the comparison srcHash == dstHash

I would contribute a patch if you agree. Maybe it is sufficient to just return false?

What is your rclone version (output from rclone version)

% rclone --version
rclone v1.55.1-DEV
- os/type: linux
- os/arch: amd64
- go/version: go1.16.6
- go/linking: dynamic
- go/tags: none

Which OS you are using and how many bits (e.g. Windows 7, 64 bit)

Fedora 35, 64bit

Which cloud storage system are you using? (e.g. Google Drive)

S3 provided by minio

The command you were trying to run (e.g. rclone copy /tmp remote:tmp)

rclone sync -vv --dry-run --checksum BaseOS/repodata ps-minio:repos/dev/repos/BaseOS/repodata

A log from the command with the -vv flag (e.g. output from rclone -vv copy /tmp remote:tmp)

% rclone sync -vv --dry-run --checksum BaseOS/repodata ps-minio:repos/dev/repos/BaseOS/repodata
<7>DEBUG : Using config file from "/home/flo/.config/rclone/rclone.conf"
<7>DEBUG : rclone: Version "v1.55.1-DEV" starting with parameters ["rclone" "sync" "-vv" "--dry-run" "--checksum" "BaseOS/repodata" "ps-minio:repos/dev/repos/BaseOS/repodata"]
<7>DEBUG : rclone: systemd logging support activated
<7>DEBUG : Creating backend with remote "BaseOS/repodata"
<7>DEBUG : fs cache: renaming cache item "BaseOS/repodata" to be canonical "/home/flo/workspace/appliance/repo/repos/compose/repos/BaseOS/repodata"
<7>DEBUG : Creating backend with remote "ps-minio:repos/dev/repos/BaseOS/repodata"
<5>NOTICE: 8a73c672249495343d89c71026cedba96c21eadff264dea18ec1f7e4774198b2-primary.xml.gz: Skipped copy as --dry-run is set (size 518.789k)
<5>NOTICE: b7ac2c7c6d49884c7a57ef55209275ddd1b9b5cc056ffdcf91214cc8f343d64f-primary.sqlite.bz2: Skipped copy as --dry-run is set (size 1.023M)
<7>DEBUG : S3 bucket repos path dev/repos/BaseOS/repodata: Waiting for checks to finish
<7>DEBUG : 1b617942f20d311b8bf11381fa7ef6ba9741bd42609cdb3823c237a50d2c6096-other.xml.gz: MD5 = e4ee2f06705c4887f290f125757b45cb OK
<7>DEBUG : 1b617942f20d311b8bf11381fa7ef6ba9741bd42609cdb3823c237a50d2c6096-other.xml.gz: Size and MD5 of src and dst objects identical
<7>DEBUG : 1b617942f20d311b8bf11381fa7ef6ba9741bd42609cdb3823c237a50d2c6096-other.xml.gz: Unchanged skipping
<7>DEBUG : 52c91c31ee3a77d8de0fbf002dffc806915d1a9f8ed43ecfda58198e8f4e8274-other.sqlite.bz2: MD5 = 599334c0667fb52db9ecc8833536b380 OK
<7>DEBUG : 52c91c31ee3a77d8de0fbf002dffc806915d1a9f8ed43ecfda58198e8f4e8274-other.sqlite.bz2: Size and MD5 of src and dst objects identical
<7>DEBUG : 52c91c31ee3a77d8de0fbf002dffc806915d1a9f8ed43ecfda58198e8f4e8274-other.sqlite.bz2: Unchanged skipping
<7>DEBUG : 7d3aa90a56c029c0211125bcf75ebe2cbc46db3b32bba829dd1eecf94d1f8419-filelists.xml.gz: MD5 = 46222f71d9c2db4218fc396767abb32c OK
<7>DEBUG : 7d3aa90a56c029c0211125bcf75ebe2cbc46db3b32bba829dd1eecf94d1f8419-filelists.xml.gz: Size and MD5 of src and dst objects identical
<7>DEBUG : 7d3aa90a56c029c0211125bcf75ebe2cbc46db3b32bba829dd1eecf94d1f8419-filelists.xml.gz: Unchanged skipping
<7>DEBUG : 9803adc50549b2622417ef1854af098e47eb57d7c5c7b9f5453e2fa759ae89b7-filelists.sqlite.bz2: MD5 = 1b7b8238e8a8a99aea313ecc28ca9f13 OK
<7>DEBUG : 9803adc50549b2622417ef1854af098e47eb57d7c5c7b9f5453e2fa759ae89b7-filelists.sqlite.bz2: Size and MD5 of src and dst objects identical
<7>DEBUG : 9803adc50549b2622417ef1854af098e47eb57d7c5c7b9f5453e2fa759ae89b7-filelists.sqlite.bz2: Unchanged skipping
<7>DEBUG : 5adda870216ea0408db1fc92e241291d64217b49630af5372b53a289d1f288fa-BaseOS.xml.gz: Size of src and dst objects identical
<7>DEBUG : 5adda870216ea0408db1fc92e241291d64217b49630af5372b53a289d1f288fa-BaseOS.xml.gz: Unchanged skipping
<7>DEBUG : bbace2fff5b9ffd24dce0fdc487cf800c044b963a4235bbd0b4d7ce9ef7e3591-BaseOS.xml: Size of src and dst objects identical
<7>DEBUG : bbace2fff5b9ffd24dce0fdc487cf800c044b963a4235bbd0b4d7ce9ef7e3591-BaseOS.xml: Unchanged skipping
<7>DEBUG : repomd.xml: Size of src and dst objects identical
<7>DEBUG : repomd.xml: Unchanged skipping
<7>DEBUG : S3 bucket repos path dev/repos/BaseOS/repodata: Waiting for transfers to finish
<7>DEBUG : Waiting for deletions to finish
<5>NOTICE: 43ab631afdf6077457770df8f51cf65eb7156bb9c8a3519db090d995fb238564-primary.sqlite.bz2: Skipped delete as --dry-run is set (size 1.023M)
<5>NOTICE: f8d795be173427ec8d8d304f617459cf3f64956826d1888ffc3236c2f7b5cb3d-primary.xml.gz: Skipped delete as --dry-run is set (size 518.338k)
<5>NOTICE: repomd.xml.asc: Skipped delete as --dry-run is set (size 520)
<5>NOTICE: 
Transferred:        1.530M / 1.530 MBytes, 100%, 25.678 MBytes/s, ETA 0s
Checks:                10 / 10, 100%
Deleted:                3 (files), 0 (dirs)
Transferred:            2 / 2, 100%
Elapsed time:         0.1s

<7>DEBUG : 8 go routines active

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Activity

  1. ncw commented on Nov 17, 2021

    @ncw
    Member

    I don't think we can make that change by default.

    Currently --checksum with no checksum available implies --size-only so don't upload the file. If we change that to mean do upload the file then lots of peoples syncs will start uploading files. This may even upload continuously depending on the exact reason they haven't got a checksum.

    I think if you use --update --use-server-modtime instead of --checksum this may do exactly what you want.

    What this will do is if the modtime on the server is > the time of the file it will do nothing. However if it is < the time it will do a checksum comparison and if there is no checksum then the file will be forced to be uploaded.

    It might be worth a small scale test!

  2. flyingflo commented on Nov 19, 2021

    @flyingflo
    Author

    Thanks for your suggestion @ncw!
    It works great!

    I set up a testbed with a minio container, pre-populated it with some files, such that there are no checksums.

    • It recovers from the no-checksum state (not sure why exactly)
    • Then, it does not upload files that are unchanged but touched, i.e. have a fresh mtime, because it actually looks at md5 sums in that case.

    I must say, I wouldn't have expected that behaviour from the flag combination, but the docs of --update do explain that well.
    ..and its exactly what I want.

    Thanks, closing..

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions