sapling/eden
Matt Glazar fe919940bc Fix race between FUSE_ERROR and SHUTDOWN EdenMount states
Summary:
If EdenMount::shutdownImpl and EdenMount::startFuse execute concurrently, the mount's `state_` might end up inconsistent. For example, for the following sequence of events, EdenMount::shutdownImpl is erroneously called twice:

1. EdenMount::initialize transitions the mount's state to INITIALIZED.
2. EdenMount::startFuse begins and transitions the mount's state to STARTING.
3. EdenMount::shutdown begins and transitions the mount's state to SHUTTING_DOWN.
4. EdenMount::shutdown finishes and transitions the mount's state to SHUT_DOWN.
5. EdenMount::startFuse finishes due to FuseChannel::initialize failing with an error and transitions the mount's state to FUSE_ERROR.
6. EdenMountDeleter calls EdenMount::destroy, which observes that the mount's state is FUSE_ERROR. EdenMount::destroy proceeds by calling EdenMount::shutdownImpl.

This specific scenario can't happen in production right now because step 3 requires allowFuseNotStarted to be true (and it's never true in production).

A similar scenario can happen with EdenMount::startFuse+EdenMount::destroy running currently, but the effects are benign. However, in a future diff (D14015024), I am changing how EdenMount::destroy works, and the SHUT_DOWN -> FUSE_ERROR transition causes problems.

When FuseChannel::initialize returns an error, transition the mount to the FUSE_ERROR state only if we are not already shutting down (instead of unconditionally). This fixes the [impossible] scenario above, and also fixes EdenMount::destroy in a future diff.

Reviewed By: simpkins

Differential Revision: D14030898

fbshipit-source-id: fe5a749b8798749734e0de91eb3b71b601ebb64b
2019-02-20 14:01:04 -08:00
..
benchmarks Cut most of the remaining Thrift SASL integration 2018-11-19 22:40:44 -08:00
cli eden: fixup cli readline dep and mac packaging 2019-02-19 11:26:26 -08:00
docs add a caching strategy document 2018-12-06 12:33:31 -08:00
fs Fix race between FUSE_ERROR and SHUTDOWN EdenMount states 2019-02-20 14:01:04 -08:00
integration eden: hg_import_helper.py execs hg debugedenimporthelper 2019-02-14 22:27:00 -08:00
py eden: add a script to build the eden client executable for oss builds 2019-01-15 14:14:32 -08:00
scripts unmount stale edenfs mounts in eden doctor 2018-01-19 11:06:51 -08:00
test_support Allow systemd opt-in via config 2018-12-10 16:30:06 -08:00
test-data add more files to the basic snapshot 2018-11-26 12:28:52 -08:00
third-party update to latest kernel headers (from fuse/for-next) 2019-01-30 23:00:38 -08:00
win Add FaultInjector to Windows builds 2019-02-19 10:50:48 -08:00
.gitignore eden: wire up mac contbuild 2019-02-05 21:52:30 -08:00
.pyre_configuration.local Update pyre version for eden 2019-01-28 13:36:41 -08:00
Eden.project.toml Eden.project.toml file for Nuclide 2018-04-26 11:05:23 -07:00