@nxtedition/rocksdb 12.1.4 → 12.1.6
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/binding.cc +2 -2
- package/deps/rocksdb/rocksdb/Makefile +10 -5
- package/deps/rocksdb/rocksdb/TARGETS +9 -7
- package/deps/rocksdb/rocksdb/cache/cache.cc +15 -11
- package/deps/rocksdb/rocksdb/cache/cache_test.cc +26 -0
- package/deps/rocksdb/rocksdb/cache/clock_cache.cc +16 -0
- package/deps/rocksdb/rocksdb/cache/clock_cache.h +6 -0
- package/deps/rocksdb/rocksdb/cache/compressed_secondary_cache.cc +38 -8
- package/deps/rocksdb/rocksdb/cache/compressed_secondary_cache.h +2 -0
- package/deps/rocksdb/rocksdb/cache/compressed_secondary_cache_test.cc +4 -0
- package/deps/rocksdb/rocksdb/cache/lru_cache.cc +11 -0
- package/deps/rocksdb/rocksdb/cache/lru_cache.h +6 -0
- package/deps/rocksdb/rocksdb/cache/secondary_cache_adapter.cc +2 -1
- package/deps/rocksdb/rocksdb/cache/tiered_secondary_cache_test.cc +56 -0
- package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.cc +12 -9
- package/deps/rocksdb/rocksdb/db/blob/blob_file_cache.cc +10 -0
- package/deps/rocksdb/rocksdb/db/blob/blob_file_cache.h +9 -0
- package/deps/rocksdb/rocksdb/db/c.cc +9 -0
- package/deps/rocksdb/rocksdb/db/c_test.c +12 -1
- package/deps/rocksdb/rocksdb/db/column_family.cc +6 -23
- package/deps/rocksdb/rocksdb/db/column_family.h +1 -2
- package/deps/rocksdb/rocksdb/db/compaction/compaction.cc +4 -5
- package/deps/rocksdb/rocksdb/db/compaction/compaction.h +4 -4
- package/deps/rocksdb/rocksdb/db/compaction/compaction_job.cc +14 -6
- package/deps/rocksdb/rocksdb/db/compaction/compaction_job.h +19 -16
- package/deps/rocksdb/rocksdb/db/compaction/compaction_job_test.cc +34 -30
- package/deps/rocksdb/rocksdb/db/compaction/compaction_outputs.h +2 -1
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.cc +2 -1
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.h +1 -1
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_fifo.cc +16 -31
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_fifo.h +2 -1
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_test.cc +7 -50
- package/deps/rocksdb/rocksdb/db/compaction/compaction_service_job.cc +95 -84
- package/deps/rocksdb/rocksdb/db/compaction/compaction_service_test.cc +616 -5
- package/deps/rocksdb/rocksdb/db/compaction/compaction_state.cc +1 -1
- package/deps/rocksdb/rocksdb/db/compaction/subcompaction_state.cc +1 -1
- package/deps/rocksdb/rocksdb/db/compaction/subcompaction_state.h +1 -1
- package/deps/rocksdb/rocksdb/db/compaction/tiered_compaction_test.cc +8 -2
- package/deps/rocksdb/rocksdb/db/db_basic_test.cc +93 -69
- package/deps/rocksdb/rocksdb/db/db_bloom_filter_test.cc +353 -89
- package/deps/rocksdb/rocksdb/db/db_compaction_test.cc +4 -3
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +116 -14
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +67 -8
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_compaction_flush.cc +42 -14
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_debug.cc +50 -0
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_experimental.cc +1 -1
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_files.cc +79 -32
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +36 -59
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.cc +72 -39
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_write.cc +14 -12
- package/deps/rocksdb/rocksdb/db/db_io_failure_test.cc +75 -0
- package/deps/rocksdb/rocksdb/db/db_iter.cc +7 -3
- package/deps/rocksdb/rocksdb/db/db_secondary_test.cc +1 -1
- package/deps/rocksdb/rocksdb/db/db_sst_test.cc +24 -0
- package/deps/rocksdb/rocksdb/db/db_test2.cc +36 -22
- package/deps/rocksdb/rocksdb/db/db_wal_test.cc +23 -0
- package/deps/rocksdb/rocksdb/db/db_with_timestamp_basic_test.cc +2 -0
- package/deps/rocksdb/rocksdb/db/error_handler.cc +28 -3
- package/deps/rocksdb/rocksdb/db/error_handler.h +2 -1
- package/deps/rocksdb/rocksdb/db/event_helpers.cc +1 -0
- package/deps/rocksdb/rocksdb/db/experimental.cc +165 -33
- package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.cc +13 -5
- package/deps/rocksdb/rocksdb/db/external_sst_file_test.cc +37 -28
- package/deps/rocksdb/rocksdb/db/flush_job.cc +11 -6
- package/deps/rocksdb/rocksdb/db/flush_job_test.cc +7 -6
- package/deps/rocksdb/rocksdb/db/forward_iterator.cc +14 -6
- package/deps/rocksdb/rocksdb/db/job_context.h +4 -0
- package/deps/rocksdb/rocksdb/db/memtable.cc +24 -14
- package/deps/rocksdb/rocksdb/db/memtable.h +2 -1
- package/deps/rocksdb/rocksdb/db/memtable_list.cc +61 -33
- package/deps/rocksdb/rocksdb/db/memtable_list.h +8 -0
- package/deps/rocksdb/rocksdb/db/repair.cc +4 -2
- package/deps/rocksdb/rocksdb/db/table_cache.cc +2 -0
- package/deps/rocksdb/rocksdb/db/version_builder.cc +14 -11
- package/deps/rocksdb/rocksdb/db/version_edit_handler.h +20 -4
- package/deps/rocksdb/rocksdb/db/version_set.cc +40 -30
- package/deps/rocksdb/rocksdb/db/version_set.h +13 -3
- package/deps/rocksdb/rocksdb/db/version_set_test.cc +8 -76
- package/deps/rocksdb/rocksdb/db/write_batch.cc +6 -2
- package/deps/rocksdb/rocksdb/db/write_batch_test.cc +1 -1
- 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 +2 -1
- package/deps/rocksdb/rocksdb/db_stress_tool/expected_state.cc +25 -2
- package/deps/rocksdb/rocksdb/env/fs_remap.cc +11 -0
- package/deps/rocksdb/rocksdb/env/fs_remap.h +5 -0
- package/deps/rocksdb/rocksdb/file/sst_file_manager_impl.cc +11 -1
- package/deps/rocksdb/rocksdb/file/sst_file_manager_impl.h +3 -1
- package/deps/rocksdb/rocksdb/include/rocksdb/advanced_cache.h +20 -1
- package/deps/rocksdb/rocksdb/include/rocksdb/advanced_options.h +10 -8
- package/deps/rocksdb/rocksdb/include/rocksdb/c.h +4 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/compaction_job_stats.h +30 -28
- package/deps/rocksdb/rocksdb/include/rocksdb/comparator.h +10 -5
- package/deps/rocksdb/rocksdb/include/rocksdb/convenience.h +3 -1
- package/deps/rocksdb/rocksdb/include/rocksdb/experimental.h +287 -83
- package/deps/rocksdb/rocksdb/include/rocksdb/options.h +68 -36
- package/deps/rocksdb/rocksdb/include/rocksdb/table_properties.h +8 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/utilities/ldb_cmd.h +1 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/version.h +2 -2
- package/deps/rocksdb/rocksdb/memtable/inlineskiplist.h +4 -4
- package/deps/rocksdb/rocksdb/options/customizable_test.cc +31 -0
- package/deps/rocksdb/rocksdb/options/db_options.cc +14 -0
- package/deps/rocksdb/rocksdb/options/db_options.h +2 -0
- package/deps/rocksdb/rocksdb/options/options_helper.cc +15 -4
- package/deps/rocksdb/rocksdb/options/options_helper.h +4 -0
- package/deps/rocksdb/rocksdb/options/options_parser.cc +5 -4
- package/deps/rocksdb/rocksdb/options/options_settable_test.cc +11 -1
- package/deps/rocksdb/rocksdb/options/options_test.cc +38 -45
- package/deps/rocksdb/rocksdb/port/port.h +16 -0
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.cc +8 -1
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.cc +10 -20
- package/deps/rocksdb/rocksdb/table/block_based/filter_policy.cc +15 -9
- package/deps/rocksdb/rocksdb/table/format.cc +32 -4
- package/deps/rocksdb/rocksdb/table/format.h +12 -1
- package/deps/rocksdb/rocksdb/table/iterator.cc +4 -0
- package/deps/rocksdb/rocksdb/table/meta_blocks.cc +214 -161
- package/deps/rocksdb/rocksdb/table/plain/plain_table_reader.cc +4 -2
- package/deps/rocksdb/rocksdb/table/table_properties.cc +4 -0
- package/deps/rocksdb/rocksdb/table/table_reader.h +2 -2
- package/deps/rocksdb/rocksdb/table/table_test.cc +5 -4
- package/deps/rocksdb/rocksdb/test_util/testutil.cc +2 -0
- package/deps/rocksdb/rocksdb/test_util/testutil.h +2 -0
- package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +11 -2
- package/deps/rocksdb/rocksdb/tools/ldb_cmd.cc +213 -22
- package/deps/rocksdb/rocksdb/tools/ldb_cmd_impl.h +3 -0
- package/deps/rocksdb/rocksdb/util/async_file_reader.h +1 -1
- package/deps/rocksdb/rocksdb/util/compaction_job_stats_impl.cc +3 -0
- package/deps/rocksdb/rocksdb/util/coro_utils.h +2 -2
- package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.cc +3 -3
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/@nxtedition+rocksdb.node +0 -0
- package/prebuilds/linux-x64/@nxtedition+rocksdb.node +0 -0
package/binding.cc
CHANGED
|
@@ -964,7 +964,7 @@ NAPI_METHOD(db_open) {
|
|
|
964
964
|
NAPI_STATUS_THROWS(GetProperty(env, options, "walTotalSizeLimit", walSizeLimit));
|
|
965
965
|
dbOptions.max_total_wal_size = maxTotalWalSize / 1e6;
|
|
966
966
|
|
|
967
|
-
bool walCompression =
|
|
967
|
+
bool walCompression = true;
|
|
968
968
|
NAPI_STATUS_THROWS(GetProperty(env, options, "walCompression", walCompression));
|
|
969
969
|
dbOptions.wal_compression =
|
|
970
970
|
walCompression ? rocksdb::CompressionType::kZSTD : rocksdb::CompressionType::kNoCompression;
|
|
@@ -1160,7 +1160,7 @@ NAPI_METHOD(db_get_many_sync) {
|
|
|
1160
1160
|
napi_value row;
|
|
1161
1161
|
if (statuses[n].IsNotFound()) {
|
|
1162
1162
|
NAPI_STATUS_THROWS(napi_get_undefined(env, &row));
|
|
1163
|
-
} else if (statuses[n].IsAborted()) {
|
|
1163
|
+
} else if (statuses[n].IsAborted() || statuses[n].IsTimedOut()) {
|
|
1164
1164
|
NAPI_STATUS_THROWS(napi_get_null(env, &row));
|
|
1165
1165
|
} else {
|
|
1166
1166
|
ROCKS_STATUS_THROWS_NAPI(statuses[n]);
|
|
@@ -630,6 +630,11 @@ VALGRIND_VER := $(join $(VALGRIND_VER),valgrind)
|
|
|
630
630
|
VALGRIND_OPTS = --error-exitcode=$(VALGRIND_ERROR) --leak-check=full
|
|
631
631
|
# Not yet supported: --show-leak-kinds=definite,possible,reachable --errors-for-leak-kinds=definite,possible,reachable
|
|
632
632
|
|
|
633
|
+
# Work around valgrind hanging on systems with limited internet access
|
|
634
|
+
ifneq ($(shell which git 2>/dev/null && git config --get https.proxy),)
|
|
635
|
+
export DEBUGINFOD_URLS=
|
|
636
|
+
endif
|
|
637
|
+
|
|
633
638
|
TEST_OBJECTS = $(patsubst %.cc, $(OBJ_DIR)/%.o, $(TEST_LIB_SOURCES) $(MOCK_LIB_SOURCES)) $(GTEST)
|
|
634
639
|
BENCH_OBJECTS = $(patsubst %.cc, $(OBJ_DIR)/%.o, $(BENCH_LIB_SOURCES))
|
|
635
640
|
CACHE_BENCH_OBJECTS = $(patsubst %.cc, $(OBJ_DIR)/%.o, $(CACHE_BENCH_LIB_SOURCES))
|
|
@@ -1164,16 +1169,16 @@ ubsan_crash_test_with_best_efforts_recovery: clean
|
|
|
1164
1169
|
$(MAKE) clean
|
|
1165
1170
|
|
|
1166
1171
|
full_valgrind_test:
|
|
1167
|
-
ROCKSDB_FULL_VALGRIND_RUN=1 DISABLE_JEMALLOC=1 $(MAKE) valgrind_check
|
|
1172
|
+
ROCKSDB_FULL_VALGRIND_RUN=1 DISABLE_JEMALLOC=1 PORTABLE=1 $(MAKE) valgrind_check
|
|
1168
1173
|
|
|
1169
1174
|
full_valgrind_test_some:
|
|
1170
|
-
ROCKSDB_FULL_VALGRIND_RUN=1 DISABLE_JEMALLOC=1 $(MAKE) valgrind_check_some
|
|
1175
|
+
ROCKSDB_FULL_VALGRIND_RUN=1 DISABLE_JEMALLOC=1 PORTABLE=1 $(MAKE) valgrind_check_some
|
|
1171
1176
|
|
|
1172
1177
|
valgrind_test:
|
|
1173
|
-
ROCKSDB_VALGRIND_RUN=1 DISABLE_JEMALLOC=1 $(MAKE) valgrind_check
|
|
1178
|
+
ROCKSDB_VALGRIND_RUN=1 DISABLE_JEMALLOC=1 PORTABLE=1 $(MAKE) valgrind_check
|
|
1174
1179
|
|
|
1175
1180
|
valgrind_test_some:
|
|
1176
|
-
ROCKSDB_VALGRIND_RUN=1 DISABLE_JEMALLOC=1 $(MAKE) valgrind_check_some
|
|
1181
|
+
ROCKSDB_VALGRIND_RUN=1 DISABLE_JEMALLOC=1 PORTABLE=1 $(MAKE) valgrind_check_some
|
|
1177
1182
|
|
|
1178
1183
|
valgrind_check: $(TESTS)
|
|
1179
1184
|
$(MAKE) DRIVER="$(VALGRIND_VER) $(VALGRIND_OPTS)" gen_parallel_tests
|
|
@@ -2484,7 +2489,7 @@ checkout_folly:
|
|
|
2484
2489
|
fi
|
|
2485
2490
|
@# Pin to a particular version for public CI, so that PR authors don't
|
|
2486
2491
|
@# need to worry about folly breaking our integration. Update periodically
|
|
2487
|
-
cd third-party/folly && git reset --hard
|
|
2492
|
+
cd third-party/folly && git reset --hard 03041f014b6e6ebb6119ffae8b7a37308f52e913
|
|
2488
2493
|
@# NOTE: this hack is required for clang in some cases
|
|
2489
2494
|
perl -pi -e 's/int rv = syscall/int rv = (int)syscall/' third-party/folly/folly/detail/Futex.cpp
|
|
2490
2495
|
@# NOTE: this hack is required for gcc in some cases
|
|
@@ -362,9 +362,9 @@ cpp_library_wrapper(name="rocksdb_lib", srcs=[
|
|
|
362
362
|
"//folly/experimental/coro:coroutine",
|
|
363
363
|
"//folly/experimental/coro:task",
|
|
364
364
|
"//folly/synchronization:distributed_mutex",
|
|
365
|
-
], headers=
|
|
365
|
+
], headers=glob(["**/*.h"]), link_whole=False, extra_test_libs=False)
|
|
366
366
|
|
|
367
|
-
cpp_library_wrapper(name="rocksdb_whole_archive_lib", srcs=[], deps=[":rocksdb_lib"], headers=
|
|
367
|
+
cpp_library_wrapper(name="rocksdb_whole_archive_lib", srcs=[], deps=[":rocksdb_lib"], headers=[], link_whole=True, extra_test_libs=False)
|
|
368
368
|
|
|
369
369
|
cpp_library_wrapper(name="rocksdb_test_lib", srcs=[
|
|
370
370
|
"db/db_test_util.cc",
|
|
@@ -378,7 +378,7 @@ cpp_library_wrapper(name="rocksdb_test_lib", srcs=[
|
|
|
378
378
|
"tools/trace_analyzer_tool.cc",
|
|
379
379
|
"utilities/agg_merge/test_agg_merge.cc",
|
|
380
380
|
"utilities/cassandra/test_utils.cc",
|
|
381
|
-
], deps=[":rocksdb_lib"], headers=
|
|
381
|
+
], deps=[":rocksdb_lib"], headers=[], link_whole=False, extra_test_libs=True)
|
|
382
382
|
|
|
383
383
|
cpp_library_wrapper(name="rocksdb_tools_lib", srcs=[
|
|
384
384
|
"test_util/testutil.cc",
|
|
@@ -386,9 +386,9 @@ cpp_library_wrapper(name="rocksdb_tools_lib", srcs=[
|
|
|
386
386
|
"tools/db_bench_tool.cc",
|
|
387
387
|
"tools/simulated_hybrid_file_system.cc",
|
|
388
388
|
"tools/trace_analyzer_tool.cc",
|
|
389
|
-
], deps=[":rocksdb_lib"], headers=
|
|
389
|
+
], deps=[":rocksdb_lib"], headers=[], link_whole=False, extra_test_libs=False)
|
|
390
390
|
|
|
391
|
-
cpp_library_wrapper(name="rocksdb_cache_bench_tools_lib", srcs=["cache/cache_bench_tool.cc"], deps=[":rocksdb_lib"], headers=
|
|
391
|
+
cpp_library_wrapper(name="rocksdb_cache_bench_tools_lib", srcs=["cache/cache_bench_tool.cc"], deps=[":rocksdb_lib"], headers=[], link_whole=False, extra_test_libs=False)
|
|
392
392
|
|
|
393
393
|
rocks_cpp_library_wrapper(name="rocksdb_stress_lib", srcs=[
|
|
394
394
|
"db_stress_tool/batched_ops_stress.cc",
|
|
@@ -410,13 +410,15 @@ rocks_cpp_library_wrapper(name="rocksdb_stress_lib", srcs=[
|
|
|
410
410
|
"test_util/testutil.cc",
|
|
411
411
|
"tools/block_cache_analyzer/block_cache_trace_analyzer.cc",
|
|
412
412
|
"tools/trace_analyzer_tool.cc",
|
|
413
|
-
], headers=
|
|
413
|
+
], headers=[])
|
|
414
414
|
|
|
415
415
|
|
|
416
416
|
cpp_binary_wrapper(name="ldb", srcs=["tools/ldb.cc"], deps=[":rocksdb_tools_lib"], extra_preprocessor_flags=[], extra_bench_libs=False)
|
|
417
417
|
|
|
418
418
|
cpp_binary_wrapper(name="db_stress", srcs=["db_stress_tool/db_stress.cc"], deps=[":rocksdb_stress_lib"], extra_preprocessor_flags=[], extra_bench_libs=False)
|
|
419
419
|
|
|
420
|
+
cpp_binary_wrapper(name="db_bench", srcs=["tools/db_bench.cc"], deps=[":rocksdb_tools_lib"], extra_preprocessor_flags=[], extra_bench_libs=False)
|
|
421
|
+
|
|
420
422
|
cpp_binary_wrapper(name="cache_bench", srcs=["cache/cache_bench.cc"], deps=[":rocksdb_cache_bench_tools_lib"], extra_preprocessor_flags=[], extra_bench_libs=False)
|
|
421
423
|
|
|
422
424
|
cpp_binary_wrapper(name="ribbon_bench", srcs=["microbench/ribbon_bench.cc"], deps=[], extra_preprocessor_flags=[], extra_bench_libs=True)
|
|
@@ -5024,7 +5026,7 @@ cpp_unittest_wrapper(name="dynamic_bloom_test",
|
|
|
5024
5026
|
extra_compiler_flags=[])
|
|
5025
5027
|
|
|
5026
5028
|
|
|
5027
|
-
cpp_library_wrapper(name="env_basic_test_lib", srcs=["env/env_basic_test.cc"], deps=[":rocksdb_test_lib"], headers=
|
|
5029
|
+
cpp_library_wrapper(name="env_basic_test_lib", srcs=["env/env_basic_test.cc"], deps=[":rocksdb_test_lib"], headers=[], link_whole=False, extra_test_libs=True)
|
|
5028
5030
|
|
|
5029
5031
|
cpp_unittest_wrapper(name="env_basic_test",
|
|
5030
5032
|
srcs=["env/env_basic_test.cc"],
|
|
@@ -133,19 +133,23 @@ Status Cache::CreateFromString(const ConfigOptions& config_options,
|
|
|
133
133
|
std::shared_ptr<Cache>* result) {
|
|
134
134
|
Status status;
|
|
135
135
|
std::shared_ptr<Cache> cache;
|
|
136
|
-
if (value.find(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
136
|
+
if (value.find("://") == std::string::npos) {
|
|
137
|
+
if (value.find('=') == std::string::npos) {
|
|
138
|
+
cache = NewLRUCache(ParseSizeT(value));
|
|
139
|
+
} else {
|
|
140
|
+
LRUCacheOptions cache_opts;
|
|
141
|
+
status = OptionTypeInfo::ParseStruct(config_options, "",
|
|
142
|
+
&lru_cache_options_type_info, "",
|
|
143
|
+
value, &cache_opts);
|
|
144
|
+
if (status.ok()) {
|
|
145
|
+
cache = NewLRUCache(cache_opts);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
143
148
|
if (status.ok()) {
|
|
144
|
-
cache
|
|
149
|
+
result->swap(cache);
|
|
145
150
|
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
result->swap(cache);
|
|
151
|
+
} else {
|
|
152
|
+
status = LoadSharedObject<Cache>(config_options, value, result);
|
|
149
153
|
}
|
|
150
154
|
return status;
|
|
151
155
|
}
|
|
@@ -886,6 +886,32 @@ TEST_P(CacheTest, ApplyToAllEntriesDuringResize) {
|
|
|
886
886
|
ASSERT_EQ(special_count, kSpecialCount);
|
|
887
887
|
}
|
|
888
888
|
|
|
889
|
+
TEST_P(CacheTest, ApplyToHandleTest) {
|
|
890
|
+
std::string callback_state;
|
|
891
|
+
const auto callback = [&](const Slice& key, Cache::ObjectPtr value,
|
|
892
|
+
size_t charge,
|
|
893
|
+
const Cache::CacheItemHelper* helper) {
|
|
894
|
+
callback_state = std::to_string(DecodeKey(key)) + "," +
|
|
895
|
+
std::to_string(DecodeValue(value)) + "," +
|
|
896
|
+
std::to_string(charge);
|
|
897
|
+
assert(helper == &CacheTest::kHelper);
|
|
898
|
+
};
|
|
899
|
+
|
|
900
|
+
std::vector<std::string> inserted;
|
|
901
|
+
|
|
902
|
+
for (int i = 0; i < 10; ++i) {
|
|
903
|
+
Insert(i, i * 2, i + 1);
|
|
904
|
+
inserted.push_back(std::to_string(i) + "," + std::to_string(i * 2) + "," +
|
|
905
|
+
std::to_string(i + 1));
|
|
906
|
+
}
|
|
907
|
+
for (int i = 0; i < 10; ++i) {
|
|
908
|
+
Cache::Handle* handle = cache_->Lookup(EncodeKey(i));
|
|
909
|
+
cache_->ApplyToHandle(cache_.get(), handle, callback);
|
|
910
|
+
EXPECT_EQ(inserted[i], callback_state);
|
|
911
|
+
cache_->Release(handle);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
|
|
889
915
|
TEST_P(CacheTest, DefaultShardBits) {
|
|
890
916
|
// Prevent excessive allocation (to save time & space)
|
|
891
917
|
estimated_value_size_ = 100000;
|
|
@@ -1444,6 +1444,22 @@ const Cache::CacheItemHelper* BaseHyperClockCache<Table>::GetCacheItemHelper(
|
|
|
1444
1444
|
return h->helper;
|
|
1445
1445
|
}
|
|
1446
1446
|
|
|
1447
|
+
template <class Table>
|
|
1448
|
+
void BaseHyperClockCache<Table>::ApplyToHandle(
|
|
1449
|
+
Cache* cache, Handle* handle,
|
|
1450
|
+
const std::function<void(const Slice& key, Cache::ObjectPtr value,
|
|
1451
|
+
size_t charge, const CacheItemHelper* helper)>&
|
|
1452
|
+
callback) {
|
|
1453
|
+
BaseHyperClockCache<Table>* cache_ptr =
|
|
1454
|
+
static_cast<BaseHyperClockCache<Table>*>(cache);
|
|
1455
|
+
auto h = static_cast<const typename Table::HandleImpl*>(handle);
|
|
1456
|
+
UniqueId64x2 unhashed;
|
|
1457
|
+
auto hash_seed = cache_ptr->GetShard(h->GetHash()).GetTable().GetHashSeed();
|
|
1458
|
+
callback(
|
|
1459
|
+
ClockCacheShard<Table>::ReverseHash(h->hashed_key, &unhashed, hash_seed),
|
|
1460
|
+
h->value, h->GetTotalCharge(), h->helper);
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1447
1463
|
namespace {
|
|
1448
1464
|
|
|
1449
1465
|
// For each cache shard, estimate what the table load factor would be if
|
|
@@ -1128,6 +1128,12 @@ class BaseHyperClockCache : public ShardedCache<ClockCacheShard<Table>> {
|
|
|
1128
1128
|
|
|
1129
1129
|
const CacheItemHelper* GetCacheItemHelper(Handle* handle) const override;
|
|
1130
1130
|
|
|
1131
|
+
void ApplyToHandle(
|
|
1132
|
+
Cache* cache, Handle* handle,
|
|
1133
|
+
const std::function<void(const Slice& key, Cache::ObjectPtr obj,
|
|
1134
|
+
size_t charge, const CacheItemHelper* helper)>&
|
|
1135
|
+
callback) override;
|
|
1136
|
+
|
|
1131
1137
|
void ReportProblems(
|
|
1132
1138
|
const std::shared_ptr<Logger>& /*info_log*/) const override;
|
|
1133
1139
|
};
|
|
@@ -79,7 +79,11 @@ std::unique_ptr<SecondaryCacheResultHandle> CompressedSecondaryCache::Lookup(
|
|
|
79
79
|
data_ptr = GetVarint32Ptr(data_ptr, data_ptr + 1,
|
|
80
80
|
static_cast<uint32_t*>(&source_32));
|
|
81
81
|
source = static_cast<CacheTier>(source_32);
|
|
82
|
-
|
|
82
|
+
uint64_t data_size = 0;
|
|
83
|
+
data_ptr = GetVarint64Ptr(data_ptr, ptr->get() + handle_value_charge,
|
|
84
|
+
static_cast<uint64_t*>(&data_size));
|
|
85
|
+
assert(handle_value_charge > data_size);
|
|
86
|
+
handle_value_charge = data_size;
|
|
83
87
|
}
|
|
84
88
|
MemoryAllocator* allocator = cache_options_.memory_allocator.get();
|
|
85
89
|
|
|
@@ -169,13 +173,15 @@ Status CompressedSecondaryCache::InsertInternal(
|
|
|
169
173
|
}
|
|
170
174
|
|
|
171
175
|
auto internal_helper = GetHelper(cache_options_.enable_custom_split_merge);
|
|
172
|
-
char header[
|
|
176
|
+
char header[20];
|
|
173
177
|
char* payload = header;
|
|
174
178
|
payload = EncodeVarint32(payload, static_cast<uint32_t>(type));
|
|
175
179
|
payload = EncodeVarint32(payload, static_cast<uint32_t>(source));
|
|
180
|
+
size_t data_size = (*helper->size_cb)(value);
|
|
181
|
+
char* data_size_ptr = payload;
|
|
182
|
+
payload = EncodeVarint64(payload, data_size);
|
|
176
183
|
|
|
177
184
|
size_t header_size = payload - header;
|
|
178
|
-
size_t data_size = (*helper->size_cb)(value);
|
|
179
185
|
size_t total_size = data_size + header_size;
|
|
180
186
|
CacheAllocationPtr ptr =
|
|
181
187
|
AllocateBlock(total_size, cache_options_.memory_allocator.get());
|
|
@@ -210,6 +216,8 @@ Status CompressedSecondaryCache::InsertInternal(
|
|
|
210
216
|
|
|
211
217
|
val = Slice(compressed_val);
|
|
212
218
|
data_size = compressed_val.size();
|
|
219
|
+
payload = EncodeVarint64(data_size_ptr, data_size);
|
|
220
|
+
header_size = payload - header;
|
|
213
221
|
total_size = header_size + data_size;
|
|
214
222
|
PERF_COUNTER_ADD(compressed_sec_cache_compressed_bytes, data_size);
|
|
215
223
|
|
|
@@ -222,14 +230,21 @@ Status CompressedSecondaryCache::InsertInternal(
|
|
|
222
230
|
|
|
223
231
|
PERF_COUNTER_ADD(compressed_sec_cache_insert_real_count, 1);
|
|
224
232
|
if (cache_options_.enable_custom_split_merge) {
|
|
225
|
-
size_t
|
|
226
|
-
CacheValueChunk* value_chunks_head =
|
|
227
|
-
|
|
228
|
-
return cache_->Insert(key, value_chunks_head, internal_helper,
|
|
233
|
+
size_t split_charge{0};
|
|
234
|
+
CacheValueChunk* value_chunks_head = SplitValueIntoChunks(
|
|
235
|
+
val, cache_options_.compression_type, split_charge);
|
|
236
|
+
return cache_->Insert(key, value_chunks_head, internal_helper,
|
|
237
|
+
split_charge);
|
|
229
238
|
} else {
|
|
239
|
+
#ifdef ROCKSDB_MALLOC_USABLE_SIZE
|
|
240
|
+
size_t charge = malloc_usable_size(ptr.get());
|
|
241
|
+
#else
|
|
242
|
+
size_t charge = total_size;
|
|
243
|
+
#endif
|
|
230
244
|
std::memcpy(ptr.get(), header, header_size);
|
|
231
245
|
CacheAllocationPtr* buf = new CacheAllocationPtr(std::move(ptr));
|
|
232
|
-
|
|
246
|
+
charge += sizeof(CacheAllocationPtr);
|
|
247
|
+
return cache_->Insert(key, buf, internal_helper, charge);
|
|
233
248
|
}
|
|
234
249
|
}
|
|
235
250
|
|
|
@@ -398,6 +413,21 @@ const Cache::CacheItemHelper* CompressedSecondaryCache::GetHelper(
|
|
|
398
413
|
}
|
|
399
414
|
}
|
|
400
415
|
|
|
416
|
+
size_t CompressedSecondaryCache::TEST_GetCharge(const Slice& key) {
|
|
417
|
+
Cache::Handle* lru_handle = cache_->Lookup(key);
|
|
418
|
+
if (lru_handle == nullptr) {
|
|
419
|
+
return 0;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
size_t charge = cache_->GetCharge(lru_handle);
|
|
423
|
+
if (cache_->Value(lru_handle) != nullptr &&
|
|
424
|
+
!cache_options_.enable_custom_split_merge) {
|
|
425
|
+
charge -= 10;
|
|
426
|
+
}
|
|
427
|
+
cache_->Release(lru_handle, /*erase_if_last_ref=*/false);
|
|
428
|
+
return charge;
|
|
429
|
+
}
|
|
430
|
+
|
|
401
431
|
std::shared_ptr<SecondaryCache>
|
|
402
432
|
CompressedSecondaryCacheOptions::MakeSharedSecondaryCache() const {
|
|
403
433
|
return std::make_shared<CompressedSecondaryCache>(*this);
|
|
@@ -139,6 +139,8 @@ class CompressedSecondaryCache : public SecondaryCache {
|
|
|
139
139
|
const Cache::CacheItemHelper* helper,
|
|
140
140
|
CompressionType type, CacheTier source);
|
|
141
141
|
|
|
142
|
+
size_t TEST_GetCharge(const Slice& key);
|
|
143
|
+
|
|
142
144
|
// TODO: clean up to use cleaner interfaces in typed_cache.h
|
|
143
145
|
const Cache::CacheItemHelper* GetHelper(bool enable_custom_split_merge) const;
|
|
144
146
|
std::shared_ptr<Cache> cache_;
|
|
@@ -39,6 +39,8 @@ class CompressedSecondaryCacheTestBase : public testing::Test,
|
|
|
39
39
|
protected:
|
|
40
40
|
void BasicTestHelper(std::shared_ptr<SecondaryCache> sec_cache,
|
|
41
41
|
bool sec_cache_is_compressed) {
|
|
42
|
+
CompressedSecondaryCache* comp_sec_cache =
|
|
43
|
+
static_cast<CompressedSecondaryCache*>(sec_cache.get());
|
|
42
44
|
get_perf_context()->Reset();
|
|
43
45
|
bool kept_in_sec_cache{true};
|
|
44
46
|
// Lookup an non-existent key.
|
|
@@ -66,6 +68,8 @@ class CompressedSecondaryCacheTestBase : public testing::Test,
|
|
|
66
68
|
ASSERT_OK(sec_cache->Insert(key1, &item1, GetHelper(), false));
|
|
67
69
|
ASSERT_EQ(get_perf_context()->compressed_sec_cache_insert_real_count, 1);
|
|
68
70
|
|
|
71
|
+
ASSERT_GT(comp_sec_cache->TEST_GetCharge(key1), 1000);
|
|
72
|
+
|
|
69
73
|
std::unique_ptr<SecondaryCacheResultHandle> handle1_2 =
|
|
70
74
|
sec_cache->Lookup(key1, GetHelper(), this, true, /*advise_erase=*/true,
|
|
71
75
|
/*stats=*/nullptr, kept_in_sec_cache);
|
|
@@ -677,6 +677,17 @@ const Cache::CacheItemHelper* LRUCache::GetCacheItemHelper(
|
|
|
677
677
|
return h->helper;
|
|
678
678
|
}
|
|
679
679
|
|
|
680
|
+
void LRUCache::ApplyToHandle(
|
|
681
|
+
Cache* cache, Handle* handle,
|
|
682
|
+
const std::function<void(const Slice& key, ObjectPtr value, size_t charge,
|
|
683
|
+
const CacheItemHelper* helper)>& callback) {
|
|
684
|
+
auto cache_ptr = static_cast<LRUCache*>(cache);
|
|
685
|
+
auto h = static_cast<const LRUHandle*>(handle);
|
|
686
|
+
callback(h->key(), h->value,
|
|
687
|
+
h->GetCharge(cache_ptr->GetShard(0).metadata_charge_policy_),
|
|
688
|
+
h->helper);
|
|
689
|
+
}
|
|
690
|
+
|
|
680
691
|
size_t LRUCache::TEST_GetLRUSize() {
|
|
681
692
|
return SumOverShards([](LRUCacheShard& cs) { return cs.TEST_GetLRUSize(); });
|
|
682
693
|
}
|
|
@@ -452,6 +452,12 @@ class LRUCache
|
|
|
452
452
|
size_t GetCharge(Handle* handle) const override;
|
|
453
453
|
const CacheItemHelper* GetCacheItemHelper(Handle* handle) const override;
|
|
454
454
|
|
|
455
|
+
void ApplyToHandle(
|
|
456
|
+
Cache* cache, Handle* handle,
|
|
457
|
+
const std::function<void(const Slice& key, ObjectPtr obj, size_t charge,
|
|
458
|
+
const CacheItemHelper* helper)>& callback)
|
|
459
|
+
override;
|
|
460
|
+
|
|
455
461
|
// Retrieves number of elements in LRU, for unit test purpose only.
|
|
456
462
|
size_t TEST_GetLRUSize();
|
|
457
463
|
// Retrieves high pri pool ratio.
|
|
@@ -271,7 +271,8 @@ Status CacheWithSecondaryAdapter::Insert(const Slice& key, ObjectPtr value,
|
|
|
271
271
|
// Warm up the secondary cache with the compressed block. The secondary
|
|
272
272
|
// cache may choose to ignore it based on the admission policy.
|
|
273
273
|
if (value != nullptr && !compressed_value.empty() &&
|
|
274
|
-
adm_policy_ == TieredAdmissionPolicy::kAdmPolicyThreeQueue
|
|
274
|
+
adm_policy_ == TieredAdmissionPolicy::kAdmPolicyThreeQueue &&
|
|
275
|
+
helper->IsSecondaryCacheCompatible()) {
|
|
275
276
|
Status status = secondary_cache_->InsertSaved(key, compressed_value, type);
|
|
276
277
|
assert(status.ok() || status.IsNotSupported());
|
|
277
278
|
}
|
|
@@ -253,6 +253,7 @@ TEST_F(DBTieredSecondaryCacheTest, BasicTest) {
|
|
|
253
253
|
table_options.cache_index_and_filter_blocks = false;
|
|
254
254
|
Options options = GetDefaultOptions();
|
|
255
255
|
options.create_if_missing = true;
|
|
256
|
+
options.compression = kLZ4Compression;
|
|
256
257
|
options.table_factory.reset(NewBlockBasedTableFactory(table_options));
|
|
257
258
|
|
|
258
259
|
// Disable paranoid_file_checks so that flush will not read back the newly
|
|
@@ -364,6 +365,7 @@ TEST_F(DBTieredSecondaryCacheTest, BasicMultiGetTest) {
|
|
|
364
365
|
table_options.cache_index_and_filter_blocks = false;
|
|
365
366
|
Options options = GetDefaultOptions();
|
|
366
367
|
options.create_if_missing = true;
|
|
368
|
+
options.compression = kLZ4Compression;
|
|
367
369
|
options.table_factory.reset(NewBlockBasedTableFactory(table_options));
|
|
368
370
|
|
|
369
371
|
options.paranoid_file_checks = false;
|
|
@@ -506,6 +508,7 @@ TEST_F(DBTieredSecondaryCacheTest, WaitAllTest) {
|
|
|
506
508
|
table_options.cache_index_and_filter_blocks = false;
|
|
507
509
|
Options options = GetDefaultOptions();
|
|
508
510
|
options.create_if_missing = true;
|
|
511
|
+
options.compression = kLZ4Compression;
|
|
509
512
|
options.table_factory.reset(NewBlockBasedTableFactory(table_options));
|
|
510
513
|
|
|
511
514
|
options.paranoid_file_checks = false;
|
|
@@ -606,6 +609,7 @@ TEST_F(DBTieredSecondaryCacheTest, ReadyBeforeWaitAllTest) {
|
|
|
606
609
|
table_options.cache_index_and_filter_blocks = false;
|
|
607
610
|
Options options = GetDefaultOptions();
|
|
608
611
|
options.create_if_missing = true;
|
|
612
|
+
options.compression = kLZ4Compression;
|
|
609
613
|
options.table_factory.reset(NewBlockBasedTableFactory(table_options));
|
|
610
614
|
options.statistics = CreateDBStatistics();
|
|
611
615
|
|
|
@@ -717,6 +721,7 @@ TEST_F(DBTieredSecondaryCacheTest, IterateTest) {
|
|
|
717
721
|
table_options.cache_index_and_filter_blocks = false;
|
|
718
722
|
Options options = GetDefaultOptions();
|
|
719
723
|
options.create_if_missing = true;
|
|
724
|
+
options.compression = kLZ4Compression;
|
|
720
725
|
options.table_factory.reset(NewBlockBasedTableFactory(table_options));
|
|
721
726
|
|
|
722
727
|
options.paranoid_file_checks = false;
|
|
@@ -760,6 +765,54 @@ TEST_F(DBTieredSecondaryCacheTest, IterateTest) {
|
|
|
760
765
|
Destroy(options);
|
|
761
766
|
}
|
|
762
767
|
|
|
768
|
+
TEST_F(DBTieredSecondaryCacheTest, VolatileTierTest) {
|
|
769
|
+
if (!LZ4_Supported()) {
|
|
770
|
+
ROCKSDB_GTEST_SKIP("This test requires LZ4 support.");
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
BlockBasedTableOptions table_options;
|
|
775
|
+
// We want a block cache of size 5KB, and a compressed secondary cache of
|
|
776
|
+
// size 5KB. However, we specify a block cache size of 256KB here in order
|
|
777
|
+
// to take into account the cache reservation in the block cache on
|
|
778
|
+
// behalf of the compressed cache. The unit of cache reservation is 256KB.
|
|
779
|
+
// The effective block cache capacity will be calculated as 256 + 5 = 261KB,
|
|
780
|
+
// and 256KB will be reserved for the compressed cache, leaving 5KB for
|
|
781
|
+
// the primary block cache. We only have to worry about this here because
|
|
782
|
+
// the cache size is so small.
|
|
783
|
+
table_options.block_cache = NewCache(256 * 1024, 5 * 1024, 256 * 1024);
|
|
784
|
+
table_options.block_size = 4 * 1024;
|
|
785
|
+
table_options.cache_index_and_filter_blocks = false;
|
|
786
|
+
Options options = GetDefaultOptions();
|
|
787
|
+
options.create_if_missing = true;
|
|
788
|
+
options.compression = kLZ4Compression;
|
|
789
|
+
options.table_factory.reset(NewBlockBasedTableFactory(table_options));
|
|
790
|
+
|
|
791
|
+
// Disable paranoid_file_checks so that flush will not read back the newly
|
|
792
|
+
// written file
|
|
793
|
+
options.paranoid_file_checks = false;
|
|
794
|
+
options.lowest_used_cache_tier = CacheTier::kVolatileTier;
|
|
795
|
+
DestroyAndReopen(options);
|
|
796
|
+
Random rnd(301);
|
|
797
|
+
const int N = 256;
|
|
798
|
+
for (int i = 0; i < N; i++) {
|
|
799
|
+
std::string p_v;
|
|
800
|
+
test::CompressibleString(&rnd, 0.5, 1007, &p_v);
|
|
801
|
+
ASSERT_OK(Put(Key(i), p_v));
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
ASSERT_OK(Flush());
|
|
805
|
+
|
|
806
|
+
// Since lowest_used_cache_tier is the volatile tier, nothing should be
|
|
807
|
+
// inserted in the secondary cache.
|
|
808
|
+
std::string v = Get(Key(0));
|
|
809
|
+
ASSERT_EQ(1007, v.size());
|
|
810
|
+
ASSERT_EQ(nvm_sec_cache()->num_insert_saved(), 0u);
|
|
811
|
+
ASSERT_EQ(nvm_sec_cache()->num_misses(), 0u);
|
|
812
|
+
|
|
813
|
+
Destroy(options);
|
|
814
|
+
}
|
|
815
|
+
|
|
763
816
|
class DBTieredAdmPolicyTest
|
|
764
817
|
: public DBTieredSecondaryCacheTest,
|
|
765
818
|
public testing::WithParamInterface<TieredAdmissionPolicy> {};
|
|
@@ -784,6 +837,7 @@ TEST_P(DBTieredAdmPolicyTest, CompressedOnlyTest) {
|
|
|
784
837
|
table_options.cache_index_and_filter_blocks = false;
|
|
785
838
|
Options options = GetDefaultOptions();
|
|
786
839
|
options.create_if_missing = true;
|
|
840
|
+
options.compression = kLZ4Compression;
|
|
787
841
|
options.table_factory.reset(NewBlockBasedTableFactory(table_options));
|
|
788
842
|
|
|
789
843
|
size_t comp_cache_usage = compressed_secondary_cache()->TEST_GetUsage();
|
|
@@ -836,6 +890,7 @@ TEST_P(DBTieredAdmPolicyTest, CompressedCacheAdmission) {
|
|
|
836
890
|
table_options.cache_index_and_filter_blocks = false;
|
|
837
891
|
Options options = GetDefaultOptions();
|
|
838
892
|
options.create_if_missing = true;
|
|
893
|
+
options.compression = kLZ4Compression;
|
|
839
894
|
options.table_factory.reset(NewBlockBasedTableFactory(table_options));
|
|
840
895
|
|
|
841
896
|
size_t comp_cache_usage = compressed_secondary_cache()->TEST_GetUsage();
|
|
@@ -937,6 +992,7 @@ TEST_F(DBTieredSecondaryCacheTest, FSBufferTest) {
|
|
|
937
992
|
table_options.cache_index_and_filter_blocks = false;
|
|
938
993
|
Options options = GetDefaultOptions();
|
|
939
994
|
options.create_if_missing = true;
|
|
995
|
+
options.compression = kLZ4Compression;
|
|
940
996
|
options.table_factory.reset(NewBlockBasedTableFactory(table_options));
|
|
941
997
|
options.statistics = CreateDBStatistics();
|
|
942
998
|
options.env = wrap_env.get();
|
|
@@ -45,20 +45,23 @@ void ArenaWrappedDBIter::Init(
|
|
|
45
45
|
const SequenceNumber& sequence, uint64_t max_sequential_skip_in_iteration,
|
|
46
46
|
uint64_t version_number, ReadCallback* read_callback,
|
|
47
47
|
ColumnFamilyHandleImpl* cfh, bool expose_blob_index, bool allow_refresh) {
|
|
48
|
-
auto mem = arena_.AllocateAligned(sizeof(DBIter));
|
|
49
|
-
db_iter_ = new (mem) DBIter(
|
|
50
|
-
env, read_options, ioptions, mutable_cf_options, ioptions.user_comparator,
|
|
51
|
-
/* iter */ nullptr, version, sequence, true,
|
|
52
|
-
max_sequential_skip_in_iteration, read_callback, cfh, expose_blob_index);
|
|
53
|
-
sv_number_ = version_number;
|
|
54
48
|
read_options_ = read_options;
|
|
55
|
-
allow_refresh_ = allow_refresh;
|
|
56
|
-
memtable_range_tombstone_iter_ = nullptr;
|
|
57
|
-
|
|
58
49
|
if (!CheckFSFeatureSupport(env->GetFileSystem().get(),
|
|
59
50
|
FSSupportedOps::kAsyncIO)) {
|
|
60
51
|
read_options_.async_io = false;
|
|
61
52
|
}
|
|
53
|
+
read_options_.total_order_seek |= ioptions.prefix_seek_opt_in_only;
|
|
54
|
+
|
|
55
|
+
auto mem = arena_.AllocateAligned(sizeof(DBIter));
|
|
56
|
+
db_iter_ = new (mem) DBIter(env, read_options_, ioptions, mutable_cf_options,
|
|
57
|
+
ioptions.user_comparator,
|
|
58
|
+
/* iter */ nullptr, version, sequence, true,
|
|
59
|
+
max_sequential_skip_in_iteration, read_callback,
|
|
60
|
+
cfh, expose_blob_index);
|
|
61
|
+
|
|
62
|
+
sv_number_ = version_number;
|
|
63
|
+
allow_refresh_ = allow_refresh;
|
|
64
|
+
memtable_range_tombstone_iter_ = nullptr;
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
Status ArenaWrappedDBIter::Refresh() { return Refresh(nullptr); }
|
|
@@ -42,6 +42,7 @@ Status BlobFileCache::GetBlobFileReader(
|
|
|
42
42
|
assert(blob_file_reader);
|
|
43
43
|
assert(blob_file_reader->IsEmpty());
|
|
44
44
|
|
|
45
|
+
// NOTE: sharing same Cache with table_cache
|
|
45
46
|
const Slice key = GetSliceForKey(&blob_file_number);
|
|
46
47
|
|
|
47
48
|
assert(cache_);
|
|
@@ -98,4 +99,13 @@ Status BlobFileCache::GetBlobFileReader(
|
|
|
98
99
|
return Status::OK();
|
|
99
100
|
}
|
|
100
101
|
|
|
102
|
+
void BlobFileCache::Evict(uint64_t blob_file_number) {
|
|
103
|
+
// NOTE: sharing same Cache with table_cache
|
|
104
|
+
const Slice key = GetSliceForKey(&blob_file_number);
|
|
105
|
+
|
|
106
|
+
assert(cache_);
|
|
107
|
+
|
|
108
|
+
cache_.get()->Erase(key);
|
|
109
|
+
}
|
|
110
|
+
|
|
101
111
|
} // namespace ROCKSDB_NAMESPACE
|
|
@@ -36,6 +36,15 @@ class BlobFileCache {
|
|
|
36
36
|
uint64_t blob_file_number,
|
|
37
37
|
CacheHandleGuard<BlobFileReader>* blob_file_reader);
|
|
38
38
|
|
|
39
|
+
// Called when a blob file is obsolete to ensure it is removed from the cache
|
|
40
|
+
// to avoid effectively leaking the open file and assicated memory
|
|
41
|
+
void Evict(uint64_t blob_file_number);
|
|
42
|
+
|
|
43
|
+
// Used to identify cache entries for blob files (not normally useful)
|
|
44
|
+
static const Cache::CacheItemHelper* GetHelper() {
|
|
45
|
+
return CacheInterface::GetBasicHelper();
|
|
46
|
+
}
|
|
47
|
+
|
|
39
48
|
private:
|
|
40
49
|
using CacheInterface =
|
|
41
50
|
BasicTypedCacheInterface<BlobFileReader, CacheEntryRole::kMisc>;
|
|
@@ -4075,6 +4075,15 @@ void rocksdb_options_set_write_dbid_to_manifest(
|
|
|
4075
4075
|
opt->rep.write_dbid_to_manifest = write_dbid_to_manifest;
|
|
4076
4076
|
}
|
|
4077
4077
|
|
|
4078
|
+
unsigned char rocksdb_options_get_write_identity_file(rocksdb_options_t* opt) {
|
|
4079
|
+
return opt->rep.write_identity_file;
|
|
4080
|
+
}
|
|
4081
|
+
|
|
4082
|
+
void rocksdb_options_set_write_identity_file(
|
|
4083
|
+
rocksdb_options_t* opt, unsigned char write_identity_file) {
|
|
4084
|
+
opt->rep.write_identity_file = write_identity_file;
|
|
4085
|
+
}
|
|
4086
|
+
|
|
4078
4087
|
unsigned char rocksdb_options_get_track_and_verify_wals_in_manifest(
|
|
4079
4088
|
rocksdb_options_t* opt) {
|
|
4080
4089
|
return opt->rep.track_and_verify_wals_in_manifest;
|
|
@@ -772,6 +772,8 @@ int main(int argc, char** argv) {
|
|
|
772
772
|
rocksdb_options_set_write_buffer_size(options, 100000);
|
|
773
773
|
rocksdb_options_set_paranoid_checks(options, 1);
|
|
774
774
|
rocksdb_options_set_max_open_files(options, 10);
|
|
775
|
+
/* Compatibility with how test was written */
|
|
776
|
+
rocksdb_options_set_write_dbid_to_manifest(options, 0);
|
|
775
777
|
|
|
776
778
|
table_options = rocksdb_block_based_options_create();
|
|
777
779
|
rocksdb_block_based_options_set_block_cache(table_options, cache);
|
|
@@ -962,15 +964,24 @@ int main(int argc, char** argv) {
|
|
|
962
964
|
rocksdb_options_t* options_dbid_in_manifest = rocksdb_options_create();
|
|
963
965
|
rocksdb_options_set_create_if_missing(options_dbid_in_manifest, 1);
|
|
964
966
|
|
|
967
|
+
rocksdb_options_set_write_dbid_to_manifest(options_dbid_in_manifest, false);
|
|
965
968
|
unsigned char write_to_manifest =
|
|
966
969
|
rocksdb_options_get_write_dbid_to_manifest(options_dbid_in_manifest);
|
|
967
970
|
CheckCondition(!write_to_manifest);
|
|
968
971
|
rocksdb_options_set_write_dbid_to_manifest(options_dbid_in_manifest, true);
|
|
969
|
-
CheckCondition(!write_to_manifest);
|
|
970
972
|
write_to_manifest =
|
|
971
973
|
rocksdb_options_get_write_dbid_to_manifest(options_dbid_in_manifest);
|
|
972
974
|
CheckCondition(write_to_manifest);
|
|
973
975
|
|
|
976
|
+
rocksdb_options_set_write_identity_file(options_dbid_in_manifest, true);
|
|
977
|
+
unsigned char write_identity_file =
|
|
978
|
+
rocksdb_options_get_write_identity_file(options_dbid_in_manifest);
|
|
979
|
+
CheckCondition(write_identity_file);
|
|
980
|
+
rocksdb_options_set_write_identity_file(options_dbid_in_manifest, false);
|
|
981
|
+
write_identity_file =
|
|
982
|
+
rocksdb_options_get_write_identity_file(options_dbid_in_manifest);
|
|
983
|
+
CheckCondition(!write_identity_file);
|
|
984
|
+
|
|
974
985
|
db = rocksdb_open(options_dbid_in_manifest, dbbackupname, &err);
|
|
975
986
|
CheckNoError(err);
|
|
976
987
|
|