-
Notifications
You must be signed in to change notification settings - Fork 458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pebble: add global sync to MemFS #3110
base: master
Are you sure you want to change the base?
Conversation
This commit introduces MemFS.Sync method which persists the entire filesystem. It makes it possible to emulate a process crash and restart, as follows: ``` fs.Sync() // capture/snapshot the filesystem fs.SetIgnoreSyncs(true) // prevent changes from taking effect db.Close() // shutdown, with no writes taking effect fs.ResetToSyncedState() // rollback to the snapshot strictFS.SetIgnoreSyncs(false) // allow changes again db = Open(..., &Options{FS: fs}) // reopen on top of the reverted data ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused. Wouldn't correct modeling of a crash be to not sync the entire filesystem? We want to ensure that we've issued the correct syncs to all the individual files?
Reviewable status: 0 of 2 files reviewed, all discussions resolved (waiting on @sumeerbhola)
@jbowens The point of
In an emulated/unit-test environment we can't guarantee an immediate stop of the DB/server in step (2). So we snapshot the state of the filesystem just before step (2), and terminate the DB/server gracefully in step (2). The graceful stop will write some extra state and sync files, but we will ignore it all. In step (4) we rollback the FS to state that it was in just before the "crash" in step (2). The point of all this is to not let the graceful stop to take effect. We need to instantly cut-off writes, i.e. turn I could rename it to avoid the confusion. Something like |
A strict A non-strict There is nothing in between. The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explaining. That makes sense. No need to consider it here, but I can imagine it being worthwhile to reset a random subset of unsynced data as well.
I think it would be possible to implement these various testing semantics as vfs.FS middleware, like we do in vfs/errorfs
. But maybe we aren't gonna need it.
Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @sumeerbhola)
This commit introduces
MemFS.Sync
method which persists the entire filesystem. It makes it possible to emulate a process crash and restart, as follows: