rocksdb/db/db_impl
Yanqin Jin 2309fd63bf Update column families' log number altogether after flushing during recovery (#5856)
Summary:
A bug occasionally shows up in crash test, and https://github.com/facebook/rocksdb/issues/5851 reproduces it.
The bug can surface in the following way.
1. Database has multiple column families.
2. Between one DB restart, the last log file is corrupted in the middle (not the tail)
3. During restart, DB crashes between flushing between two column families.

Then DB will fail to be opened again with error "SST file is ahead of WALs".
Solution is to update the log number associated with each column family altogether after flushing all column families' memtables. The version edits should be written to a new MANIFEST. Only after writing to all these version edits succeed does RocksDB (atomically) points the CURRENT file to the new MANIFEST.

Test plan (on devserver):
```
$make all && make check
```
Specifically
```
$make db_test2
$./db_test2 --gtest_filter=DBTest2.CrashInRecoveryMultipleCF
```
Also checked for compatibility as follows.
Use this branch, run DBTest2.CrashInRecoveryMultipleCF and preserve the db directory.
Then checkout 5.4, build ldb, and dump the MANIFEST.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5856

Differential Revision: D17620818

Pulled By: riversand963

fbshipit-source-id: b52ce5969c9a8052cacec2bd805fcfb373589039
2019-10-24 18:29:30 -07:00
..
db_impl_compaction_flush.cc Propagate SST and blob file numbers through the EventListener interface (#5962) 2019-10-24 14:44:15 -07:00
db_impl_debug.cc Add command "list_file_range_deletes" in ldb (#5615) 2019-08-15 17:01:03 -07:00
db_impl_experimental.cc BlobDB GC: add SST <-> oldest blob file referenced mapping (#5903) 2019-10-14 15:21:01 -07:00
db_impl_files.cc Move WAL-closing loop out of original loop (#5804) 2019-09-17 17:17:19 -07:00
db_impl_open.cc Update column families' log number altogether after flushing during recovery (#5856) 2019-10-24 18:29:30 -07: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 Apply formatter to recent 200+ commits. (#5830) 2019-09-20 12:04:26 -07:00
db_impl_secondary.h Override check consistency for DBImplSecondary (#5469) 2019-06-17 15:39:55 -07:00
db_impl_write.cc Add insert hints for each writebatch (#5728) 2019-09-12 17:15:18 -07:00
db_impl.cc MultiGet batching in memtable (#5818) 2019-10-10 09:39:39 -07:00
db_impl.h Fix OnFlushCompleted fired before flush result write to MANIFEST (#5908) 2019-10-16 10:40:23 -07:00
db_secondary_test.cc Apply formatter to recent 200+ commits. (#5830) 2019-09-20 12:04:26 -07:00