Skip to content

fs/operations: do ignore size when --ignore-size is specified along with --checksum - #4011

Closed
tiborvass wants to merge 0 commit into
rclone:masterfrom
tiborvass:checksum-ignore-size
Closed

tiborvass wants to merge 0 commit into
rclone:masterfrom
tiborvass:checksum-ignore-size

Conversation

@tiborvass

@tiborvass tiborvass commented Feb 27, 2020 •

Copy link
Copy Markdown

What is the purpose of this change?

This fixes a bug where two different but same-sized objects that cannot be compared
with checksum are considered equal even though --checksum and --ignore-size are
specified.

To test this, use an existing s3 bucket on AWS that was not created with rclone and
that has objects uploaded with multi-part (ETAG != MD5) then try to sync from it to
some destination, twice in a row. The second time it should copy again the objects
that do not have a hash, instead of relying on --size-only behavior.

If someone can add a test for this case, I'd appreciate it!

IMHO, --ignore-size (and not --size-only) should be the default fallback, when
--checksum is specified.

Was the change discussed in an issue or in the forum before?

Unsure.

Checklist

  • I have read the contribution guidelines.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • I'm done, this Pull Request is ready for review :-)

@ncw

ncw commented Feb 27, 2020

Copy link
Copy Markdown
Member

To test this, use an existing s3 bucket on AWS that was not created with rclone and
that has objects uploaded with multi-part (ETAG != MD5) then try to sync from it to
some destination, twice in a row. The second time it should copy again the objects
that do not have a hash, instead of relying on --size-only behavior.

Is this using

rclone copy --checksum --ignore-size s3:bucket /local/path

?

Can you describe the workflow that causes this problem. I don't understand why you would use --ignore-size - it is quite an esoteric option.

In general rclone prefers not to keep copying objects so you can run the command multiple times.

@tiborvass

tiborvass commented Feb 27, 2020 •

Copy link
Copy Markdown
Author

@ncw Thanks for your response!

I was using rclone sync --checksum --ignore-size s3:bucket s3:otherbucket but the same would be true for local destination.

The workflow is that I'm copying/syncing to a bucket from another existing bucket that was not created with rclone and has objects that were multipart uploaded, think "backup bucket". By changing one byte in such an object and attempting to copy it to the backup bucket, you will notice that because it has the same size, it doesn't copy, even though: 1. the files are different, and 2. I specified --ignore-size.

Maybe this will help understand:

$ mkdir dir dir2
$ bucket=mybucket
$ dd if=/dev/urandom bs=9M count=1 | base64 > dir/file       # I believe default for multipart_threshold is 8M
$ dd if=/dev/urandom bs=9M count=1 | base64 > dir2/file     # create a different file with same size
$ aws s3 cp --recursive dir s3://$bucket/dir
$ aws s3 cp --recursive dir2 s3://$bucket/dir2
$ wc -c dir/file; wc -c dir2/file             # different content, but same size (and above multipart_threshold)
12748477 dir/file
12748477 dir2/file
$ aws s3api head-object --bucket $bucket --key dir/file         # note the -2 in ETAG showing multipart upload
{
    "AcceptRanges": "bytes",
    "LastModified": "Thu, 27 Feb 2020 21:24:45 GMT",
    "ContentLength": 12748477,
    "ETag": "\"547717adb79902aaf28e20b0eed60cb0-2\"",
    "VersionId": "null",
    "ContentType": "binary/octet-stream",
    "Metadata": {}
}
$ aws s3api head-object --bucket $bucket --key dir2/file
{
    "AcceptRanges": "bytes",
    "LastModified": "Thu, 27 Feb 2020 21:24:49 GMT",
    "ContentLength": 12748477,
    "ETag": "\"33391fd40656ffa4eb9dfa2be9336202-2\"",
    "VersionId": "null",
    "ContentType": "binary/octet-stream",
    "Metadata": {}
}
$ rclone -v --checksum --ignore-size copy s3:$bucket/dir s3:$bucket/dir2
2020/02/27 21:25:24 INFO  : S3 bucket $bucket path dir2: Waiting for checks to finish
2020/02/27 21:25:24 NOTICE: S3 bucket $bucket path dir2: --checksum is in use but the source and destination have no hashes in common; falling back to --size-only
2020/02/27 21:25:24 INFO  : S3 bucket $bucket path dir2: Waiting for transfers to finish
2020/02/27 21:25:24 INFO  :
Transferred:             0 / 0 Bytes, -, 0 Bytes/s, ETA -
Checks:                 1 / 1, 100%
Elapsed time:         0.0s

It should have transferred (IMHO even if --ignore-size is not specified, but this PR is about at least honoring --ignore-size).

Hopefully this helps!

I don't understand why you would use --ignore-size - it is quite an esoteric option.

In general rclone prefers not to keep copying objects so you can run the command multiple times.

