From e0cd6bf0e91e9b3892ded3b4e4a10a1e0c47ecf6 Mon Sep 17 00:00:00 2001 From: Dhruba Borthakur Date: Wed, 21 Nov 2012 15:09:46 -0800 Subject: [PATCH] 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 --- db/c_test.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/db/c_test.c b/db/c_test.c index a1e82b2f1..2c36972b8 100644 --- a/db/c_test.c +++ b/db/c_test.c @@ -313,6 +313,11 @@ int main(int argc, char** argv) { 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_options_set_create_if_missing(options, 0); leveldb_options_set_error_if_exists(options, 0); -- GitLab