Skip to content

Commit 8a101e4

Browse files
committed
WaitForCompact with empty WaitForCompactOptions
1 parent 2b11550 commit 8a101e4

6 files changed

Lines changed: 28 additions & 20 deletions

File tree

‎db/c.cc‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ using ROCKSDB_NAMESPACE::TransactionDB;
119119
using ROCKSDB_NAMESPACE::TransactionDBOptions;
120120
using ROCKSDB_NAMESPACE::TransactionLogIterator;
121121
using ROCKSDB_NAMESPACE::TransactionOptions;
122+
using ROCKSDB_NAMESPACE::WaitForCompactOptions;
122123
using ROCKSDB_NAMESPACE::WALRecoveryMode;
123124
using ROCKSDB_NAMESPACE::WritableFile;
124125
using ROCKSDB_NAMESPACE::WriteBatch;
@@ -274,6 +275,9 @@ struct rocksdb_optimistictransactiondb_t {
274275
struct rocksdb_optimistictransaction_options_t {
275276
OptimisticTransactionOptions rep;
276277
};
278+
struct rocksdb_wait_for_compact_options_t {
279+
WaitForCompactOptions rep;
280+
};
277281

278282
struct rocksdb_compactionfiltercontext_t {
279283
CompactionFilter::Context rep;
@@ -6555,5 +6559,10 @@ void rocksdb_disable_manual_compaction(rocksdb_t* db) {
65556559
void rocksdb_enable_manual_compaction(rocksdb_t* db) {
65566560
db->rep->EnableManualCompaction();
65576561
}
6562+
void rocksdb_wait_for_compact(
6563+
rocksdb_t* db,
6564+
rocksdb_wait_for_compact_options_t* wait_for_compact_options) {
6565+
db->rep->WaitForCompact(wait_for_compact_options->rep);
6566+
}
65586567

65596568
} // end extern "C"

‎db/db_impl/db_impl.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ class DBImpl : public DB {
10611061
// with options to flush before waiting for compaction to finish and close db
10621062
// upon the completion of compaction
10631063
Status WaitForCompact(
1064-
const WaitForCompactionsOptions& wait_for_compaction_options);
1064+
const WaitForCompactOptions& wait_for_compact_options) override;
10651065

10661066
#ifndef NDEBUG
10671067
// Compact any files in the named level that overlap [*begin, *end]
@@ -1108,7 +1108,7 @@ class DBImpl : public DB {
11081108
// with options to flush before waiting for compaction to finish and close db
11091109
// upon the completion of compaction
11101110
Status TEST_WaitForCompact(
1111-
const WaitForCompactionsOptions& wait_for_compaction_options);
1111+
const WaitForCompactOptions& wait_for_compact_options);
11121112

11131113
// Wait for any background purge
11141114
Status TEST_WaitForPurge();

‎db/db_impl/db_impl_compaction_flush.cc‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3970,14 +3970,8 @@ Status DBImpl::WaitForCompact(bool wait_unscheduled) {
39703970
}
39713971

39723972
Status DBImpl::WaitForCompact(
3973-
const WaitForCompactionsOptions& wait_for_compaction_options) {
3974-
if (wait_for_compaction_options.flush) {
3975-
MaybeScheduleFlushOrCompaction();
3976-
}
3977-
InstrumentedMutexLock l(&mutex_);
3978-
if (wait_for_compaction_options.close_db) {
3979-
}
3980-
return error_handler_.GetBGError();
3973+
const WaitForCompactOptions& /*wait_for_compact_options*/) {
3974+
return DBImpl::WaitForCompact();
39813975
}
39823976

39833977
} // namespace ROCKSDB_NAMESPACE

‎db/db_impl/db_impl_debug.cc‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ Status DBImpl::TEST_WaitForCompact(bool wait_unscheduled) {
183183
return WaitForCompact(wait_unscheduled);
184184
}
185185

186+
Status DBImpl::TEST_WaitForCompact(
187+
const WaitForCompactOptions& wait_for_compact_options) {
188+
// Wait until the compaction completes with options to flush before compaction
189+
// and close db after compaction
190+
return WaitForCompact(wait_for_compact_options);
191+
}
192+
186193
Status DBImpl::TEST_WaitForPurge() {
187194
InstrumentedMutexLock l(&mutex_);
188195
while (bg_purge_scheduled_ && error_handler_.GetBGError().ok()) {

‎include/rocksdb/db.h‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct Options;
5353
struct ReadOptions;
5454
struct TableProperties;
5555
struct WriteOptions;
56-
struct WaitForCompactionsOptions;
56+
struct WaitForCompactOptions;
5757
class Env;
5858
class EventListener;
5959
class FileSystem;
@@ -1448,6 +1448,12 @@ class DB {
14481448
// DisableManualCompaction() has been called.
14491449
virtual void EnableManualCompaction() = 0;
14501450

1451+
// Wait for Compaction to finish
1452+
virtual Status WaitForCompact(
1453+
const WaitForCompactOptions& /* wait_for_compact_options */) {
1454+
return Status::NotSupported("WaitForCompact Not implemented");
1455+
}
1456+
14511457
// Number of levels used for this DB.
14521458
virtual int NumberLevels(ColumnFamilyHandle* column_family) = 0;
14531459
virtual int NumberLevels() { return NumberLevels(DefaultColumnFamily()); }

‎include/rocksdb/options.h‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,14 +2080,6 @@ struct LiveFilesStorageInfoOptions {
20802080
uint64_t wal_size_for_flush = 0;
20812081
};
20822082

2083-
struct WaitForCompactionsOptions {
2084-
// If true, flush before waiting for compactions to finish.
2085-
// Must be set to true to ensure no immediate compactions after closing and
2086-
// re-opening the DB
2087-
bool flush = false;
2088-
2089-
// If true, will close the DB upon compactions finishing
2090-
bool close_db = false;
2091-
};
2083+
struct WaitForCompactOptions {};
20922084

20932085
} // namespace ROCKSDB_NAMESPACE

0 commit comments

Comments
 (0)