Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recreate mutagen sync session when mutagen.yml changes, fixes #4753 #4837

Merged
merged 6 commits into from
Apr 26, 2023

Conversation

rfay
Copy link
Member

@rfay rfay commented Apr 19, 2023

The Issue

A sync session can outlive the mutagen.yml file, as it's not checked again after creation

How This PR Solves The Issue

  • Add a label to the mutagen sync session with the SHA1 hash of the existing mutagen.yml
  • On start, check to see if the hash remains the same
  • If not, recreate the sync session (and volume)

Manual Testing Instructions

  • ddev start and review the mutagen sync identifier (ddev mutagen st -l | grep Identifier)
  • Change mutagen.yml (make sure to remove #ddev-generated)
  • ddev restart and verify that you have a new mutagen sync session (ddev mutagen sync st -l | grep Identifier)
  • ddev restart without changes and verify you have the same session identifier now

Automated Testing Overview

Added TestMutagenConfigChange and TestFileHash

Release/Deployment Notes

  • It may be wise for people to ddev mutagen reset on the new release.

@github-actions
Copy link

github-actions bot commented Apr 19, 2023

@rfay rfay marked this pull request as ready for review April 20, 2023 13:43
@rfay rfay requested a review from a team as a code owner April 20, 2023 13:43
Copy link

@xenoscopic xenoscopic left a comment

Choose a reason for hiding this comment

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

Hey @rfay, I had a look over this and I think the strategy is good; similar to what Mutagen Compose does (Mutagen Compose actually does an in-memory configuration comparison, but the result is the same). I only had one comment and it may be something that is already addressed elsewhere in the code.

@@ -976,12 +976,20 @@ Fix with 'ddev config global --required-docker-compose-version="" --use-docker-c

if app.IsMutagenEnabled() {
if ok, volumeExists, info := CheckMutagenVolumeSyncCompatibility(app); !ok {
util.Debug("mutagen sync session and docker volume are in incompatible status: '%s', Removing mutagen sync session '%s' and docker volume %s", info, MutagenSyncName(app.Name), GetMutagenVolumeName(app))
util.Debug("mutagen sync session, configuration, and docker volume are in incompatible status: '%s', Removing mutagen sync session '%s' and docker volume %s", info, MutagenSyncName(app.Name), GetMutagenVolumeName(app))
terminateErr := TerminateMutagenSync(app)

Choose a reason for hiding this comment

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

I think my only comment would be that it might be worth flushing the stale session before terminating it, that way both endpoints are theoretically the same when the new session is created. Doing that will help ensure that the first reconciliation pass of the new synchronization session will construct a virtual ancestor that's (ideally) equal to both endpoints (and that way no pending unsynced changes are lost and converted to conflicts when the new empty ancestor is created in the new session).

However, my guess is that a flush may be done elsewhere, just before CheckMutagenVolumeSyncCompatibility (and potentially TerminateMutagenSync) is invoked, so if that's the case then just ignore this comment.

Mutagen should probably eventually add a mechanism to transfer the virtual ancestor from one session to a new one (maybe a mutagen sync update command, or something). There are some complexities with that, but it should be possible someday.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks so much, will check!

@rfay rfay force-pushed the 20230419_mutagen_check_yml branch 2 times, most recently from 64adf28 to 3f6b835 Compare April 24, 2023 01:30
@rfay rfay force-pushed the 20230419_mutagen_check_yml branch from 3f6b835 to 63ddf57 Compare April 25, 2023 22:18
@rfay rfay merged commit 91a12cb into ddev:master Apr 26, 2023
11 checks passed
@rfay rfay deleted the 20230419_mutagen_check_yml branch April 26, 2023 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants