The c_test was sometimes failing with an assertion.

Summary:
On fast filesystems (e.g. /dev/shm and ext4), the flushing
of memstore to disk was fast and quick, and the background compaction
thread was not getting scheduled fast enough to delete obsolete
files before the db was closed. This caused the repair method
to pick up those files that were not part of the db and the unit
test was failing.

The fix is to enhance the unti test to run a compaction before
closing the database so that all files that are not part of the
database are truly deleted from the filesystem.

Test Plan: make c_test; ./c_test

Reviewers: chip, emayanke, sheki

Reviewed By: chip

CC: leveldb

Differential Revision: https://reviews.facebook.net/D6915
This commit is contained in:
Dhruba Borthakur 2012-11-21 15:09:46 -08:00
parent 879e45eb99
commit e0cd6bf0e9

View file

@ -313,6 +313,11 @@ int main(int argc, char** argv) {
StartPhase("repair"); StartPhase("repair");
{ {
// If we do not compact here, then the lazy deletion of
// files (https://reviews.facebook.net/D6123) would leave
// around deleted files and the repair process will find
// those files and put them back into the database.
leveldb_compact_range(db, NULL, 0, NULL, 0);
leveldb_close(db); leveldb_close(db);
leveldb_options_set_create_if_missing(options, 0); leveldb_options_set_create_if_missing(options, 0);
leveldb_options_set_error_if_exists(options, 0); leveldb_options_set_error_if_exists(options, 0);