rocksdb/db/db_impl
Mike Kolupaev 74b01ac2ea Fix use-after-free and double-deleting files in BackgroundCallPurge() (#6193)
Summary:
The bad code was:

```
mutex.Lock(); // `mutex` protects `container`
for (auto& x : container) {
  mutex.Unlock();
  // do stuff to x
  mutex.Lock();
}
```

It's incorrect because both `x` and the iterator may become invalid if another thread modifies the container while this thread is not holding the mutex.

Broken by https://github.com/facebook/rocksdb/pull/5796 - it replaced a `while (!container.empty())` loop with a `for (auto x : container)`.

(RocksDB code does a lot of such unlocking+re-locking of mutexes, and this type of bugs comes up a lot :/ )
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6193

Test Plan: Ran some logdevice integration tests that were crashing without this fix.

Differential Revision: D19116874

Pulled By: al13n321

fbshipit-source-id: 9672bc4227c1b68f46f7436db2b96811adb8c703
2020-01-02 12:21:53 -08:00
..
db_impl_compaction_flush.cc delete superversions in BackgroundCallPurge (#6146) 2020-01-02 12:20:29 -08:00
db_impl_debug.cc Fix IngestExternalFile's bug with two_write_queue (#5976) 2019-11-15 14:00:37 -08:00
db_impl_experimental.cc Support options.max_open_files = -1 with periodic_compaction_seconds (#6090) 2019-11-27 09:50:44 -08:00
db_impl_files.cc Let DBSecondary close files after catch up (#6114) 2019-12-02 17:53:24 -08:00
db_impl_open.cc Support options.max_open_files = -1 with periodic_compaction_seconds (#6090) 2019-11-27 09:50:44 -08:00
db_impl_readonly.cc Apply formatter on recent 45 commits. (#5827) 2019-09-19 12:34:17 -07:00
db_impl_readonly.h Use delete to disable automatic generated methods. (#5009) 2019-09-11 18:09:00 -07:00
db_impl_secondary.cc delete superversions in BackgroundCallPurge (#6146) 2020-01-02 12:20:29 -08:00
db_impl_secondary.h Let DBSecondary close files after catch up (#6114) 2019-12-02 17:53:24 -08:00
db_impl_write.cc Do not create/install new SuperVersion if nothing was deleted during memtable trim (#6169) 2019-12-17 07:52:22 -08:00
db_impl.cc Fix use-after-free and double-deleting files in BackgroundCallPurge() (#6193) 2020-01-02 12:21:53 -08:00
db_impl.h Fix use-after-free and double-deleting files in BackgroundCallPurge() (#6193) 2020-01-02 12:21:53 -08:00
db_secondary_test.cc Let DBSecondary close files after catch up (#6114) 2019-12-02 17:53:24 -08:00