Skip to content

feat(user): let only one MATLAB migrate user data at a time - #213

Draft
ehennestad wants to merge 1 commit into
chain-user-data-migrationsfrom
lock-user-data-migrations
Draft

ehennestad wants to merge 1 commit into
chain-user-data-migrationsfrom
lock-user-data-migrations

Conversation

@ehennestad

Copy link
Copy Markdown
Collaborator

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.lock in 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.acquireLock creates the file with java.io.File.createNewFile, which checks and creates as one atomic operation. It returns an onCleanup object, 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

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>
@ehennestad
ehennestad added this pull request to stack #212 November 9, 2026 09:02
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Test Results

789 tests  +5   788 ✅ +5   1m 26s ⏱️ -34s
 60 suites +1     1 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 53cc87f. ± Comparison against base commit db5055d.

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.

1 participant