Repository navigation
fix(fs): make concurrent Windows junction creation atomic - #13009
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughWindows directory symlink creation now injects the creator through retries, while Windows junctions use staged, serialized commits with destination inspection and cleanup. Regression tests cover concurrent callers and missing link parents, and CI runs the missing-parent scenario. ChangesWindows junction atomicity
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
There was a problem hiding this comment.
Pull request overview
This PR adds a Windows-specific regression test intended to reproduce a race when multiple threads concurrently create the same junction-backed directory link (observed as ERROR_DIRECTORY / os error 267 in native installs). It also adds a test-only hook to force the Windows implementation into junction mode to make the race reproducible regardless of symlink privileges.
Changes:
- Add a Windows concurrency regression test that spawns multiple threads racing to create the same junction link and asserts only one writer “creates” while the rest reuse.
- Add a
#[cfg(test)]helper to force the Windows symlink writer to use the junction branch.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pnpm/crates/fs/src/symlink_dir/tests.rs | Adds a Windows regression test for concurrent junction creation behavior. |
| pnpm/crates/fs/src/symlink_dir.rs | Adds a test-only helper to force junction mode in the Windows writer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Confidence Score: 5/5The change is safe to merge. It introduces new Windows-only production code and accompanying tests; no cross-platform logic is affected. The staging-plus-lock approach is sound: each worker gets a unique path derived from PID and a monotonic counter, so there is no reuse across process runs or between concurrent callers. The commit lock correctly serializes only the existence-check + rename step, keeping the expensive junction creation parallel. Post-rename and post-cleanup error paths all return AlreadyExists-kinded errors so force_symlink_inner routes them to the reuse branch rather than failing the install. The ConcurrentCleanupWarning mechanism correctly propagates diagnostic text without blocking the install. All three concerns from the previous review rounds are fully resolved in this commit, and the new concurrency regression test exercises exactly the original failure scenario. No files require special attention. Reviews (12): Last reviewed commit: "chore(ci): remove temporary Windows boot..." | Re-trigger Greptile |
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.9947898384000005,
"stddev": 0.5289049494919972,
"median": 3.7733728212,
"user": 3.5879353800000002,
"system": 3.4579926800000003,
"min": 3.6695105302,
"max": 5.4004400662,
"times": [
5.4004400662,
3.7009209682,
3.7401518782000003,
4.203581124199999,
4.1512701802,
3.6823796052,
3.7516796322,
3.8528983892000004,
3.6695105302,
3.7950660102000002
]
},
{
"command": "pacquet@main",
"mean": 3.736362246400001,
"stddev": 0.16652819936002072,
"median": 3.6750886867,
"user": 3.54086948,
"system": 3.4374007799999995,
"min": 3.6092284522000004,
"max": 4.1529259642,
"times": [
4.1529259642,
3.6092284522000004,
3.6670332012,
3.6322062212,
3.6670347662,
3.6976192442,
3.6831426072,
3.8996201962000003,
3.6500477642000004,
3.7047640472000003
]
},
{
"command": "pnpr@HEAD",
"mean": 2.1317741164000004,
"stddev": 0.15381221135716217,
"median": 2.0566629612000003,
"user": 2.70882848,
"system": 3.0566375799999994,
"min": 1.9784981732,
"max": 2.4267371982,
"times": [
2.0275575592000004,
2.0245109202,
2.1913917872,
2.0228579982,
2.0121890492000003,
2.3361817822,
2.4267371982,
1.9784981732,
2.0857683632,
2.2120483332000003
]
},
{
"command": "pnpr@main",
"mean": 2.1986858172000003,
"stddev": 0.15048303125328175,
"median": 2.2208318062000005,
"user": 2.64221488,
"system": 3.0538555799999996,
"min": 1.9949159082,
"max": 2.3702773912,
"times": [
2.3283055112000004,
2.1049654842,
2.1157227622000003,
2.0657147712,
1.9949159082,
2.3702773912,
2.3259408502000003,
2.3333100202000003,
2.0203264792,
2.3273789942
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6540759325200001,
"stddev": 0.006827726111968664,
"median": 0.65443563492,
"user": 0.38275403999999996,
"system": 1.3406391,
"min": 0.64193611492,
"max": 0.66398090192,
"times": [
0.64193611492,
0.66398090192,
0.6579781759200001,
0.6599667409200001,
0.65386839992,
0.65110824392,
0.6481179769200001,
0.6481257489200001,
0.66067415192,
0.65500286992
]
},
{
"command": "pacquet@main",
"mean": 0.6674617827200001,
"stddev": 0.029236323431586622,
"median": 0.6596030204200001,
"user": 0.38399803999999993,
"system": 1.3486395,
"min": 0.64501182292,
"max": 0.7470291509200001,
"times": [
0.6770824819200001,
0.6607776469200001,
0.65804460492,
0.64501182292,
0.66114267392,
0.66106559892,
0.64790538892,
0.6581300639200001,
0.6584283939200001,
0.7470291509200001
]
},
{
"command": "pnpr@HEAD",
"mean": 0.74171450642,
"stddev": 0.07237750334520944,
"median": 0.71245131892,
"user": 0.39830204,
"system": 1.3707227999999998,
"min": 0.6917663929200001,
"max": 0.9271332699200001,
"times": [
0.79761837392,
0.7453643159200001,
0.70078034592,
0.69920228792,
0.6917663929200001,
0.6996284839200001,
0.70765588292,
0.9271332699200001,
0.73074895592,
0.71724675492
]
},
{
"command": "pnpr@main",
"mean": 0.7272561586200001,
"stddev": 0.056581303563296555,
"median": 0.7093720544200001,
"user": 0.39334463999999997,
"system": 1.3725484000000001,
"min": 0.68217002392,
"max": 0.8729118089200001,
"times": [
0.6988428469200001,
0.6976853339200001,
0.68357908692,
0.7105470249200001,
0.68217002392,
0.71552941392,
0.8729118089200001,
0.7488163899200001,
0.75428257292,
0.70819708392
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.294160315299999,
"stddev": 0.047913931195528024,
"median": 4.294548063400001,
"user": 3.7890636799999995,
"system": 3.44730364,
"min": 4.2181518304,
"max": 4.3630378384,
"times": [
4.2181518304,
4.2829372094,
4.2942849414,
4.3396038744,
4.3630378384,
4.3488931344,
4.2948111854,
4.2487218364,
4.2424291713999995,
4.3087321314
]
},
{
"command": "pacquet@main",
"mean": 4.2385958389,
"stddev": 0.03518117404084179,
"median": 4.235211790399999,
"user": 3.7298760799999995,
"system": 3.409938139999999,
"min": 4.2006690874,
"max": 4.3019023214,
"times": [
4.2811316734,
4.2381764664,
4.2542183364,
4.2591669054,
4.2322471144,
4.2052844974,
4.3019023214,
4.2094731484,
4.2006690874,
4.2036888384
]
},
{
"command": "pnpr@HEAD",
"mean": 2.1809703244999996,
"stddev": 0.06489972933872258,
"median": 2.1809462619,
"user": 2.5406659799999995,
"system": 2.9448200399999998,
"min": 2.0993268494,
"max": 2.2858752663999997,
"times": [
2.1012881984,
2.2379853454,
2.1074137954,
2.1732594274,
2.2251293764,
2.2324240304,
2.1886330964,
2.0993268494,
2.1583678593999998,
2.2858752663999997
]
},
{
"command": "pnpr@main",
"mean": 2.2408652688999995,
"stddev": 0.10650092094959714,
"median": 2.2135900254000003,
"user": 2.4732157799999994,
"system": 2.97768964,
"min": 2.1097335254,
"max": 2.3725554614,
"times": [
2.1243458133999997,
2.3240913764,
2.2167402764,
2.1923171394,
2.2104397744,
2.3704136094,
2.3588417254,
2.3725554614,
2.1291739873999997,
2.1097335254
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.34277832874,
"stddev": 0.011164392776721611,
"median": 1.34367342304,
"user": 1.29223812,
"system": 1.71078222,
"min": 1.32272083504,
"max": 1.35812176304,
"times": [
1.3282851310400001,
1.3544171650399999,
1.32272083504,
1.35812176304,
1.33717425704,
1.34601339904,
1.34939813204,
1.34133344704,
1.3495998600399999,
1.34071929804
]
},
{
"command": "pacquet@main",
"mean": 1.3862776482399999,
"stddev": 0.0811486971159814,
"median": 1.35956768704,
"user": 1.30763762,
"system": 1.73818612,
"min": 1.33727972904,
"max": 1.61251013004,
"times": [
1.38880553904,
1.61251013004,
1.38393872704,
1.35347594704,
1.35704853004,
1.36208684404,
1.34322752104,
1.35371328704,
1.37069022804,
1.33727972904
]
},
{
"command": "pnpr@HEAD",
"mean": 0.67045210614,
"stddev": 0.034960866769563025,
"median": 0.6611080140400001,
"user": 0.33360812,
"system": 1.2917949199999998,
"min": 0.6445973700400001,
"max": 0.76791560404,
"times": [
0.66511502004,
0.6445973700400001,
0.6621937370400001,
0.65714534104,
0.76791560404,
0.66002229104,
0.66657187204,
0.65963042804,
0.6686167820400001,
0.65271261604
]
},
{
"command": "pnpr@main",
"mean": 0.66508983414,
"stddev": 0.007782942471721463,
"median": 0.6638636440400001,
"user": 0.34535541999999997,
"system": 1.28902762,
"min": 0.6537289900400001,
"max": 0.6788719320400001,
"times": [
0.66354454304,
0.6567324090400001,
0.6537289900400001,
0.6717969580400001,
0.66076141604,
0.66081620204,
0.6641827450400001,
0.6788719320400001,
0.6672119830400001,
0.67325116304
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.04809216802,
"stddev": 0.0651426385757837,
"median": 3.02052424662,
"user": 1.7762440800000001,
"system": 1.9984982599999999,
"min": 2.98572890912,
"max": 3.21536974112,
"times": [
3.01481387912,
3.01625974512,
3.01126529912,
2.98572890912,
3.01589294712,
3.06731761112,
3.02478874812,
3.21536974112,
3.07778510812,
3.05169969212
]
},
{
"command": "pacquet@main",
"mean": 3.0578040476200004,
"stddev": 0.06065621634869265,
"median": 3.03972804962,
"user": 1.76047668,
"system": 2.0082962599999994,
"min": 2.99736687212,
"max": 3.21013282812,
"times": [
3.02458901912,
3.07305178712,
3.08196601312,
3.02010229212,
3.05190279612,
2.99736687212,
3.02755330312,
3.21013282812,
3.01677943612,
3.07459612912
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6899406301200001,
"stddev": 0.009895776767199714,
"median": 0.68909247712,
"user": 0.3362122799999999,
"system": 1.3147470600000002,
"min": 0.6747008761200001,
"max": 0.71051288412,
"times": [
0.69652810012,
0.6881436001200001,
0.68851300012,
0.6792962411200001,
0.71051288412,
0.69666601912,
0.6747008761200001,
0.68967195412,
0.68974134412,
0.68563228212
]
},
{
"command": "pnpr@main",
"mean": 0.6897362335200001,
"stddev": 0.03756012819177892,
"median": 0.68191099862,
"user": 0.35631828,
"system": 1.29580496,
"min": 0.66184382312,
"max": 0.79380747512,
"times": [
0.6843346381200001,
0.6674337851200001,
0.69012764012,
0.67720936712,
0.68472103112,
0.67406257812,
0.68426926412,
0.66184382312,
0.79380747512,
0.6795527331200001
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.66214303322,
"stddev": 0.007812755201649037,
"median": 0.66200683272,
"user": 0.6273050999999998,
"system": 0.15438340000000003,
"min": 0.6526745632200001,
"max": 0.6755317352200001,
"times": [
0.65720976822,
0.6526745632200001,
0.66160291922,
0.6656142902200001,
0.6624107462200001,
0.65704050222,
0.66258434722,
0.67373443822,
0.6530270222200001,
0.6755317352200001
]
},
{
"command": "pacquet@main",
"mean": 0.66077277922,
"stddev": 0.006637724911386313,
"median": 0.65840338722,
"user": 0.6216875,
"system": 0.1606304,
"min": 0.65081090322,
"max": 0.67528808222,
"times": [
0.66705401722,
0.65821594622,
0.67528808222,
0.6581358782200001,
0.65756775722,
0.66137286222,
0.66333733622,
0.65735418122,
0.65081090322,
0.65859082822
]
},
{
"command": "pnpr@HEAD",
"mean": 0.10802631546000002,
"stddev": 0.0007503543810435675,
"median": 0.10793396822000001,
"user": 0.028086659999999996,
"system": 0.01976052,
"min": 0.10713548922,
"max": 0.11093707622000001,
"times": [
0.11093707622000001,
0.10713548922,
0.10813712422,
0.10793396822000001,
0.10846742122000001,
0.10733688922000001,
0.10819038322,
0.10807167222000001,
0.10755218222000001,
0.10837177922,
0.10750477322,
0.10783315322,
0.10765927122,
0.10864904122,
0.10771543722,
0.10774531222000001,
0.10780446322000001,
0.10809968522,
0.10814372722000001,
0.10804187122,
0.10757041022000001,
0.10854794722000001,
0.10718090222000001,
0.10868915922000001,
0.10733874722
]
},
{
"command": "pnpr@main",
"mean": 0.10806959626000001,
"stddev": 0.0008489643521607909,
"median": 0.10789031422,
"user": 0.028312099999999996,
"system": 0.020218000000000003,
"min": 0.10698621922000001,
"max": 0.11164882022000001,
"times": [
0.10788080022,
0.11164882022000001,
0.10789031422,
0.10775870122,
0.10850941422,
0.10741386822000001,
0.10841092022000001,
0.10808066422000001,
0.10777276822000001,
0.10804303322000001,
0.10772643122,
0.10829501422000001,
0.10759881322,
0.10806492422000001,
0.10732660422000001,
0.10867241922000001,
0.10698621922000001,
0.10863691222,
0.10774377422,
0.10771636222000001,
0.10824357822000001,
0.10814642622000001,
0.10793110422,
0.10757821522000001,
0.10766380422
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 6.59441245382,
"stddev": 0.15132872690656607,
"median": 6.56471542102,
"user": 3.79233014,
"system": 3.74787696,
"min": 6.41122957452,
"max": 6.93622945752,
"times": [
6.51585552952,
6.60162076652,
6.56581203652,
6.56361880552,
6.41122957452,
6.48970587752,
6.69823241852,
6.93622945752,
6.69407486152,
6.46774521052
]
},
{
"command": "pacquet@main",
"mean": 6.647287134220001,
"stddev": 0.17984364045162218,
"median": 6.64116760852,
"user": 3.6928603399999993,
"system": 3.73893396,
"min": 6.43094057252,
"max": 7.0053131105199995,
"times": [
6.68079025452,
6.5111681705199995,
6.62689511152,
6.85877902652,
7.0053131105199995,
6.5903640895199995,
6.68219143252,
6.43094057252,
6.65544010552,
6.43098946852
]
},
{
"command": "pnpr@HEAD",
"mean": 4.99729534202,
"stddev": 0.06801710270463797,
"median": 5.01760275702,
"user": 2.7998854399999997,
"system": 3.2707039599999996,
"min": 4.90826784752,
"max": 5.08948181552,
"times": [
4.91030345352,
5.02903607552,
4.91975085552,
4.95837362452,
5.06632369452,
5.08948181552,
5.02254690552,
5.01265860852,
5.05621053952,
4.90826784752
]
},
{
"command": "pnpr@main",
"mean": 4.96939232972,
"stddev": 0.07579732675591039,
"median": 4.98444047152,
"user": 2.75982994,
"system": 3.2742767599999993,
"min": 4.85381302652,
"max": 5.06159746652,
"times": [
5.01966411752,
5.05186336652,
4.96817358052,
4.86129174952,
4.97483157352,
5.01652430952,
4.85381302652,
5.06159746652,
4.99404936952,
4.89211473752
]
}
]
} |
|
| Branch | pr/13009 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 2,180.97 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 689.94 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 670.45 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 108.03 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 2,131.77 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 4,997.30 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 741.71 ms |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13009 +/- ##
=======================================
Coverage 85.53% 85.53%
=======================================
Files 498 498
Lines 79541 79551 +10
=======================================
+ Hits 68037 68046 +9
- Misses 11504 11505 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pnpm/crates/fs/src/symlink_dir.rs`:
- Around line 411-440: Update the rename-failure handling around fs::rename so
cleanup and symlink_metadata errors never return before the existence check or
mask the original rename_error. Attempt fs::remove_dir, retain any cleanup
failure for reporting only, always run symlink_metadata(link) to return
AlreadyExists when the destination exists, and otherwise return an error that
preserves rename_error while incorporating relevant cleanup or metadata details.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 8393006e-072d-40e3-9301-f2c925457ce8
📒 Files selected for processing (2)
.changeset/windows-atomic-junctions.mdpnpm/crates/fs/src/symlink_dir.rs
The pacquet-ci.yml global-virtual-store bootstrap workaround is no longer needed. Restore the workflow to match main.
939bb7d to
62daba3
Compare
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules 1. Changeset missing pnpm entry
|
| --- | ||
| "pacquet": patch | ||
| --- |
There was a problem hiding this comment.
1. Changeset missing pnpm entry 📘 Rule violation § Compliance
The new changeset only declares a pacquet bump and omits an explicit pnpm entry. This violates the changeset compliance requirement and may cause incorrect/absent versioning for pnpm in release tooling.
Agent Prompt
## Issue description
The changeset `.changeset/windows-atomic-junctions.md` is missing an explicit `pnpm` package entry (with a valid bump type), which is required by the compliance checklist.
## Issue Context
This PR adds a new changeset, but its front-matter only lists `pacquet`.
## Fix Focus Areas
- .changeset/windows-atomic-junctions.md[1-3]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
Summary
Root cause
When true directory symlinks are unavailable, the Rust filesystem layer falls back to the
junctioncrate. That crate creates a normal directory at the final link path and then converts it into a reparse point. Concurrent global-virtual-store edges could observe or replace that intermediate directory, causingERROR_DIRECTORY(os error 267) during dependency installation.The new path creates each junction at a unique sibling path, then commits it under a short process-wide lock. Other workers see only a complete junction and flow through the existing
AlreadyExistsreuse path.Validation
cargo test -p pacquet-fscargo clippy -p pacquet-fs --all-targets -- --deny warningsPATH="$HOME/.cargo/bin:$PATH" just readyPATH="$HOME/.cargo/bin:$PATH" just dylintWritten by an agent (GitHub Copilot CLI, gpt-5.6-sol).
Summary by CodeRabbit
Bug Fixes
Tests
Chores