Repository navigation
feat(user): let only one MATLAB migrate user data at a time - #213
Draft
ehennestad wants to merge 1 commit into
Draft
ehennestad wants to merge 1 commit into
ehennestad wants to merge 1 commit into
Conversation
Every MATLAB release shares the user data directory, so two sessions can start together and both try to move the same folders. Each would see the other's half finished work. A session with something to migrate now holds a lock file in the user data directory while it does so. A second session waits for it, and then finds the work done. A session with nothing to migrate does not wait. The file is created with java.io.File.createNewFile, which is atomic. After two minutes the waiting session stops with an error that names the file to delete if no other MATLAB is running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every MATLAB release shares the user data directory, so two sessions can start at the same moment and both try to move the same folders. Each sees the other's half finished work. In a test with three sessions starting together on the same data, one moved it and the other two failed the move, fell back to the preference directory and showed an empty project list.
Change
A session with something to migrate holds
.nansen_migration.lockin the user data directory while it does so. A second session waits for the file to go away and then finds the work done. A session with nothing to migrate does not wait, so a normal startup is unaffected.nansen.internal.migration.acquireLockcreates the file withjava.io.File.createNewFile, which checks and creates as one atomic operation. It returns anonCleanupobject, so the file is removed when the migration returns or throws.After two minutes the waiting session stops with
NANSEN:Migration:LockTimeout. The message names the file to delete if no other MATLAB is running. A lock is not taken over automatically, because a holder that is slow cannot be told apart from one that has stopped. Any other failure to create the lock means the directory cannot be written to, which the existing move handles by using the preference directory for that session.🤖 Generated with Claude Code