-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vfs: enforce mutual exclusion in MemFS.Lock
Previously MemFS's Lock method did not implement mutual exclusion under the assumption that databases are given separate processes which do not share memory. This commit adapts Lock to enforce mutual exclusion, preventing accidentally using same FS concurrently from more than one Pebble instance. It's believed that cockroachdb/cockroach#110645 is the result of Cockroach acceptance tests opening a MemFS store twice, with one Pebble instance deleting files from beneath another Pebble instance.
- Loading branch information
Showing
3 changed files
with
166 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
mkfs A B | ||
---- | ||
OK | ||
|
||
# | ||
# Locking a path with parents that don't exist should error. | ||
# | ||
|
||
lock fs=A path=a/b/c handle=fsApathABC | ||
---- | ||
open a/b/c: file does not exist | ||
|
||
# | ||
# If we create the parents, it should succeed. | ||
# | ||
|
||
mkdirall fs=A path=a/b | ||
---- | ||
OK | ||
|
||
lock fs=A path=a/b/c handle=fsApathABC | ||
---- | ||
OK | ||
|
||
# | ||
# Locking the same path on the same filesystem should fail with EAGAIN. | ||
# | ||
|
||
lock fs=A path=a/b/c handle=bogus | ||
---- | ||
resource temporarily unavailable | ||
|
||
# | ||
# Locking the same path on a DIFFERENT filesystem should succeed. | ||
# | ||
|
||
mkdirall fs=B path=a/b | ||
---- | ||
OK | ||
|
||
lock fs=B path=a/b/c handle=fsBpathABC | ||
---- | ||
OK | ||
|
||
# | ||
# Releasing the lock on fs A should allow us to reacquire it. | ||
# | ||
|
||
close handle=fsApathABC | ||
---- | ||
OK | ||
|
||
lock fs=A path=a/b/c handle=fsApathABC | ||
---- | ||
OK |