sapling/eden
Matt Glazar 3b9a0310a1 Fix deadlock when restarting during RocksDbLocalStore::get()
Summary:
If TreeInode::startLoadingInode() is in progress, and EdenServer::startTakeoverShutdown() is called, edenfs can deadlock:

1. Thread A: A FUSE request calls TreeInode::readdir() -> TreeInode::prefetch() -> TreeInode::startLoadingInode() on the children TreeInode-s -> RocksDbLocalStore::getFuture().
2. Thread B: A takeover request calls EdenServer::performTakeoverShutdown() -> InodeMap::shutdown().
3. Thread C: RocksDbLocalStore::getFuture() (called in step 1) completes -> TreeInode::inodeLoadComplete(). (The inodeLoadComplete continuation was registered by TreeInode::registerInodeLoadComplete().)
4. Thread C: After TreeInode::inodeLoadComplete() returns, the TreeInode's InodePtr is destructed, dropping the reference count to 0.
5. Thread C: InodeMap::onInodeUnreferenced() -> InodeMap::shutdownComplete() -> EdenMount::shutdown() (called in step 2) completes -> EdenServer::performTakeoverShutdown().
6. Thread C: EdenServer::performTakeoverShutdown() -> localStore_.reset() -> RocksDbLocalStore::~RocksDbLocalStore().
7. Thread C: RocksDbLocalStore::~RocksDbLocalStore() signals the thread pool to exit and waits for the pool's threads to exit. Because thread C is one of the threads managed by RocksDbLocalStore's thread pool, the signal is never handled and RocksDbLocalStore::~RocksDbLocalStore() never finishes.

Fix this deadlock by executing EdenServer::shutdown()'s callback (in EdenServer::performTakeoverShutdown()) on a different thread.

Reviewed By: simpkins

Differential Revision: D14337058

fbshipit-source-id: 1d63b4e7d8f5103a2dde31e329150bf763be3db7
2019-03-12 19:29:35 -07:00
..
benchmarks Cut most of the remaining Thrift SASL integration 2018-11-19 22:40:44 -08:00
cli Update pyre version for eden 2019-03-12 13:56:33 -07:00
docs Document how globs work 2019-03-07 14:20:57 -08:00
fs Fix deadlock when restarting during RocksDbLocalStore::get() 2019-03-12 19:29:35 -07:00
integration Fix deadlock when restarting during RocksDbLocalStore::get() 2019-03-12 19:29:35 -07:00
locale add a custom translation for ENOTCONN 2019-03-07 12:55:04 -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 Add missing copyright notices 2019-03-07 19:32:39 -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 Created HResultError class and fixed the exception handling. 2019-03-12 16:30:44 -07:00
.gitignore eden: wire up mac contbuild 2019-02-05 21:52:30 -08:00
Eden.project.toml Eden.project.toml file for Nuclide 2018-04-26 11:05:23 -07:00