Skip to content

bisync: normalize session name to non-canonical (and docs edits) - fixes #7423 - #7497

Merged
nielash merged 3 commits into
rclone:masterfrom
nielash:bisync-canonical
Jan 20, 2024
Merged

nielash merged 3 commits into
rclone:masterfrom
nielash:bisync-canonical

Conversation

@nielash

@nielash nielash commented Dec 9, 2023

Copy link
Copy Markdown
Contributor

(This PR is dependent on #7410 -- only 3 of the commits are new 🙂 )

What is the purpose of this change?

Before this change, bisync used the "canonical" Fs name in the filename for its listing files, including any {hexstring} suffix. An unintended consequence of this was that if a user added a backend-specific flag from the command line (thus "overriding" the config), bisync would fail to find the listing files it created during the prior run without this flag, due to the path now having a {hexstring} suffix that wasn't there before (or vice versa, if the flag was present when the session was established, and later removed.) This would sometimes cause bisync to fail with a critical error (if no listing existed with the alternate name), or worse -- it would sometimes cause bisync to use an old, incorrect listing (if old listings with the alternate name DID still exist, from before the user changed their flags.)

After this change, the issue is fixed by always normalizing the SessionName to the non-canonical version (no {hexstring} suffix), regardless of the flags. To avoid a breaking change, we first check if a suffixed listing exists. If so, we rename it (and overwrite the non-suffixed version, if any.) If not, we carry on with the non-suffixed version. (We should only find a suffixed version if created prior to this commit.)

The result for the user is that the same pair of paths will always use the same .lst filenames, with or without backend-specific flags.

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

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 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point of those {suffix} is a reminder that with different backend flags the contents of the remote may be different.

They were put in for the VFS caching to make sure we don't mix up data we shouldn't.

For example if you override the --drive-root-folder-id you'll get a different set of files. However a lot of the flags, eg --drive-list-chunk will not affect the files shown.

So by ignoring the {...} you are removing a safety check - we should be encouraging the users to put the config overrides into the config file so they remain static.

I see that bisync has exactly the same problem though with not being able to find previous listings.

Maybe we should merge your fix just with a warning to the user about getting the config overrides into the config file to make a static listing.

Happy to go with your decision here, so I shall approve this :-)

@nielash

nielash commented Jan 20, 2024

Copy link
Copy Markdown
Contributor Author

Thanks! Very good points. I think the safety check would be more properly addressed for Bisync by #5678 Sessions -- i.e. the ability for Bisync to detect that important flags have changed (whether backend or not) and require some extra confirmation like --force to proceed. I think the current {suffix} implementation has a few flaws:

  • it catches only backend-specific flags, even though other flags can also change the contents of the remote (for example --max-age, --ignore-case-sync)
  • it doesn't distinguish between important changes (--drive-root-folder-id) and unimportant changes (--drive-pacer-min-sleep)
  • putting the overrides in the config is not ideal for flags like --drive-skip-gdocs where sometimes I want it (bisync) and sometimes I don't (lsl). You'd have to either make two remotes or override the override with --drive-skip-gdocs=false when necessary, which is not terrible but slightly annoying 😄
  • The safety check can accidentally result in less safe behavior -- for instance, with Bisync, if it results in accidentally using old suffixed listings from a year ago that are still lying around.

Bisync users trip over this one quite a bit, so I think for the moment the unintended consequences outweigh the intended ones, and this feature should be merged, to be followed shortly by a better safety check via #5678.

As an aside: part of the reason I started working on a draft of #2697 (comment) (Profiles) is because I am considering this as a possible way to implement #5678, as ivandeex also alluded to on that ticket. Basically -- use the Profiles methods to store a Bisync session in the config, and then on each run Bisync can detect if there are important differences. But it would also be possible to avoid storing this in the config, if the Profiles feature is too big to take on right now (for instance, Bisync could just marshall the flag configuration to JSON and store in the workdir alongside its other listing files.) No pressure at all to look at it -- just thought I'd mention as it is relevant to this ticket!

as these changes did not make it in time for 1.65
Before this change, bisync used the "canonical" Fs name in the filename for its
listing files, including any {hexstring} suffix. An unintended consequence of
this was that if a user added a backend-specific flag from the command line
(thus "overriding" the config), bisync would fail to find the listing files it
created during the prior run without this flag, due to the path now having a
{hexstring} suffix that wasn't there before (or vice versa, if the flag was
present when the session was established, and later removed.) This would
sometimes cause bisync to fail with a critical error (if no listing existed
with the alternate name), or worse -- it would sometimes cause bisync to use an
old, incorrect listing (if old listings with the alternate name DID still
exist, from before the user changed their flags.)

After this change, the issue is fixed by always normalizing the SessionName to
the non-canonical version (no {hexstring} suffix), regardless of the flags. To
avoid a breaking change, we first check if a suffixed listing exists. If so, we
rename it (and overwrite the non-suffixed version, if any.) If not, we carry on
with the non-suffixed version. (We should only find a suffixed version if
created prior to this commit.)

The result for the user is that the same pair of paths will always use the same
.lst filenames, with or without backend-specific flags.
@nielash

nielash commented Jan 20, 2024

Copy link
Copy Markdown
Contributor Author

(rebased to clear out the duplicate commits)

@nielash
nielash merged commit d8e07bf into rclone:master Jan 20, 2024
@ncw

ncw commented Jan 22, 2024

Copy link
Copy Markdown
Member

Thanks! Very good points. I think the safety check would be more properly addressed for Bisync by #5678 Sessions -- i.e. the ability for Bisync to detect that important flags have changed (whether backend or not) and require some extra confirmation like --force to proceed. I think the current {suffix} implementation has a few flaws:

  • it catches only backend-specific flags, even though other flags can also change the contents of the remote (for example --max-age, --ignore-case-sync)

Hmm, yes! Though people don't usually use those with rclone mount which was the main user of this.

  • it doesn't distinguish between important changes (--drive-root-folder-id) and unimportant changes (--drive-pacer-min-sleep)

Aye. There is no way to do this other than markup all the individual config items which I decided was too much work!

  • putting the overrides in the config is not ideal for flags like --drive-skip-gdocs where sometimes I want it (bisync) and sometimes I don't (lsl). You'd have to either make two remotes or override the override with --drive-skip-gdocs=false when necessary, which is not terrible but slightly annoying 😄
  • The safety check can accidentally result in less safe behavior -- for instance, with Bisync, if it results in accidentally using old suffixed listings from a year ago that are still lying around.

Bisync users trip over this one quite a bit, so I think for the moment the unintended consequences outweigh the intended ones, and this feature should be merged, to be followed shortly by a better safety check via #5678.

That sounds fine to me.

I prefer the evolution towards perfection, than the striving for perfection immediately approach!

As an aside: part of the reason I started working on a draft of #2697 (comment) (Profiles) is because I am considering this as a possible way to implement #5678, as ivandeex also alluded to on that ticket. Basically -- use the Profiles methods to store a Bisync session in the config, and then on each run Bisync can detect if there are important differences. But it would also be possible to avoid storing this in the config, if the Profiles feature is too big to take on right now (for instance, Bisync could just marshall the flag configuration to JSON and store in the workdir alongside its other listing files.) No pressure at all to look at it -- just thought I'd mention as it is relevant to this ticket!

OK! I'm catching up on the PRs so will get to it soon :-)

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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bisync: session name should normalize to non-canonical version for overridden configs Bisync should be considered experimental

2 participants