feat: Implemented [SIM] Support Windows-native file locking for SourceMapCache#964
Open
Risktaker001 wants to merge 2 commits intodotandev:mainfrom
Open
feat: Implemented [SIM] Support Windows-native file locking for SourceMapCache#964Risktaker001 wants to merge 2 commits intodotandev:mainfrom
Risktaker001 wants to merge 2 commits intodotandev:mainfrom
Conversation
|
@Risktaker001 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Owner
|
fix ci. |
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.
Closes #870
PR: Windows-Native File Locking for SourceMapCache (#870)
Summary
Implements Windows-native file locking for the SourceMapCache using
LockFileExAPI, replacing the previous no-op implementation that left Windows users vulnerable to cache corruption during concurrent debug sessions.Problem
The existing
flock-based file locking was a no-op on Windows:syscall.Flockis not supported on Windows platformsSolution
Implemented proper Windows file locking using
LockFileExfromgolang.org/x/sys/windows:LockFileEx Implementation
Key Features
LOCKFILE_EXCLUSIVE_LOCK) for write operationsFiles Changed
internal/sourcemap/cache_lock_windows.go(66 lines)acquireLock()- Opens lock file and acquires LockFileExreleaseLock()- Unlocks file and closes handleinternal/sourcemap/sourcemap_test.go(+120 lines)TestSourceCache_ConcurrentWrites- 10 writers × 5 writes to same entryTestSourceCache_ConcurrentWritesDifferentEntries- 20 concurrent writersTesting
The existing CI workflow already includes Windows testing:
Run concurrent write tests:
go test -v -run TestSourceCache_Concurrent ./internal/sourcemap/Run all sourcemap tests:
go test -v ./internal/sourcemap/Technical Details
LockFileEx Flags Used
LOCKFILE_EXCLUSIVE_LOCK (0x02)- Exclusive/write lockLOCKFILE_FAIL_IMMEDIATELY- Not used (blocking with retry)Windows API Calls
windows.LockFileEx()- Acquire file lockwindows.UnlockFile()- Release file lockwindows.SetHandleInformation()- Set HANDLE_FLAG_INHERIT=0Compatibility
golang.org/x/sys/windows(Go stdlib, available since Go 1.17)Breaking Changes
None. The implementation is transparent to the rest of the SourceMapCache logic and maintains the same interface.
Backwards Compatibility
The Windows lock file format is compatible with Unix lock files (
.lockextension). Existing lock files from the no-op implementation are simply overwritten with proper locks.