@nxtedition/rocksdb 15.1.2 → 15.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +15 -0
- package/binding.cc +79 -38
- package/build.sh +1 -2
- package/deps/rocksdb/rocksdb/BUCK +10 -8
- package/deps/rocksdb/rocksdb/CMakeLists.txt +27 -2
- package/deps/rocksdb/rocksdb/Makefile +27 -116
- package/deps/rocksdb/rocksdb/cache/cache_bench_tool.cc +1 -1
- package/deps/rocksdb/rocksdb/cache/clock_cache.cc +101 -124
- package/deps/rocksdb/rocksdb/cache/clock_cache.h +47 -30
- package/deps/rocksdb/rocksdb/db/c.cc +793 -131
- package/deps/rocksdb/rocksdb/db/c_test.c +571 -0
- package/deps/rocksdb/rocksdb/db/compact_files_test.cc +226 -0
- package/deps/rocksdb/rocksdb/db/compaction/compaction.h +4 -0
- package/deps/rocksdb/rocksdb/db/compaction/compaction_job.cc +95 -59
- package/deps/rocksdb/rocksdb/db/compaction/compaction_job.h +2 -2
- package/deps/rocksdb/rocksdb/db/compaction/compaction_job_test.cc +45 -35
- package/deps/rocksdb/rocksdb/db/compaction/compaction_outputs.cc +8 -4
- package/deps/rocksdb/rocksdb/db/compaction/compaction_outputs.h +1 -1
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.cc +11 -6
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.h +8 -2
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_test.cc +47 -0
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.cc +12 -2
- package/deps/rocksdb/rocksdb/db/compaction/compaction_service_test.cc +82 -0
- package/deps/rocksdb/rocksdb/db/compaction/subcompaction_state.cc +2 -2
- package/deps/rocksdb/rocksdb/db/compaction/subcompaction_state.h +1 -1
- package/deps/rocksdb/rocksdb/db/db_basic_test.cc +69 -24
- package/deps/rocksdb/rocksdb/db/db_bloom_filter_test.cc +9 -1
- package/deps/rocksdb/rocksdb/db/db_compaction_test.cc +65 -0
- package/deps/rocksdb/rocksdb/db/db_etc3_test.cc +161 -0
- package/deps/rocksdb/rocksdb/db/db_filesnapshot.cc +1 -0
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +20 -7
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +13 -0
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_compaction_flush.cc +114 -39
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_files.cc +3 -0
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_follower.cc +3 -3
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +1 -1
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.cc +39 -25
- package/deps/rocksdb/rocksdb/db/db_iterator_test.cc +361 -0
- package/deps/rocksdb/rocksdb/db/db_options_test.cc +35 -0
- package/deps/rocksdb/rocksdb/db/db_range_del_test.cc +83 -0
- package/deps/rocksdb/rocksdb/db/db_test.cc +249 -4
- package/deps/rocksdb/rocksdb/db/db_test2.cc +3 -0
- package/deps/rocksdb/rocksdb/db/db_test_util.cc +2 -1
- package/deps/rocksdb/rocksdb/db/db_wal_test.cc +3 -2
- package/deps/rocksdb/rocksdb/db/flush_job_test.cc +7 -7
- package/deps/rocksdb/rocksdb/db/listener_test.cc +7 -17
- package/deps/rocksdb/rocksdb/db/memtable_list_test.cc +4 -2
- package/deps/rocksdb/rocksdb/db/obsolete_files_test.cc +41 -0
- package/deps/rocksdb/rocksdb/db/repair.cc +2 -2
- package/deps/rocksdb/rocksdb/db/version_edit.h +7 -4
- package/deps/rocksdb/rocksdb/db/version_set.cc +299 -90
- package/deps/rocksdb/rocksdb/db/version_set.h +56 -9
- package/deps/rocksdb/rocksdb/db/version_set_test.cc +41 -39
- package/deps/rocksdb/rocksdb/db/version_util.h +3 -2
- package/deps/rocksdb/rocksdb/db/wal_manager.cc +7 -1
- package/deps/rocksdb/rocksdb/db/wal_manager_test.cc +48 -10
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.h +1 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_gflags.cc +5 -1
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.cc +16 -5
- package/deps/rocksdb/rocksdb/env/env_test.cc +126 -41
- package/deps/rocksdb/rocksdb/env/fs_posix.cc +14 -7
- package/deps/rocksdb/rocksdb/env/io_posix.cc +304 -112
- package/deps/rocksdb/rocksdb/env/io_posix.h +16 -4
- package/deps/rocksdb/rocksdb/env/io_posix_test.cc +43 -0
- package/deps/rocksdb/rocksdb/folly.mk +148 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/advanced_compression.h +29 -3
- package/deps/rocksdb/rocksdb/include/rocksdb/advanced_options.h +73 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/c.h +246 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/compaction_filter.h +0 -2
- package/deps/rocksdb/rocksdb/include/rocksdb/data_structure.h +15 -9
- package/deps/rocksdb/rocksdb/include/rocksdb/db.h +19 -9
- package/deps/rocksdb/rocksdb/include/rocksdb/env.h +1 -1
- package/deps/rocksdb/rocksdb/include/rocksdb/file_system.h +6 -4
- package/deps/rocksdb/rocksdb/include/rocksdb/metadata.h +14 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/options.h +67 -6
- package/deps/rocksdb/rocksdb/include/rocksdb/sst_file_writer.h +1 -7
- package/deps/rocksdb/rocksdb/include/rocksdb/statistics.h +3 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/thread_status.h +6 -14
- package/deps/rocksdb/rocksdb/include/rocksdb/utilities/backup_engine.h +8 -1
- package/deps/rocksdb/rocksdb/include/rocksdb/utilities/env_mirror.h +2 -2
- package/deps/rocksdb/rocksdb/include/rocksdb/utilities/ldb_cmd_execute_result.h +0 -4
- package/deps/rocksdb/rocksdb/include/rocksdb/utilities/option_change_migration.h +33 -5
- package/deps/rocksdb/rocksdb/include/rocksdb/utilities/stackable_db.h +6 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/version.h +2 -2
- package/deps/rocksdb/rocksdb/monitoring/statistics.cc +2 -0
- package/deps/rocksdb/rocksdb/monitoring/thread_status_impl.cc +5 -2
- package/deps/rocksdb/rocksdb/monitoring/thread_status_updater.cc +2 -2
- package/deps/rocksdb/rocksdb/monitoring/thread_status_updater.h +6 -6
- package/deps/rocksdb/rocksdb/monitoring/thread_status_updater_debug.cc +2 -2
- package/deps/rocksdb/rocksdb/monitoring/thread_status_util.cc +10 -5
- package/deps/rocksdb/rocksdb/monitoring/thread_status_util.h +2 -2
- package/deps/rocksdb/rocksdb/options/cf_options.cc +15 -3
- package/deps/rocksdb/rocksdb/options/cf_options.h +7 -0
- package/deps/rocksdb/rocksdb/options/db_options.cc +27 -36
- package/deps/rocksdb/rocksdb/options/db_options.h +3 -2
- package/deps/rocksdb/rocksdb/options/options.cc +4 -0
- package/deps/rocksdb/rocksdb/options/options_helper.cc +8 -2
- package/deps/rocksdb/rocksdb/options/options_settable_test.cc +4 -1
- package/deps/rocksdb/rocksdb/options/options_test.cc +19 -3
- package/deps/rocksdb/rocksdb/src.mk +1 -1
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.cc +155 -32
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.h +7 -3
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.cc +169 -125
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.h +22 -7
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.cc +43 -24
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +9 -5
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_test.cc +9 -8
- package/deps/rocksdb/rocksdb/table/block_based/filter_block.h +17 -0
- package/deps/rocksdb/rocksdb/table/block_based/filter_policy.cc +15 -5
- package/deps/rocksdb/rocksdb/table/block_based/filter_policy_internal.h +13 -18
- package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.cc +29 -0
- package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.h +6 -0
- package/deps/rocksdb/rocksdb/table/block_based/full_filter_block_test.cc +15 -0
- package/deps/rocksdb/rocksdb/table/block_based/index_builder.cc +79 -19
- package/deps/rocksdb/rocksdb/table/block_based/index_builder.h +48 -20
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.cc +51 -0
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.h +19 -0
- package/deps/rocksdb/rocksdb/table/block_based/user_defined_index_wrapper.h +1 -1
- package/deps/rocksdb/rocksdb/table/external_table.cc +2 -2
- package/deps/rocksdb/rocksdb/table/sst_file_dumper.cc +3 -2
- package/deps/rocksdb/rocksdb/table/sst_file_dumper.h +3 -1
- package/deps/rocksdb/rocksdb/table/table_builder.h +5 -0
- package/deps/rocksdb/rocksdb/table/table_reader.h +4 -2
- package/deps/rocksdb/rocksdb/table/table_test.cc +48 -39
- package/deps/rocksdb/rocksdb/test_util/sync_point.cc +4 -0
- package/deps/rocksdb/rocksdb/test_util/sync_point.h +32 -0
- package/deps/rocksdb/rocksdb/test_util/testutil.h +6 -2
- package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +14 -4
- package/deps/rocksdb/rocksdb/tools/ldb_cmd.cc +8 -5
- package/deps/rocksdb/rocksdb/tools/ldb_cmd_test.cc +3 -2
- package/deps/rocksdb/rocksdb/tools/sst_dump_tool.cc +63 -12
- package/deps/rocksdb/rocksdb/util/auto_tune_compressor.cc +16 -1
- package/deps/rocksdb/rocksdb/util/auto_tune_compressor.h +5 -1
- package/deps/rocksdb/rocksdb/util/bit_fields.h +133 -23
- package/deps/rocksdb/rocksdb/util/bloom_test.cc +2 -5
- package/deps/rocksdb/rocksdb/util/compression.cc +51 -23
- package/deps/rocksdb/rocksdb/util/compression_test.cc +525 -270
- package/deps/rocksdb/rocksdb/util/filter_bench.cc +3 -4
- package/deps/rocksdb/rocksdb/util/simple_mixed_compressor.cc +11 -2
- package/deps/rocksdb/rocksdb/util/simple_mixed_compressor.h +4 -1
- package/deps/rocksdb/rocksdb/util/slice_test.cc +92 -0
- package/deps/rocksdb/rocksdb/util/thread_list_test.cc +2 -2
- package/deps/rocksdb/rocksdb/util/thread_operation.h +2 -2
- package/deps/rocksdb/rocksdb/util/threadpool_imp.cc +2 -2
- package/deps/rocksdb/rocksdb/utilities/backup/backup_engine.cc +19 -2
- package/deps/rocksdb/rocksdb/utilities/backup/backup_engine_test.cc +75 -0
- package/deps/rocksdb/rocksdb/utilities/checkpoint/checkpoint_test.cc +1 -0
- package/deps/rocksdb/rocksdb/utilities/option_change_migration/option_change_migration.cc +303 -111
- package/deps/rocksdb/rocksdb/utilities/option_change_migration/option_change_migration_test.cc +379 -0
- package/deps/rocksdb/rocksdb.gyp +1 -0
- package/iterator.js +66 -70
- package/package.json +6 -6
- package/prebuilds/darwin-arm64/@nxtedition+rocksdb.node +0 -0
- package/deps/rocksdb/rocksdb/table/block_based/index_builder_test.cc +0 -183
|
@@ -268,8 +268,13 @@ class VersionStorageInfo {
|
|
|
268
268
|
bool expand_range = true, // if set, returns files which overlap the
|
|
269
269
|
// range and overlap each other. If false,
|
|
270
270
|
// then just files intersecting the range
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
const FileMetaData* starting_l0_file =
|
|
272
|
+
nullptr, // If not null, restricts L0 file selection to only include
|
|
273
|
+
// files at or older than starting_l0_file.
|
|
274
|
+
InternalKey** next_smallest =
|
|
275
|
+
nullptr // if non-null, returns the
|
|
276
|
+
// smallest key of next file not included
|
|
277
|
+
) const;
|
|
273
278
|
void GetCleanInputsWithinInterval(
|
|
274
279
|
int level, const InternalKey* begin, // nullptr means before all keys
|
|
275
280
|
const InternalKey* end, // nullptr means after all keys
|
|
@@ -286,8 +291,10 @@ class VersionStorageInfo {
|
|
|
286
291
|
int hint_index, // index of overlap file
|
|
287
292
|
int* file_index, // return index of overlap file
|
|
288
293
|
bool within_interval = false, // if set, force the inputs within interval
|
|
289
|
-
InternalKey** next_smallest =
|
|
290
|
-
|
|
294
|
+
InternalKey** next_smallest =
|
|
295
|
+
nullptr // if non-null, returns the
|
|
296
|
+
// smallest key of next file not included
|
|
297
|
+
) const;
|
|
291
298
|
|
|
292
299
|
// Returns true iff some file in the specified level overlaps
|
|
293
300
|
// some part of [*smallest_user_key,*largest_user_key].
|
|
@@ -1044,6 +1051,10 @@ class Version {
|
|
|
1044
1051
|
|
|
1045
1052
|
void GetColumnFamilyMetaData(ColumnFamilyMetaData* cf_meta);
|
|
1046
1053
|
|
|
1054
|
+
// Get column family metadata with optional filtering by key range and level.
|
|
1055
|
+
void GetColumnFamilyMetaData(const GetColumnFamilyMetaDataOptions& options,
|
|
1056
|
+
ColumnFamilyMetaData* cf_meta);
|
|
1057
|
+
|
|
1047
1058
|
void GetSstFilesBoundaryKeys(Slice* smallest_user_key,
|
|
1048
1059
|
Slice* largest_user_key);
|
|
1049
1060
|
|
|
@@ -1186,7 +1197,9 @@ class AtomicGroupReadBuffer {
|
|
|
1186
1197
|
// but false for secondary instance or writable DB).
|
|
1187
1198
|
class VersionSet {
|
|
1188
1199
|
public:
|
|
1189
|
-
VersionSet(const std::string& dbname,
|
|
1200
|
+
VersionSet(const std::string& dbname,
|
|
1201
|
+
const ImmutableDBOptions* imm_db_options,
|
|
1202
|
+
const MutableDBOptions& mutable_db_options,
|
|
1190
1203
|
const FileOptions& file_options, Cache* table_cache,
|
|
1191
1204
|
WriteBufferManager* write_buffer_manager,
|
|
1192
1205
|
WriteController* write_controller,
|
|
@@ -1203,6 +1216,13 @@ class VersionSet {
|
|
|
1203
1216
|
|
|
1204
1217
|
virtual Status Close(FSDirectory* db_dir, InstrumentedMutex* mu);
|
|
1205
1218
|
|
|
1219
|
+
// Requires: already holding DB mutex `mu`, to ensure
|
|
1220
|
+
// * Safely read values from `updated_options`
|
|
1221
|
+
// * Safely update fields on `this` (must be read elsewhere while holding mu)
|
|
1222
|
+
// except `mu` can be nullptr during initialization
|
|
1223
|
+
void UpdatedMutableDbOptions(const MutableDBOptions& updated_options,
|
|
1224
|
+
InstrumentedMutex* mu);
|
|
1225
|
+
|
|
1206
1226
|
Status LogAndApplyToDefaultColumnFamily(
|
|
1207
1227
|
const ReadOptions& read_options, const WriteOptions& write_options,
|
|
1208
1228
|
VersionEdit* edit, InstrumentedMutex* mu,
|
|
@@ -1548,10 +1568,6 @@ class VersionSet {
|
|
|
1548
1568
|
}
|
|
1549
1569
|
|
|
1550
1570
|
const FileOptions& file_options() { return file_options_; }
|
|
1551
|
-
void ChangeFileOptions(const MutableDBOptions& new_options) {
|
|
1552
|
-
file_options_.writable_file_max_buffer_size =
|
|
1553
|
-
new_options.writable_file_max_buffer_size;
|
|
1554
|
-
}
|
|
1555
1571
|
|
|
1556
1572
|
// TODO - Consider updating together when file options change in SetDBOptions
|
|
1557
1573
|
const OffpeakTimeOption& offpeak_time_option() {
|
|
@@ -1590,6 +1606,16 @@ class VersionSet {
|
|
|
1590
1606
|
|
|
1591
1607
|
bool& TEST_unchanging() { return const_cast<bool&>(unchanging_); }
|
|
1592
1608
|
|
|
1609
|
+
uint64_t TEST_GetMinMaxManifestFileSize() {
|
|
1610
|
+
return min_max_manifest_file_size_;
|
|
1611
|
+
}
|
|
1612
|
+
unsigned TEST_GetMaxManifestSpaceAmpPct() {
|
|
1613
|
+
return max_manifest_space_amp_pct_;
|
|
1614
|
+
}
|
|
1615
|
+
size_t TEST_GetManifestPreallocationSize() {
|
|
1616
|
+
return manifest_preallocation_size_;
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1593
1619
|
protected:
|
|
1594
1620
|
struct ManifestWriter;
|
|
1595
1621
|
|
|
@@ -1610,6 +1636,7 @@ class VersionSet {
|
|
|
1610
1636
|
}
|
|
1611
1637
|
};
|
|
1612
1638
|
|
|
1639
|
+
// Revert back to a post-construction state (keep same options/settings)
|
|
1613
1640
|
void Reset();
|
|
1614
1641
|
|
|
1615
1642
|
// Returns approximated offset of a key in a file for a given version.
|
|
@@ -1648,6 +1675,11 @@ class VersionSet {
|
|
|
1648
1675
|
ColumnFamilyData* cfd, const std::string& fpath,
|
|
1649
1676
|
int level, const FileMetaData& meta);
|
|
1650
1677
|
|
|
1678
|
+
// Auto-tune next max size for the current manifest file based on its initial
|
|
1679
|
+
// "compacted" size and other parameters saved in this VersionSet. Must be
|
|
1680
|
+
// holding DB mutex if outside of DB startup.
|
|
1681
|
+
void TuneMaxManifestFileSize();
|
|
1682
|
+
|
|
1651
1683
|
// Protected by DB mutex.
|
|
1652
1684
|
WalSet wals_;
|
|
1653
1685
|
|
|
@@ -1699,6 +1731,20 @@ class VersionSet {
|
|
|
1699
1731
|
// Current size of manifest file
|
|
1700
1732
|
uint64_t manifest_file_size_;
|
|
1701
1733
|
|
|
1734
|
+
// Size of the populated manifest file last time it was re-written from
|
|
1735
|
+
// scratch.
|
|
1736
|
+
uint64_t last_compacted_manifest_file_size_;
|
|
1737
|
+
|
|
1738
|
+
// Auto-tuned max allowed size for the current manifest file
|
|
1739
|
+
uint64_t tuned_max_manifest_file_size_;
|
|
1740
|
+
|
|
1741
|
+
// Saved copy of max_manifest_file_size in (Mutable)DBOptions
|
|
1742
|
+
uint64_t min_max_manifest_file_size_;
|
|
1743
|
+
// Saved, sanitized copy from (Mutable)DBOptions
|
|
1744
|
+
unsigned max_manifest_space_amp_pct_;
|
|
1745
|
+
// Saved copy from (Mutable)DBOptions
|
|
1746
|
+
size_t manifest_preallocation_size_;
|
|
1747
|
+
|
|
1702
1748
|
// Obsolete files, or during DB shutdown any files not referenced by what's
|
|
1703
1749
|
// left of the in-memory LSM state.
|
|
1704
1750
|
std::vector<ObsoleteFileInfo> obsolete_files_;
|
|
@@ -1751,6 +1797,7 @@ class ReactiveVersionSet : public VersionSet {
|
|
|
1751
1797
|
public:
|
|
1752
1798
|
ReactiveVersionSet(const std::string& dbname,
|
|
1753
1799
|
const ImmutableDBOptions* _db_options,
|
|
1800
|
+
const MutableDBOptions& mutable_db_options,
|
|
1754
1801
|
const FileOptions& _file_options, Cache* table_cache,
|
|
1755
1802
|
WriteBufferManager* write_buffer_manager,
|
|
1756
1803
|
WriteController* write_controller,
|
|
@@ -1159,12 +1159,12 @@ class VersionSetTestBase {
|
|
|
1159
1159
|
: env_(nullptr),
|
|
1160
1160
|
dbname_(test::PerThreadDBPath(name)),
|
|
1161
1161
|
options_(),
|
|
1162
|
-
|
|
1162
|
+
imm_db_options_(options_),
|
|
1163
1163
|
cf_options_(options_),
|
|
1164
|
-
immutable_options_(
|
|
1164
|
+
immutable_options_(imm_db_options_, cf_options_),
|
|
1165
1165
|
mutable_cf_options_(cf_options_),
|
|
1166
1166
|
table_cache_(NewLRUCache(50000, 16)),
|
|
1167
|
-
write_buffer_manager_(
|
|
1167
|
+
write_buffer_manager_(imm_db_options_.db_write_buffer_size),
|
|
1168
1168
|
shutting_down_(false),
|
|
1169
1169
|
table_factory_(std::make_shared<mock::MockTableFactory>()) {
|
|
1170
1170
|
EXPECT_OK(test::CreateEnvFromSystem(ConfigOptions(), &env_, &env_guard_));
|
|
@@ -1178,8 +1178,8 @@ class VersionSetTestBase {
|
|
|
1178
1178
|
EXPECT_OK(fs_->CreateDirIfMissing(dbname_, IOOptions(), nullptr));
|
|
1179
1179
|
|
|
1180
1180
|
options_.env = env_;
|
|
1181
|
-
|
|
1182
|
-
|
|
1181
|
+
imm_db_options_.env = env_;
|
|
1182
|
+
imm_db_options_.fs = fs_;
|
|
1183
1183
|
immutable_options_.env = env_;
|
|
1184
1184
|
immutable_options_.fs = fs_;
|
|
1185
1185
|
immutable_options_.clock = env_->GetSystemClock().get();
|
|
@@ -1188,16 +1188,17 @@ class VersionSetTestBase {
|
|
|
1188
1188
|
mutable_cf_options_.table_factory = table_factory_;
|
|
1189
1189
|
|
|
1190
1190
|
versions_.reset(new VersionSet(
|
|
1191
|
-
dbname_, &
|
|
1192
|
-
&write_buffer_manager_, &write_controller_,
|
|
1191
|
+
dbname_, &imm_db_options_, mutable_db_options_, env_options_,
|
|
1192
|
+
table_cache_.get(), &write_buffer_manager_, &write_controller_,
|
|
1193
1193
|
/*block_cache_tracer=*/nullptr, /*io_tracer=*/nullptr,
|
|
1194
1194
|
/*db_id=*/"", /*db_session_id=*/"", /*daily_offpeak_time_utc=*/"",
|
|
1195
1195
|
/*error_handler=*/nullptr, /*read_only=*/false));
|
|
1196
1196
|
reactive_versions_ = std::make_shared<ReactiveVersionSet>(
|
|
1197
|
-
dbname_, &
|
|
1198
|
-
&write_buffer_manager_, &write_controller_,
|
|
1199
|
-
|
|
1200
|
-
|
|
1197
|
+
dbname_, &imm_db_options_, mutable_db_options_, env_options_,
|
|
1198
|
+
table_cache_.get(), &write_buffer_manager_, &write_controller_,
|
|
1199
|
+
nullptr);
|
|
1200
|
+
imm_db_options_.db_paths.emplace_back(dbname_,
|
|
1201
|
+
std::numeric_limits<uint64_t>::max());
|
|
1201
1202
|
}
|
|
1202
1203
|
|
|
1203
1204
|
virtual ~VersionSetTestBase() {
|
|
@@ -1220,7 +1221,7 @@ class VersionSetTestBase {
|
|
|
1220
1221
|
ASSERT_OK(
|
|
1221
1222
|
SetIdentityFile(WriteOptions(), env_, dbname_, Temperature::kUnknown));
|
|
1222
1223
|
VersionEdit new_db;
|
|
1223
|
-
if (
|
|
1224
|
+
if (imm_db_options_.write_dbid_to_manifest) {
|
|
1224
1225
|
DBOptions tmp_db_options;
|
|
1225
1226
|
tmp_db_options.env = env_;
|
|
1226
1227
|
std::unique_ptr<DBImpl> impl(new DBImpl(tmp_db_options, dbname_));
|
|
@@ -1381,8 +1382,8 @@ class VersionSetTestBase {
|
|
|
1381
1382
|
|
|
1382
1383
|
void ReopenDB() {
|
|
1383
1384
|
versions_.reset(new VersionSet(
|
|
1384
|
-
dbname_, &
|
|
1385
|
-
&write_buffer_manager_, &write_controller_,
|
|
1385
|
+
dbname_, &imm_db_options_, mutable_db_options_, env_options_,
|
|
1386
|
+
table_cache_.get(), &write_buffer_manager_, &write_controller_,
|
|
1386
1387
|
/*block_cache_tracer=*/nullptr, /*io_tracer=*/nullptr,
|
|
1387
1388
|
/*db_id=*/"", /*db_session_id=*/"", /*daily_offpeak_time_utc=*/"",
|
|
1388
1389
|
/*error_handler=*/nullptr, /*read_only=*/false));
|
|
@@ -1471,7 +1472,8 @@ class VersionSetTestBase {
|
|
|
1471
1472
|
const std::string dbname_;
|
|
1472
1473
|
EnvOptions env_options_;
|
|
1473
1474
|
Options options_;
|
|
1474
|
-
ImmutableDBOptions
|
|
1475
|
+
ImmutableDBOptions imm_db_options_;
|
|
1476
|
+
MutableDBOptions mutable_db_options_;
|
|
1475
1477
|
ColumnFamilyOptions cf_options_;
|
|
1476
1478
|
ImmutableOptions immutable_options_;
|
|
1477
1479
|
MutableCFOptions mutable_cf_options_;
|
|
@@ -1902,8 +1904,8 @@ TEST_F(VersionSetTest, WalAddition) {
|
|
|
1902
1904
|
// Recover a new VersionSet.
|
|
1903
1905
|
{
|
|
1904
1906
|
std::unique_ptr<VersionSet> new_versions(new VersionSet(
|
|
1905
|
-
dbname_, &
|
|
1906
|
-
&write_buffer_manager_, &write_controller_,
|
|
1907
|
+
dbname_, &imm_db_options_, mutable_db_options_, env_options_,
|
|
1908
|
+
table_cache_.get(), &write_buffer_manager_, &write_controller_,
|
|
1907
1909
|
/*block_cache_tracer=*/nullptr, /*io_tracer=*/nullptr,
|
|
1908
1910
|
/*db_id=*/"", /*db_session_id=*/"", /*daily_offpeak_time_utc=*/"",
|
|
1909
1911
|
/*error_handler=*/nullptr, /*unchanging=*/false));
|
|
@@ -1970,8 +1972,8 @@ TEST_F(VersionSetTest, WalCloseWithoutSync) {
|
|
|
1970
1972
|
// Recover a new VersionSet.
|
|
1971
1973
|
{
|
|
1972
1974
|
std::unique_ptr<VersionSet> new_versions(new VersionSet(
|
|
1973
|
-
dbname_, &
|
|
1974
|
-
&write_buffer_manager_, &write_controller_,
|
|
1975
|
+
dbname_, &imm_db_options_, mutable_db_options_, env_options_,
|
|
1976
|
+
table_cache_.get(), &write_buffer_manager_, &write_controller_,
|
|
1975
1977
|
/*block_cache_tracer=*/nullptr, /*io_tracer=*/nullptr,
|
|
1976
1978
|
/*db_id=*/"", /*db_session_id=*/"", /*daily_offpeak_time_utc=*/"",
|
|
1977
1979
|
/*error_handler=*/nullptr, /*unchanging=*/false));
|
|
@@ -2024,8 +2026,8 @@ TEST_F(VersionSetTest, WalDeletion) {
|
|
|
2024
2026
|
// Recover a new VersionSet, only the non-closed WAL should show up.
|
|
2025
2027
|
{
|
|
2026
2028
|
std::unique_ptr<VersionSet> new_versions(new VersionSet(
|
|
2027
|
-
dbname_, &
|
|
2028
|
-
&write_buffer_manager_, &write_controller_,
|
|
2029
|
+
dbname_, &imm_db_options_, mutable_db_options_, env_options_,
|
|
2030
|
+
table_cache_.get(), &write_buffer_manager_, &write_controller_,
|
|
2029
2031
|
/*block_cache_tracer=*/nullptr, /*io_tracer=*/nullptr,
|
|
2030
2032
|
/*db_id=*/"", /*db_session_id=*/"", /*daily_offpeak_time_utc=*/"",
|
|
2031
2033
|
/*error_handler=*/nullptr, /*unchanging=*/false));
|
|
@@ -2063,8 +2065,8 @@ TEST_F(VersionSetTest, WalDeletion) {
|
|
|
2063
2065
|
// Recover from the new MANIFEST, only the non-closed WAL should show up.
|
|
2064
2066
|
{
|
|
2065
2067
|
std::unique_ptr<VersionSet> new_versions(new VersionSet(
|
|
2066
|
-
dbname_, &
|
|
2067
|
-
&write_buffer_manager_, &write_controller_,
|
|
2068
|
+
dbname_, &imm_db_options_, mutable_db_options_, env_options_,
|
|
2069
|
+
table_cache_.get(), &write_buffer_manager_, &write_controller_,
|
|
2068
2070
|
/*block_cache_tracer=*/nullptr, /*io_tracer=*/nullptr,
|
|
2069
2071
|
/*db_id=*/"", /*db_session_id=*/"", /*daily_offpeak_time_utc=*/"",
|
|
2070
2072
|
/*error_handler=*/nullptr, /*unchanging=*/false));
|
|
@@ -2184,8 +2186,8 @@ TEST_F(VersionSetTest, DeleteWalsBeforeNonExistingWalNumber) {
|
|
|
2184
2186
|
// Recover a new VersionSet, WAL0 is deleted, WAL1 is not.
|
|
2185
2187
|
{
|
|
2186
2188
|
std::unique_ptr<VersionSet> new_versions(new VersionSet(
|
|
2187
|
-
dbname_, &
|
|
2188
|
-
&write_buffer_manager_, &write_controller_,
|
|
2189
|
+
dbname_, &imm_db_options_, mutable_db_options_, env_options_,
|
|
2190
|
+
table_cache_.get(), &write_buffer_manager_, &write_controller_,
|
|
2189
2191
|
/*block_cache_tracer=*/nullptr, /*io_tracer=*/nullptr,
|
|
2190
2192
|
/*db_id=*/"", /*db_session_id=*/"", /*daily_offpeak_time_utc=*/"",
|
|
2191
2193
|
/*error_handler=*/nullptr, /*unchanging=*/false));
|
|
@@ -2221,8 +2223,8 @@ TEST_F(VersionSetTest, DeleteAllWals) {
|
|
|
2221
2223
|
// Recover a new VersionSet, all WALs are deleted.
|
|
2222
2224
|
{
|
|
2223
2225
|
std::unique_ptr<VersionSet> new_versions(new VersionSet(
|
|
2224
|
-
dbname_, &
|
|
2225
|
-
&write_buffer_manager_, &write_controller_,
|
|
2226
|
+
dbname_, &imm_db_options_, mutable_db_options_, env_options_,
|
|
2227
|
+
table_cache_.get(), &write_buffer_manager_, &write_controller_,
|
|
2226
2228
|
/*block_cache_tracer=*/nullptr, /*io_tracer=*/nullptr,
|
|
2227
2229
|
/*db_id=*/"", /*db_session_id=*/"", /*daily_offpeak_time_utc=*/"",
|
|
2228
2230
|
/*error_handler=*/nullptr, /*unchanging=*/false));
|
|
@@ -2264,8 +2266,8 @@ TEST_F(VersionSetTest, AtomicGroupWithWalEdits) {
|
|
|
2264
2266
|
// kept.
|
|
2265
2267
|
{
|
|
2266
2268
|
std::unique_ptr<VersionSet> new_versions(new VersionSet(
|
|
2267
|
-
dbname_, &
|
|
2268
|
-
&write_buffer_manager_, &write_controller_,
|
|
2269
|
+
dbname_, &imm_db_options_, mutable_db_options_, env_options_,
|
|
2270
|
+
table_cache_.get(), &write_buffer_manager_, &write_controller_,
|
|
2269
2271
|
/*block_cache_tracer=*/nullptr, /*io_tracer=*/nullptr,
|
|
2270
2272
|
/*db_id=*/"", /*db_session_id=*/"", /*daily_offpeak_time_utc=*/"",
|
|
2271
2273
|
/*error_handler=*/nullptr, /*unchanging=*/false));
|
|
@@ -2444,8 +2446,8 @@ class VersionSetWithTimestampTest : public VersionSetTest {
|
|
|
2444
2446
|
|
|
2445
2447
|
void VerifyFullHistoryTsLow(uint64_t expected_ts_low) {
|
|
2446
2448
|
std::unique_ptr<VersionSet> vset(new VersionSet(
|
|
2447
|
-
dbname_, &
|
|
2448
|
-
&write_buffer_manager_, &write_controller_,
|
|
2449
|
+
dbname_, &imm_db_options_, mutable_db_options_, env_options_,
|
|
2450
|
+
table_cache_.get(), &write_buffer_manager_, &write_controller_,
|
|
2449
2451
|
/*block_cache_tracer=*/nullptr, /*io_tracer=*/nullptr,
|
|
2450
2452
|
/*db_id=*/"", /*db_session_id=*/"", /*daily_offpeak_time_utc=*/"",
|
|
2451
2453
|
/*error_handler=*/nullptr, /*unchanging=*/false));
|
|
@@ -3500,7 +3502,7 @@ class VersionSetTestEmptyDb
|
|
|
3500
3502
|
std::unique_ptr<log::Writer>* log_writer) override {
|
|
3501
3503
|
assert(nullptr != log_writer);
|
|
3502
3504
|
VersionEdit new_db;
|
|
3503
|
-
if (
|
|
3505
|
+
if (imm_db_options_.write_dbid_to_manifest) {
|
|
3504
3506
|
ASSERT_OK(SetIdentityFile(WriteOptions(), env_, dbname_,
|
|
3505
3507
|
Temperature::kUnknown));
|
|
3506
3508
|
DBOptions tmp_db_options;
|
|
@@ -3532,7 +3534,7 @@ class VersionSetTestEmptyDb
|
|
|
3532
3534
|
const std::string VersionSetTestEmptyDb::kUnknownColumnFamilyName = "unknown";
|
|
3533
3535
|
|
|
3534
3536
|
TEST_P(VersionSetTestEmptyDb, OpenFromIncompleteManifest0) {
|
|
3535
|
-
|
|
3537
|
+
imm_db_options_.write_dbid_to_manifest = std::get<0>(GetParam());
|
|
3536
3538
|
PrepareManifest(nullptr, nullptr, &log_writer_);
|
|
3537
3539
|
log_writer_.reset();
|
|
3538
3540
|
CreateCurrentFile();
|
|
@@ -3564,7 +3566,7 @@ TEST_P(VersionSetTestEmptyDb, OpenFromIncompleteManifest0) {
|
|
|
3564
3566
|
}
|
|
3565
3567
|
|
|
3566
3568
|
TEST_P(VersionSetTestEmptyDb, OpenFromIncompleteManifest1) {
|
|
3567
|
-
|
|
3569
|
+
imm_db_options_.write_dbid_to_manifest = std::get<0>(GetParam());
|
|
3568
3570
|
PrepareManifest(nullptr, nullptr, &log_writer_);
|
|
3569
3571
|
// Only a subset of column families in the MANIFEST.
|
|
3570
3572
|
VersionEdit new_cf1;
|
|
@@ -3605,7 +3607,7 @@ TEST_P(VersionSetTestEmptyDb, OpenFromIncompleteManifest1) {
|
|
|
3605
3607
|
}
|
|
3606
3608
|
|
|
3607
3609
|
TEST_P(VersionSetTestEmptyDb, OpenFromInCompleteManifest2) {
|
|
3608
|
-
|
|
3610
|
+
imm_db_options_.write_dbid_to_manifest = std::get<0>(GetParam());
|
|
3609
3611
|
PrepareManifest(nullptr, nullptr, &log_writer_);
|
|
3610
3612
|
// Write all column families but no log_number, next_file_number and
|
|
3611
3613
|
// last_sequence.
|
|
@@ -3651,7 +3653,7 @@ TEST_P(VersionSetTestEmptyDb, OpenFromInCompleteManifest2) {
|
|
|
3651
3653
|
}
|
|
3652
3654
|
|
|
3653
3655
|
TEST_P(VersionSetTestEmptyDb, OpenManifestWithUnknownCF) {
|
|
3654
|
-
|
|
3656
|
+
imm_db_options_.write_dbid_to_manifest = std::get<0>(GetParam());
|
|
3655
3657
|
PrepareManifest(nullptr, nullptr, &log_writer_);
|
|
3656
3658
|
// Write all column families but no log_number, next_file_number and
|
|
3657
3659
|
// last_sequence.
|
|
@@ -3708,7 +3710,7 @@ TEST_P(VersionSetTestEmptyDb, OpenManifestWithUnknownCF) {
|
|
|
3708
3710
|
}
|
|
3709
3711
|
|
|
3710
3712
|
TEST_P(VersionSetTestEmptyDb, OpenCompleteManifest) {
|
|
3711
|
-
|
|
3713
|
+
imm_db_options_.write_dbid_to_manifest = std::get<0>(GetParam());
|
|
3712
3714
|
PrepareManifest(nullptr, nullptr, &log_writer_);
|
|
3713
3715
|
// Write all column families but no log_number, next_file_number and
|
|
3714
3716
|
// last_sequence.
|
|
@@ -3828,7 +3830,7 @@ class VersionSetTestMissingFiles : public VersionSetTestBase,
|
|
|
3828
3830
|
ASSERT_OK(s);
|
|
3829
3831
|
log_writer->reset(new log::Writer(std::move(file_writer), 0, false));
|
|
3830
3832
|
VersionEdit new_db;
|
|
3831
|
-
if (
|
|
3833
|
+
if (imm_db_options_.write_dbid_to_manifest) {
|
|
3832
3834
|
DBOptions tmp_db_options;
|
|
3833
3835
|
tmp_db_options.env = env_;
|
|
3834
3836
|
std::unique_ptr<DBImpl> impl(new DBImpl(tmp_db_options, dbname_));
|
|
@@ -4088,7 +4090,7 @@ TEST_F(VersionSetTestMissingFiles, NoFileMissing) {
|
|
|
4088
4090
|
}
|
|
4089
4091
|
|
|
4090
4092
|
TEST_F(VersionSetTestMissingFiles, MinLogNumberToKeep2PC) {
|
|
4091
|
-
|
|
4093
|
+
imm_db_options_.allow_2pc = true;
|
|
4092
4094
|
NewDB();
|
|
4093
4095
|
|
|
4094
4096
|
SstInfo sst(100, kDefaultColumnFamilyName, "a", 0 /* level */,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright (c)
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
// This source code is licensed under both the GPLv2 (found in the
|
|
3
3
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
4
4
|
// (found in the LICENSE.Apache file in the root directory).
|
|
@@ -23,7 +23,8 @@ class OfflineManifestWriter {
|
|
|
23
23
|
immutable_db_options_(WithDbPath(options, db_path)),
|
|
24
24
|
tc_(NewLRUCache(1 << 20 /* capacity */,
|
|
25
25
|
options.table_cache_numshardbits)),
|
|
26
|
-
versions_(db_path, &immutable_db_options_,
|
|
26
|
+
versions_(db_path, &immutable_db_options_, MutableDBOptions{options},
|
|
27
|
+
sopt_, tc_.get(), &wb_, &wc_,
|
|
27
28
|
/*block_cache_tracer=*/nullptr, /*io_tracer=*/nullptr,
|
|
28
29
|
/*db_id=*/"", /*db_session_id=*/"",
|
|
29
30
|
options.daily_offpeak_time_utc,
|
|
@@ -192,7 +192,13 @@ void WalManager::PurgeObsoleteWALFiles() {
|
|
|
192
192
|
s.ToString().c_str());
|
|
193
193
|
continue;
|
|
194
194
|
}
|
|
195
|
-
|
|
195
|
+
|
|
196
|
+
// Avoid expression `now_seconds - file_m_time` when
|
|
197
|
+
// `file_m_time > now_seconds` to prevent unsigned underflow in case
|
|
198
|
+
// system clock goes backwards. Both timestamps are based on wall clock
|
|
199
|
+
// time, which is not guaranteed to be monotonic.
|
|
200
|
+
if (file_m_time <= now_seconds &&
|
|
201
|
+
now_seconds - file_m_time > db_options_.WAL_ttl_seconds) {
|
|
196
202
|
s = DeleteDBFile(&db_options_, file_path, archival_dir, false,
|
|
197
203
|
/*force_fg=*/!wal_in_db_path_);
|
|
198
204
|
if (!s.ok()) {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
#include "rocksdb/write_batch.h"
|
|
20
20
|
#include "rocksdb/write_buffer_manager.h"
|
|
21
21
|
#include "table/mock_table.h"
|
|
22
|
+
#include "test_util/mock_time_env.h"
|
|
22
23
|
#include "test_util/testharness.h"
|
|
23
24
|
#include "test_util/testutil.h"
|
|
24
25
|
#include "util/string_util.h"
|
|
@@ -39,7 +40,7 @@ class WalManagerTest : public testing::Test {
|
|
|
39
40
|
EXPECT_OK(DestroyDB(dbname_, Options()));
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
void Init() {
|
|
43
|
+
void Init(SystemClock* clock_override) {
|
|
43
44
|
ASSERT_OK(env_->CreateDirIfMissing(dbname_));
|
|
44
45
|
ASSERT_OK(env_->CreateDirIfMissing(ArchivalDirectory(dbname_)));
|
|
45
46
|
db_options_.db_paths.emplace_back(dbname_,
|
|
@@ -47,11 +48,15 @@ class WalManagerTest : public testing::Test {
|
|
|
47
48
|
db_options_.wal_dir = dbname_;
|
|
48
49
|
db_options_.env = env_.get();
|
|
49
50
|
db_options_.fs = env_->GetFileSystem();
|
|
50
|
-
|
|
51
|
+
if (clock_override == nullptr) {
|
|
52
|
+
db_options_.clock = env_->GetSystemClock().get();
|
|
53
|
+
} else {
|
|
54
|
+
db_options_.clock = clock_override;
|
|
55
|
+
}
|
|
51
56
|
|
|
52
57
|
versions_.reset(new VersionSet(
|
|
53
|
-
dbname_, &db_options_,
|
|
54
|
-
&write_buffer_manager_, &write_controller_,
|
|
58
|
+
dbname_, &db_options_, MutableDBOptions{}, env_options_,
|
|
59
|
+
table_cache_.get(), &write_buffer_manager_, &write_controller_,
|
|
55
60
|
/*block_cache_tracer=*/nullptr, /*io_tracer=*/nullptr,
|
|
56
61
|
/*db_id=*/"", /*db_session_id=*/"", /*daily_offpeak_time_utc=*/"",
|
|
57
62
|
/*error_handler=*/nullptr, /*read_only=*/false));
|
|
@@ -124,7 +129,7 @@ class WalManagerTest : public testing::Test {
|
|
|
124
129
|
};
|
|
125
130
|
|
|
126
131
|
TEST_F(WalManagerTest, ReadFirstRecordCache) {
|
|
127
|
-
Init();
|
|
132
|
+
Init(nullptr /* clock_override */);
|
|
128
133
|
std::string path = dbname_ + "/000001.log";
|
|
129
134
|
std::unique_ptr<FSWritableFile> file;
|
|
130
135
|
ASSERT_OK(env_->GetFileSystem()->NewWritableFile(path, FileOptions(), &file,
|
|
@@ -221,7 +226,7 @@ int CountRecords(TransactionLogIterator* iter) {
|
|
|
221
226
|
TEST_F(WalManagerTest, WALArchivalSizeLimit) {
|
|
222
227
|
db_options_.WAL_ttl_seconds = 0;
|
|
223
228
|
db_options_.WAL_size_limit_MB = 1000;
|
|
224
|
-
Init();
|
|
229
|
+
Init(nullptr /* clock_override */);
|
|
225
230
|
|
|
226
231
|
// TEST : Create WalManager with huge size limit and no ttl.
|
|
227
232
|
// Create some archived files and call PurgeObsoleteWALFiles().
|
|
@@ -258,7 +263,7 @@ TEST_F(WalManagerTest, WALArchivalSizeLimit) {
|
|
|
258
263
|
|
|
259
264
|
TEST_F(WalManagerTest, WALArchivalTtl) {
|
|
260
265
|
db_options_.WAL_ttl_seconds = 1000;
|
|
261
|
-
Init();
|
|
266
|
+
Init(nullptr /* clock_override */);
|
|
262
267
|
|
|
263
268
|
// TEST : Create WalManager with a ttl and no size limit.
|
|
264
269
|
// Create some archived log files and call PurgeObsoleteWALFiles().
|
|
@@ -282,8 +287,41 @@ TEST_F(WalManagerTest, WALArchivalTtl) {
|
|
|
282
287
|
ASSERT_TRUE(log_files.empty());
|
|
283
288
|
}
|
|
284
289
|
|
|
290
|
+
TEST_F(WalManagerTest, WALArchivalTtlClockGoesBackwards) {
|
|
291
|
+
// This test used to trigger an unsigned underflow bug, where WAL files were
|
|
292
|
+
// incorrectly deleted when the system time moved backwards between writing
|
|
293
|
+
// to a WAL and running `WalManager::PurgeObsoleteWALFiles()`.
|
|
294
|
+
constexpr int kNumLogs = 5;
|
|
295
|
+
constexpr int kEntriesPerLog = 100;
|
|
296
|
+
|
|
297
|
+
db_options_.WAL_ttl_seconds = 86400; // One day
|
|
298
|
+
|
|
299
|
+
// Configure mock clock to lag one second behind system time. That way, the
|
|
300
|
+
// WAL file's mtime will appear to be in the future when
|
|
301
|
+
// `WalManager::PurgeObsoleteWALFiles()` runs.
|
|
302
|
+
int64_t now_seconds;
|
|
303
|
+
ASSERT_OK(env_->GetSystemClock()->GetCurrentTime(&now_seconds));
|
|
304
|
+
auto mock_clock = std::make_shared<MockSystemClock>(env_->GetSystemClock());
|
|
305
|
+
mock_clock->SetCurrentTime(static_cast<uint64_t>(now_seconds - 1));
|
|
306
|
+
db_options_.clock = mock_clock.get();
|
|
307
|
+
|
|
308
|
+
Init(mock_clock.get() /* clock */);
|
|
309
|
+
|
|
310
|
+
CreateArchiveLogs(kNumLogs, kEntriesPerLog);
|
|
311
|
+
|
|
312
|
+
const std::string archive_dir = ArchivalDirectory(dbname_);
|
|
313
|
+
ASSERT_EQ(kNumLogs,
|
|
314
|
+
ListSpecificFiles(env_.get(), archive_dir, kWalFile).size());
|
|
315
|
+
|
|
316
|
+
wal_manager_->PurgeObsoleteWALFiles();
|
|
317
|
+
|
|
318
|
+
// All files must still be present because TTL has not elapsed.
|
|
319
|
+
ASSERT_EQ(kNumLogs,
|
|
320
|
+
ListSpecificFiles(env_.get(), archive_dir, kWalFile).size());
|
|
321
|
+
}
|
|
322
|
+
|
|
285
323
|
TEST_F(WalManagerTest, TransactionLogIteratorMoveOverZeroFiles) {
|
|
286
|
-
Init();
|
|
324
|
+
Init(nullptr /* clock_override */);
|
|
287
325
|
RollTheLog(false);
|
|
288
326
|
Put("key1", std::string(1024, 'a'));
|
|
289
327
|
// Create a zero record WAL file.
|
|
@@ -297,7 +335,7 @@ TEST_F(WalManagerTest, TransactionLogIteratorMoveOverZeroFiles) {
|
|
|
297
335
|
}
|
|
298
336
|
|
|
299
337
|
TEST_F(WalManagerTest, TransactionLogIteratorJustEmptyFile) {
|
|
300
|
-
Init();
|
|
338
|
+
Init(nullptr /* clock_override */);
|
|
301
339
|
RollTheLog(false);
|
|
302
340
|
auto iter = OpenTransactionLogIter(0);
|
|
303
341
|
// Check that an empty iterator is returned
|
|
@@ -305,7 +343,7 @@ TEST_F(WalManagerTest, TransactionLogIteratorJustEmptyFile) {
|
|
|
305
343
|
}
|
|
306
344
|
|
|
307
345
|
TEST_F(WalManagerTest, TransactionLogIteratorNewFileWhileScanning) {
|
|
308
|
-
Init();
|
|
346
|
+
Init(nullptr /* clock_override */);
|
|
309
347
|
CreateArchiveLogs(2, 100);
|
|
310
348
|
auto iter = OpenTransactionLogIter(0);
|
|
311
349
|
CreateArchiveLogs(1, 100);
|
|
@@ -248,6 +248,7 @@ DECLARE_string(fs_uri);
|
|
|
248
248
|
DECLARE_uint64(ops_per_thread);
|
|
249
249
|
DECLARE_uint64(log2_keys_per_lock);
|
|
250
250
|
DECLARE_uint64(max_manifest_file_size);
|
|
251
|
+
DECLARE_int32(max_manifest_space_amp_pct);
|
|
251
252
|
DECLARE_bool(in_place_update);
|
|
252
253
|
DECLARE_string(memtablerep);
|
|
253
254
|
DECLARE_int32(prefix_size);
|
|
@@ -978,7 +978,11 @@ DEFINE_uint64(log2_keys_per_lock, 2, "Log2 of number of keys per lock");
|
|
|
978
978
|
static const bool FLAGS_log2_keys_per_lock_dummy __attribute__((__unused__)) =
|
|
979
979
|
RegisterFlagValidator(&FLAGS_log2_keys_per_lock, &ValidateUint32Range);
|
|
980
980
|
|
|
981
|
-
DEFINE_uint64(max_manifest_file_size, 16384,
|
|
981
|
+
DEFINE_uint64(max_manifest_file_size, 16384,
|
|
982
|
+
"Maximum size of a MANIFEST file (without auto-tuning)");
|
|
983
|
+
|
|
984
|
+
DEFINE_int32(max_manifest_space_amp_pct, 500,
|
|
985
|
+
"Max manifest space amp percentage for auto-tuning");
|
|
982
986
|
|
|
983
987
|
DEFINE_bool(in_place_update, false, "On true, does inplace update in memtable");
|
|
984
988
|
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
#include "db_stress_tool/db_stress_filters.h"
|
|
26
26
|
#include "db_stress_tool/db_stress_table_properties_collector.h"
|
|
27
27
|
#include "db_stress_tool/db_stress_wide_merge_operator.h"
|
|
28
|
+
#include "file/file_util.h"
|
|
28
29
|
#include "options/options_parser.h"
|
|
29
30
|
#include "rocksdb/convenience.h"
|
|
30
31
|
#include "rocksdb/filter_policy.h"
|
|
@@ -194,10 +195,10 @@ std::shared_ptr<Cache> StressTest::NewCache(size_t capacity,
|
|
|
194
195
|
exit(1);
|
|
195
196
|
} else if (EndsWith(cache_type, "hyper_clock_cache")) {
|
|
196
197
|
size_t estimated_entry_charge;
|
|
197
|
-
if (cache_type == "fixed_hyper_clock_cache"
|
|
198
|
-
cache_type == "hyper_clock_cache") {
|
|
198
|
+
if (cache_type == "fixed_hyper_clock_cache") {
|
|
199
199
|
estimated_entry_charge = FLAGS_block_size;
|
|
200
|
-
} else if (cache_type == "auto_hyper_clock_cache"
|
|
200
|
+
} else if (cache_type == "auto_hyper_clock_cache" ||
|
|
201
|
+
cache_type == "hyper_clock_cache") {
|
|
201
202
|
estimated_entry_charge = 0;
|
|
202
203
|
} else {
|
|
203
204
|
fprintf(stderr, "Cache type not supported.");
|
|
@@ -349,7 +350,6 @@ bool StressTest::BuildOptionsTable() {
|
|
|
349
350
|
"1",
|
|
350
351
|
"2",
|
|
351
352
|
}},
|
|
352
|
-
{"max_sequential_skip_in_iterations", {"4", "8", "12"}},
|
|
353
353
|
{"block_based_table_factory",
|
|
354
354
|
{
|
|
355
355
|
keepRibbonFilterPolicyOnly ? "{filter_policy=ribbonfilter:2.35}"
|
|
@@ -362,6 +362,13 @@ bool StressTest::BuildOptionsTable() {
|
|
|
362
362
|
std::to_string(FLAGS_block_size + (FLAGS_seed & 0xFFFU)) + "}",
|
|
363
363
|
}},
|
|
364
364
|
};
|
|
365
|
+
if (FLAGS_use_multiscan == 0) {
|
|
366
|
+
// TODO: this can fail MultiScan when consecutive data blocks share the
|
|
367
|
+
// same user at boundary. MultiScan uses user key to locate the block to
|
|
368
|
+
// reach which can move the scan earlier than its current block.
|
|
369
|
+
options_tbl.emplace("max_sequential_skip_in_iterations",
|
|
370
|
+
std::vector<std::string>{"4", "8", "12"});
|
|
371
|
+
}
|
|
365
372
|
if (FLAGS_compaction_style == kCompactionStyleUniversal &&
|
|
366
373
|
FLAGS_universal_max_read_amp > 0) {
|
|
367
374
|
// level0_file_num_compaction_trigger needs to be at most max_read_amp
|
|
@@ -1695,7 +1702,10 @@ Status StressTest::TestMultiScan(ThreadState* thread,
|
|
|
1695
1702
|
std::vector<std::string> end_key_strs;
|
|
1696
1703
|
// TODO support reverse BytewiseComparator in the stress test
|
|
1697
1704
|
MultiScanArgs scan_opts(options_.comparator);
|
|
1698
|
-
scan_opts.use_async_io =
|
|
1705
|
+
scan_opts.use_async_io =
|
|
1706
|
+
FLAGS_multiscan_use_async_io &&
|
|
1707
|
+
CheckFSFeatureSupport(options_.env->GetFileSystem().get(),
|
|
1708
|
+
FSSupportedOps::kAsyncIO);
|
|
1699
1709
|
start_key_strs.reserve(num_scans);
|
|
1700
1710
|
end_key_strs.reserve(num_scans);
|
|
1701
1711
|
|
|
@@ -4420,6 +4430,7 @@ void InitializeOptionsFromFlags(
|
|
|
4420
4430
|
options.compression_opts.checksum = true;
|
|
4421
4431
|
}
|
|
4422
4432
|
options.max_manifest_file_size = FLAGS_max_manifest_file_size;
|
|
4433
|
+
options.max_manifest_space_amp_pct = FLAGS_max_manifest_space_amp_pct;
|
|
4423
4434
|
options.max_subcompactions = static_cast<uint32_t>(FLAGS_subcompactions);
|
|
4424
4435
|
options.allow_concurrent_memtable_write =
|
|
4425
4436
|
FLAGS_allow_concurrent_memtable_write;
|