fix(mfs): serialize FileDescriptor Flush and Close#1131
Open
Conversation
Flush and Close both call flushUp which accesses the underlying DagModifier without synchronization. When a caller invokes both from separate goroutines, two concurrent Sync calls race on the write buffer, causing a nil pointer dereference. - add sync.Mutex to fileDescriptor, acquired in Flush and Close - Flush on a closed descriptor now returns ErrClosed - add TestConcurrentFlushAndClose
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #1131 +/- ##
==========================================
- Coverage 62.54% 62.49% -0.06%
==========================================
Files 261 261
Lines 26216 26238 +22
==========================================
Hits 16398 16398
- Misses 8128 8151 +23
+ Partials 1690 1689 -1
... and 8 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Directory had SetMode/SetModTime but no matching getters, unlike File which has both. Add Mode() and ModTime() so callers like FUSE mounts can read directory metadata without going through GetNode and ExtractFSNode manually.
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.
This PR fixes panic in MFS found in Kubo when we enabled FUSE tests on CI (log).
FlushandCloseboth callflushUpwhich accesses the underlyingDagModifierwithout synchronization. When a caller invokes both from separate goroutines, two concurrentSynccalls race on the write buffer, causing anilpointer dereference.sync.MutextofileDescriptor, acquired inFlushandCloseErrClosedTestConcurrentFlushAndCloseso we catch regressions with-race