I must say I'm a bit surprised by that. I agree that --ignore-size is an esoteric option, but possibly not for the same reasons: I believe it should be the default. And as a user I expect rclone by default to prioritize copying the correct files before optimizing transfer, providing optimization opt-ins for people who have additional knowledge of their data (for instance if they know size changes over time, they can go with size comparison). In other words, overoptimizing to the point of incorrectness seems very weird to me.

@tiborvass

Copy link
Copy Markdown
Author

If it helps, s3cmd does want to copy.

$ s3cmd cp -n s3://$bucket/dir s3://$bucket/dir2
copy: 's3://$bucket/dir' -> 's3://$bucket/dir2'
WARNING: Exiting now because of --dry-run

@thaJeztah

Copy link
Copy Markdown

ping @ncw PTAL 🙏🤗

@thaJeztah

Copy link
Copy Markdown

@ncw could you have a look to see if there's any objections against this change?

@ivandeex

ivandeex commented Nov 17, 2020 •

Copy link
Copy Markdown
Member

@tiborvass
I rebased the fix on master but forgot to re-commit so the branch stayed on par with rclone master.
When I force-pushed, github said PR has no new commits, closed it and revoked my permission for this branch 😡
Sorry about that.
Currently the branch is on par with master.
Please re-apply the rebased commit ivandeex@6066adf from here:
https://github.com/ivandeex/rclone/commits/tiborvass--checksum-ignore-size
It should re-open the PR
Sorry again 😞

@ivandeex

ivandeex commented Nov 26, 2020 •

Copy link
Copy Markdown
Member

This PR is unfortunately broken by me (can be revived by ivandeex@6066adf) and forgotten by its authors.

However it serves as a good example of uncontrolled complexity (see #4793 (comment)) of the "equal" method and around, which used to grow organically in response to the stream of change detection feature requests, often serving contradictory user requirements such as consistency (this PR #4011 (comment)), cost savings (see #2889 (comment)) and many others (sometimes unexplained ;)), blurring the line between "bug" ang "feature".

This in turn has led to a number of change-related CLI flags (see https://rclone.org/flags), some of them having negative (no-check), conditional (x-if-y) or even double-negative (noignore) names, which interact in exotic ways with 30+ supported backends (https://rclone.org/overview#features) and their (in)ability to provide required traits.

On top of that we have filtering flags and two unobviously different commands: sync vs copy. I feel that many users won't feel difference between them and documentation doesn't stress enough.

In the end we might expect that any behavior can be requested, even that that feels esoteric or illogical.
¯\_(ツ)_/¯

This probably calls for some brushing (#4793 (comment)):

This seems like a big effort covering <5% of user base so I'm not sure.
OTOH there is a generalization PR #3782 (multiwrite union) that has been a success.

@ncw ?

@ncw

ncw commented Nov 26, 2020

Copy link
Copy Markdown
Member

However it serves as a good example of uncontrolled complexity (see #4793 (comment)) of the "equal" method and around, which used to grow organically in response to the stream of change detection feature requests, often serving contradictory user requirements such as consistency (this PR #4011 (comment)), cost savings (see #2889 (comment)) and many others (sometimes unexplained ;)), blurring the line between "bug" ang "feature".

I think we could inventory the flags to see where we are at.

However I don't want to break backwards compatibility, so if we want to change stuff then we need to do so carefull!

The equal function has been reasonably stable, I think the only thing added to it recently is --refresh-times - which is a very specialised options.

User demand is how rclone has gained new features, though we need to be careful to push back on ones which aren't of general interest.

This in turn has led to a number of change-related CLI flags (see https://rclone.org/flags), some of them having negative (no-check), conditional (x-if-y) or even double-negative (noignore) names, which interact in exotic ways with 30+ supported backends (https://rclone.org/overview#features) and their (in)ability to provide required traits.

Indeed. N-flags * N-providers * N-options-per-provider is a big number.

On top of that we have filtering flags and two unobviously different commands: sync vs copy. I feel that many users won't feel difference between them and documentation doesn't stress enough.

More docs for sync and copy would be appreciated. The sync page has lots of warnings on now as a result of user accidents.

In the end we might expect that any behavior can be requested, even that that feels esoteric or illogical.

Yes, users want to get their stuff done, it is our job to keep rclone consistent!

This probably calls for some brushing (#4793 (comment)):

I'll just copy the comment here

Idea: pause adding new --no-ignore-x-if-prefer-y flags for now. Add examples to docs for existing flags, they cover 95% of known use cases. For remaining 5%, create an issue to design a flag like --change-criteria +time,-size,whatever.

I think that is a good plan to control the complexity.

This seems like a big effort covering <5% of user base so I'm not sure.

Making a generalised solution will mean that advanced users will have somewhere to go when then need to get stuff done, but hopefully a much smaller subset of flags will cover the main use cases (eg --checksum, --size-only).

I like that idea. We could implement it then deprecate flags which we don't like. (You can hide flags so they still work but are hidden).

OTOH there is a generalization PR #3782 (multiwrite union) that has been a success.

Great idea.

I especially like your moratorium on adding more complexity to what we've got already.

Do you want to make an issue, then we can think about all the things which might need to be controlled?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants