Skip to content

Commit

Permalink
Made Database::compact not fail when there's an auto-compact in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
snej committed Apr 4, 2016
1 parent 52bd047 commit eec818e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion CBForest/Database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "Document.hh"
#include "LogInternal.hh"
#include "atomic.h" // forestdb internal
#include "time_utils.h" // forestdb internal
#include <errno.h>
#include <stdarg.h> // va_start, va_end
#include <stdio.h>
Expand Down Expand Up @@ -294,7 +295,14 @@ namespace cbforest {


void Database::compact() {
check(fdb_compact(_fileHandle, NULL));
auto status = fdb_compact(_fileHandle, NULL);
if (status == FDB_RESULT_FILE_IS_BUSY) {
// This result means there is already a background auto-compact in progress.
while (isCompacting())
::usleep(100 * 1000);
} else {
check(status);
}
}

fdb_compact_decision Database::compactionCallback(fdb_file_handle *fhandle,
Expand Down

0 comments on commit eec818e

Please sign in to comment.