@nxtedition/rocksdb 10.1.4 → 10.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 +16 -12
- package/deps/rocksdb/rocksdb/CMakeLists.txt +16 -5
- package/deps/rocksdb/rocksdb/Makefile +38 -15
- package/deps/rocksdb/rocksdb/TARGETS +10 -0
- package/deps/rocksdb/rocksdb/cache/cache_test.cc +58 -0
- package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.cc +4 -4
- package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.h +4 -2
- package/deps/rocksdb/rocksdb/db/builder.cc +2 -2
- package/deps/rocksdb/rocksdb/db/builder.h +1 -1
- package/deps/rocksdb/rocksdb/db/c.cc +205 -6
- package/deps/rocksdb/rocksdb/db/c_test.c +189 -1
- package/deps/rocksdb/rocksdb/db/column_family.cc +28 -0
- package/deps/rocksdb/rocksdb/db/column_family.h +17 -0
- package/deps/rocksdb/rocksdb/db/column_family_test.cc +234 -60
- package/deps/rocksdb/rocksdb/db/compaction/compaction.cc +8 -1
- package/deps/rocksdb/rocksdb/db/compaction/compaction.h +11 -9
- package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.cc +4 -4
- package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.h +2 -0
- package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator_test.cc +1 -0
- package/deps/rocksdb/rocksdb/db/compaction/compaction_job.cc +22 -25
- package/deps/rocksdb/rocksdb/db/compaction/compaction_job.h +2 -0
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_test.cc +112 -0
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.cc +72 -21
- package/deps/rocksdb/rocksdb/db/compaction/compaction_service_job.cc +2 -0
- package/deps/rocksdb/rocksdb/db/compaction/tiered_compaction_test.cc +77 -0
- package/deps/rocksdb/rocksdb/db/convenience.cc +3 -0
- package/deps/rocksdb/rocksdb/db/db_block_cache_test.cc +269 -112
- package/deps/rocksdb/rocksdb/db/db_bloom_filter_test.cc +107 -43
- package/deps/rocksdb/rocksdb/db/db_filesnapshot.cc +93 -24
- package/deps/rocksdb/rocksdb/db/db_flush_test.cc +5 -5
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +157 -68
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +56 -15
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_compaction_flush.cc +78 -105
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_files.cc +39 -9
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_follower.cc +1 -0
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +21 -14
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_write.cc +107 -63
- package/deps/rocksdb/rocksdb/db/db_properties_test.cc +43 -2
- package/deps/rocksdb/rocksdb/db/db_range_del_test.cc +4 -0
- package/deps/rocksdb/rocksdb/db/db_rate_limiter_test.cc +6 -0
- package/deps/rocksdb/rocksdb/db/db_test.cc +10 -2
- package/deps/rocksdb/rocksdb/db/db_test2.cc +1 -1
- package/deps/rocksdb/rocksdb/db/db_test_util.cc +5 -0
- package/deps/rocksdb/rocksdb/db/db_test_util.h +7 -6
- package/deps/rocksdb/rocksdb/db/db_wal_test.cc +92 -2
- package/deps/rocksdb/rocksdb/db/error_handler.cc +34 -39
- package/deps/rocksdb/rocksdb/db/error_handler.h +3 -4
- package/deps/rocksdb/rocksdb/db/error_handler_fs_test.cc +8 -4
- package/deps/rocksdb/rocksdb/db/event_helpers.cc +6 -3
- package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.cc +71 -15
- package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.h +11 -0
- package/deps/rocksdb/rocksdb/db/external_sst_file_test.cc +383 -4
- package/deps/rocksdb/rocksdb/db/fault_injection_test.cc +88 -72
- package/deps/rocksdb/rocksdb/db/flush_job.cc +30 -3
- package/deps/rocksdb/rocksdb/db/flush_job.h +14 -0
- package/deps/rocksdb/rocksdb/db/internal_stats.cc +60 -1
- package/deps/rocksdb/rocksdb/db/internal_stats.h +20 -1
- package/deps/rocksdb/rocksdb/db/log_writer.cc +24 -0
- package/deps/rocksdb/rocksdb/db/log_writer.h +5 -0
- package/deps/rocksdb/rocksdb/db/memtable.cc +6 -4
- package/deps/rocksdb/rocksdb/db/memtable.h +10 -10
- package/deps/rocksdb/rocksdb/db/memtable_list.cc +4 -4
- package/deps/rocksdb/rocksdb/db/multi_cf_iterator_impl.h +10 -3
- package/deps/rocksdb/rocksdb/db/range_tombstone_fragmenter.h +8 -10
- package/deps/rocksdb/rocksdb/db/repair.cc +4 -3
- package/deps/rocksdb/rocksdb/db/seqno_to_time_mapping.cc +30 -0
- package/deps/rocksdb/rocksdb/db/seqno_to_time_mapping.h +9 -0
- package/deps/rocksdb/rocksdb/db/table_cache.cc +17 -2
- package/deps/rocksdb/rocksdb/db/table_cache.h +9 -1
- package/deps/rocksdb/rocksdb/db/table_properties_collector.h +9 -2
- package/deps/rocksdb/rocksdb/db/table_properties_collector_test.cc +3 -1
- package/deps/rocksdb/rocksdb/db/transaction_log_impl.cc +3 -3
- package/deps/rocksdb/rocksdb/db/transaction_log_impl.h +7 -7
- package/deps/rocksdb/rocksdb/db/version_edit.cc +0 -1
- package/deps/rocksdb/rocksdb/db/version_edit_handler.h +7 -6
- package/deps/rocksdb/rocksdb/db/version_set.cc +54 -31
- package/deps/rocksdb/rocksdb/db/version_set.h +14 -7
- package/deps/rocksdb/rocksdb/db/wal_manager.cc +37 -29
- package/deps/rocksdb/rocksdb/db/wal_manager.h +6 -5
- package/deps/rocksdb/rocksdb/db/wide/wide_columns_helper.cc +6 -0
- package/deps/rocksdb/rocksdb/db/write_batch.cc +54 -23
- package/deps/rocksdb/rocksdb/db/write_callback_test.cc +46 -5
- package/deps/rocksdb/rocksdb/db/write_thread.cc +53 -5
- package/deps/rocksdb/rocksdb/db/write_thread.h +36 -4
- package/deps/rocksdb/rocksdb/db_stress_tool/CMakeLists.txt +1 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/batched_ops_stress.cc +5 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/cf_consistency_stress.cc +57 -17
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.cc +11 -3
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.h +8 -4
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_driver.cc +10 -25
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_env_wrapper.h +25 -88
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_filters.cc +93 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_filters.h +16 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_gflags.cc +43 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_listener.h +109 -21
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_shared_state.h +8 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.cc +666 -205
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.h +55 -10
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_tool.cc +18 -16
- package/deps/rocksdb/rocksdb/db_stress_tool/multi_ops_txns_stress.cc +19 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/multi_ops_txns_stress.h +5 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/no_batched_ops_stress.cc +782 -494
- package/deps/rocksdb/rocksdb/env/composite_env_wrapper.h +21 -0
- package/deps/rocksdb/rocksdb/env/env.cc +6 -0
- package/deps/rocksdb/rocksdb/env/io_posix.cc +0 -1
- package/deps/rocksdb/rocksdb/file/file_util.cc +8 -2
- package/deps/rocksdb/rocksdb/file/prefetch_test.cc +34 -19
- package/deps/rocksdb/rocksdb/file/writable_file_writer.cc +29 -32
- package/deps/rocksdb/rocksdb/file/writable_file_writer.h +41 -15
- package/deps/rocksdb/rocksdb/include/rocksdb/advanced_options.h +4 -2
- package/deps/rocksdb/rocksdb/include/rocksdb/c.h +63 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/db.h +16 -5
- package/deps/rocksdb/rocksdb/include/rocksdb/env.h +5 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/iterator.h +0 -16
- package/deps/rocksdb/rocksdb/include/rocksdb/iterator_base.h +16 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/listener.h +21 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/options.h +76 -3
- package/deps/rocksdb/rocksdb/include/rocksdb/table_properties.h +17 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/transaction_log.h +12 -6
- package/deps/rocksdb/rocksdb/include/rocksdb/universal_compaction.h +31 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/user_write_callback.h +29 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/utilities/checkpoint.h +4 -2
- package/deps/rocksdb/rocksdb/include/rocksdb/utilities/customizable_util.h +0 -1
- package/deps/rocksdb/rocksdb/include/rocksdb/utilities/ldb_cmd.h +17 -8
- package/deps/rocksdb/rocksdb/include/rocksdb/utilities/stackable_db.h +2 -2
- package/deps/rocksdb/rocksdb/include/rocksdb/utilities/table_properties_collectors.h +46 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/utilities/transaction.h +7 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/version.h +2 -2
- package/deps/rocksdb/rocksdb/options/cf_options.cc +13 -2
- package/deps/rocksdb/rocksdb/options/cf_options.h +6 -2
- package/deps/rocksdb/rocksdb/options/db_options.cc +8 -0
- package/deps/rocksdb/rocksdb/options/db_options.h +9 -5
- package/deps/rocksdb/rocksdb/options/options.cc +3 -0
- package/deps/rocksdb/rocksdb/options/options_helper.cc +1 -0
- package/deps/rocksdb/rocksdb/options/options_settable_test.cc +3 -1
- package/deps/rocksdb/rocksdb/port/jemalloc_helper.h +2 -2
- package/deps/rocksdb/rocksdb/port/stack_trace.cc +1 -0
- package/deps/rocksdb/rocksdb/port/win/port_win.cc +3 -2
- package/deps/rocksdb/rocksdb/src.mk +4 -0
- package/deps/rocksdb/rocksdb/table/block_based/binary_search_index_reader.cc +1 -2
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.cc +4 -2
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.cc +15 -0
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.cc +102 -41
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +15 -7
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_impl.h +1 -3
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +5 -6
- package/deps/rocksdb/rocksdb/table/block_based/block_cache.h +31 -0
- package/deps/rocksdb/rocksdb/table/block_based/block_prefetcher.cc +6 -0
- package/deps/rocksdb/rocksdb/table/block_based/cachable_entry.h +10 -5
- package/deps/rocksdb/rocksdb/table/block_based/filter_block.h +11 -15
- package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.cc +17 -11
- package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.h +5 -2
- package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.cc +28 -21
- package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.h +9 -11
- package/deps/rocksdb/rocksdb/table/block_based/full_filter_block_test.cc +16 -16
- package/deps/rocksdb/rocksdb/table/block_based/hash_index_reader.cc +1 -2
- package/deps/rocksdb/rocksdb/table/block_based/index_reader_common.cc +14 -9
- package/deps/rocksdb/rocksdb/table/block_based/index_reader_common.h +4 -1
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.cc +82 -41
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.h +13 -14
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block_test.cc +18 -22
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_reader.cc +51 -13
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_reader.h +2 -0
- package/deps/rocksdb/rocksdb/table/block_based/uncompression_dict_reader.cc +3 -11
- package/deps/rocksdb/rocksdb/table/block_based/uncompression_dict_reader.h +2 -3
- package/deps/rocksdb/rocksdb/table/compaction_merging_iterator.cc +9 -10
- package/deps/rocksdb/rocksdb/table/compaction_merging_iterator.h +3 -2
- package/deps/rocksdb/rocksdb/table/format.cc +1 -2
- package/deps/rocksdb/rocksdb/table/merging_iterator.cc +18 -13
- package/deps/rocksdb/rocksdb/table/merging_iterator.h +5 -3
- package/deps/rocksdb/rocksdb/table/plain/plain_table_builder.cc +2 -2
- package/deps/rocksdb/rocksdb/table/sst_file_reader.cc +1 -1
- package/deps/rocksdb/rocksdb/table/sst_file_writer_collectors.h +3 -1
- package/deps/rocksdb/rocksdb/table/table_builder.h +8 -7
- package/deps/rocksdb/rocksdb/table/table_reader.h +9 -0
- package/deps/rocksdb/rocksdb/test_util/testutil.cc +1 -0
- package/deps/rocksdb/rocksdb/test_util/testutil.h +6 -0
- package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +19 -0
- package/deps/rocksdb/rocksdb/tools/ldb_cmd.cc +434 -110
- package/deps/rocksdb/rocksdb/tools/ldb_cmd_impl.h +3 -1
- package/deps/rocksdb/rocksdb/tools/ldb_tool.cc +3 -0
- package/deps/rocksdb/rocksdb/util/aligned_storage.h +24 -0
- package/deps/rocksdb/rocksdb/util/filter_bench.cc +1 -1
- package/deps/rocksdb/rocksdb/util/random.cc +2 -1
- package/deps/rocksdb/rocksdb/util/stderr_logger.h +1 -1
- package/deps/rocksdb/rocksdb/util/udt_util.cc +33 -0
- package/deps/rocksdb/rocksdb/util/udt_util.h +7 -0
- package/deps/rocksdb/rocksdb/util/udt_util_test.cc +33 -0
- package/deps/rocksdb/rocksdb/util/write_batch_util.h +5 -0
- package/deps/rocksdb/rocksdb/util/xxhash.h +10 -3
- package/deps/rocksdb/rocksdb/utilities/backup/backup_engine_test.cc +13 -13
- package/deps/rocksdb/rocksdb/utilities/checkpoint/checkpoint_test.cc +104 -48
- package/deps/rocksdb/rocksdb/utilities/debug.cc +16 -4
- package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.cc +647 -235
- package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.h +274 -157
- package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.cc +144 -0
- package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.h +45 -0
- package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector_test.cc +139 -0
- package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.cc +12 -0
- package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector_test.cc +3 -0
- package/deps/rocksdb/rocksdb/utilities/transactions/optimistic_transaction_test.cc +105 -6
- package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction.cc +64 -8
- package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction.h +5 -0
- package/deps/rocksdb/rocksdb/utilities/transactions/transaction_base.cc +43 -5
- package/deps/rocksdb/rocksdb/utilities/transactions/transaction_base.h +5 -0
- package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.cc +154 -6
- package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.h +1 -1
- package/deps/rocksdb/rocksdb/utilities/transactions/write_committed_transaction_ts_test.cc +158 -2
- package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn.cc +16 -11
- package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn_db.cc +4 -4
- package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_txn.cc +9 -8
- package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_txn_db.cc +2 -1
- package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc +43 -7
- package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc +2 -0
- package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h +1 -1
- package/index.js +1 -2
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/@nxtedition+rocksdb.node +0 -0
- package/prebuilds/linux-x64/@nxtedition+rocksdb.node +0 -0
- package/util.h +25 -2
- package/.tap/test-results/node_modules/abstract-level/test/chained-batch-test.js.tap +0 -0
- package/.tap/test-results/node_modules/abstract-level/test/get-test.js.tap +0 -0
- package/.tap/test-results/test/abstract-level-test.js.tap +0 -1077
- package/.tap/test-results/test/batch-test.js.tap +0 -12
- package/.tap/test-results/test/chained-batch-gc-test.js.tap +0 -11
- package/.tap/test-results/test/cleanup-hanging-iterators-test.js.tap +0 -135
- package/.tap/test-results/test/clear-gc-test.js.tap +0 -13
- package/.tap/test-results/test/column-test.js.tap +0 -55
- package/.tap/test-results/test/common.js.tap +0 -0
- package/.tap/test-results/test/compression-test.js.tap +0 -30
- package/.tap/test-results/test/db-identity.js.tap +0 -12
- package/.tap/test-results/test/electron.js.tap +0 -0
- package/.tap/test-results/test/env-cleanup-hook-test.js.tap +0 -40
- package/.tap/test-results/test/env-cleanup-hook.js.tap +0 -0
- package/.tap/test-results/test/gc.js.tap +0 -0
- package/.tap/test-results/test/getproperty-test.js.tap +0 -29
- package/.tap/test-results/test/iterator-gc-test.js.tap +0 -15
- package/.tap/test-results/test/iterator-hwm-test.js.tap +0 -131
- package/.tap/test-results/test/iterator-recursion-test.js.tap +0 -12
- package/.tap/test-results/test/iterator-starvation-test.js.tap +0 -73
- package/.tap/test-results/test/iterator-test.js.tap +0 -6
- package/.tap/test-results/test/leak-tester-batch.js.tap +0 -0
- package/.tap/test-results/test/leak-tester-iterator.js.tap +0 -0
- package/.tap/test-results/test/leak-tester.js.tap +0 -0
- package/.tap/test-results/test/lock-test.js.tap +0 -18
- package/.tap/test-results/test/lock.js.tap +0 -0
- package/.tap/test-results/test/make.js.tap +0 -0
- package/.tap/test-results/test/max-rev-merge.js.tap +0 -0
- package/.tap/test-results/test/merge-operator-test.js.tap +0 -12
- package/.tap/test-results/test/mkdir-test.js.tap +0 -15
- package/.tap/test-results/test/segfault-test.js.tap +0 -76
- package/.tap/test-results/test/stack-blower.js.tap +0 -0
- package/deps/rocksdb/rocksdb/README.md +0 -29
- package/deps/rocksdb/rocksdb/microbench/README.md +0 -60
- package/deps/rocksdb/rocksdb/plugin/README.md +0 -43
- package/deps/rocksdb/rocksdb/port/README +0 -10
- package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/README +0 -13
- package/tmp/000099.sst +0 -0
- package/tmp/000102.sst +0 -0
- package/tmp/000103.log +0 -0
- package/tmp/CURRENT +0 -1
- package/tmp/IDENTITY +0 -1
- package/tmp/LOCK +0 -0
- package/tmp/MANIFEST-000104 +0 -0
- package/tmp/OPTIONS-000098 +0 -207
- package/tmp/OPTIONS-000106 +0 -207
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
#include <ios>
|
|
12
12
|
#include <thread>
|
|
13
13
|
|
|
14
|
+
#include "db_stress_tool/db_stress_listener.h"
|
|
15
|
+
#include "rocksdb/io_status.h"
|
|
14
16
|
#include "rocksdb/options.h"
|
|
15
17
|
#include "rocksdb/slice_transform.h"
|
|
16
18
|
#include "util/compression.h"
|
|
@@ -18,6 +20,7 @@
|
|
|
18
20
|
#include "db_stress_tool/db_stress_common.h"
|
|
19
21
|
#include "db_stress_tool/db_stress_compaction_filter.h"
|
|
20
22
|
#include "db_stress_tool/db_stress_driver.h"
|
|
23
|
+
#include "db_stress_tool/db_stress_filters.h"
|
|
21
24
|
#include "db_stress_tool/db_stress_table_properties_collector.h"
|
|
22
25
|
#include "db_stress_tool/db_stress_wide_merge_operator.h"
|
|
23
26
|
#include "options/options_parser.h"
|
|
@@ -90,14 +93,26 @@ StressTest::StressTest()
|
|
|
90
93
|
exit(1);
|
|
91
94
|
}
|
|
92
95
|
}
|
|
96
|
+
|
|
97
|
+
Status s = DbStressSqfcManager().MakeSharedFactory(
|
|
98
|
+
FLAGS_sqfc_name, FLAGS_sqfc_version, &sqfc_factory_);
|
|
99
|
+
if (!s.ok()) {
|
|
100
|
+
fprintf(stderr, "Error initializing SstQueryFilterConfig: %s\n",
|
|
101
|
+
s.ToString().c_str());
|
|
102
|
+
exit(1);
|
|
103
|
+
}
|
|
93
104
|
}
|
|
94
105
|
|
|
95
|
-
StressTest
|
|
106
|
+
void StressTest::CleanUp() {
|
|
96
107
|
for (auto cf : column_families_) {
|
|
97
108
|
delete cf;
|
|
98
109
|
}
|
|
99
110
|
column_families_.clear();
|
|
111
|
+
if (db_) {
|
|
112
|
+
db_->Close();
|
|
113
|
+
}
|
|
100
114
|
delete db_;
|
|
115
|
+
db_ = nullptr;
|
|
101
116
|
|
|
102
117
|
for (auto* cf : cmp_cfhs_) {
|
|
103
118
|
delete cf;
|
|
@@ -275,19 +290,12 @@ bool StressTest::BuildOptionsTable() {
|
|
|
275
290
|
std::to_string(options_.write_buffer_size / 8),
|
|
276
291
|
}},
|
|
277
292
|
{"memtable_huge_page_size", {"0", std::to_string(2 * 1024 * 1024)}},
|
|
278
|
-
{"max_successive_merges", {"0", "2", "4"}},
|
|
279
293
|
{"strict_max_successive_merges", {"false", "true"}},
|
|
280
294
|
{"inplace_update_num_locks", {"100", "200", "300"}},
|
|
281
295
|
// TODO: re-enable once internal task T124324915 is fixed.
|
|
282
296
|
// {"experimental_mempurge_threshold", {"0.0", "1.0"}},
|
|
283
297
|
// TODO(ljin): enable test for this option
|
|
284
298
|
// {"disable_auto_compactions", {"100", "200", "300"}},
|
|
285
|
-
{"level0_file_num_compaction_trigger",
|
|
286
|
-
{
|
|
287
|
-
std::to_string(options_.level0_file_num_compaction_trigger),
|
|
288
|
-
std::to_string(options_.level0_file_num_compaction_trigger + 2),
|
|
289
|
-
std::to_string(options_.level0_file_num_compaction_trigger + 4),
|
|
290
|
-
}},
|
|
291
299
|
{"level0_slowdown_writes_trigger",
|
|
292
300
|
{
|
|
293
301
|
std::to_string(options_.level0_slowdown_writes_trigger),
|
|
@@ -332,6 +340,35 @@ bool StressTest::BuildOptionsTable() {
|
|
|
332
340
|
}},
|
|
333
341
|
{"max_sequential_skip_in_iterations", {"4", "8", "12"}},
|
|
334
342
|
};
|
|
343
|
+
if (FLAGS_compaction_style == kCompactionStyleUniversal &&
|
|
344
|
+
FLAGS_universal_max_read_amp > 0) {
|
|
345
|
+
// level0_file_num_compaction_trigger needs to be at most max_read_amp
|
|
346
|
+
options_tbl.emplace(
|
|
347
|
+
"level0_file_num_compaction_trigger",
|
|
348
|
+
std::vector<std::string>{
|
|
349
|
+
std::to_string(options_.level0_file_num_compaction_trigger),
|
|
350
|
+
std::to_string(
|
|
351
|
+
std::min(options_.level0_file_num_compaction_trigger + 2,
|
|
352
|
+
FLAGS_universal_max_read_amp)),
|
|
353
|
+
std::to_string(
|
|
354
|
+
std::min(options_.level0_file_num_compaction_trigger + 4,
|
|
355
|
+
FLAGS_universal_max_read_amp)),
|
|
356
|
+
});
|
|
357
|
+
} else {
|
|
358
|
+
options_tbl.emplace(
|
|
359
|
+
"level0_file_num_compaction_trigger",
|
|
360
|
+
std::vector<std::string>{
|
|
361
|
+
std::to_string(options_.level0_file_num_compaction_trigger),
|
|
362
|
+
std::to_string(options_.level0_file_num_compaction_trigger + 2),
|
|
363
|
+
std::to_string(options_.level0_file_num_compaction_trigger + 4),
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
if (FLAGS_unordered_write) {
|
|
367
|
+
options_tbl.emplace("max_successive_merges", std::vector<std::string>{"0"});
|
|
368
|
+
} else {
|
|
369
|
+
options_tbl.emplace("max_successive_merges",
|
|
370
|
+
std::vector<std::string>{"0", "2", "4"});
|
|
371
|
+
}
|
|
335
372
|
|
|
336
373
|
if (FLAGS_allow_setting_blob_options_dynamically) {
|
|
337
374
|
options_tbl.emplace("enable_blob_files",
|
|
@@ -423,14 +460,9 @@ void StressTest::FinishInitDb(SharedState* shared) {
|
|
|
423
460
|
}
|
|
424
461
|
|
|
425
462
|
void StressTest::TrackExpectedState(SharedState* shared) {
|
|
426
|
-
//
|
|
427
|
-
//
|
|
428
|
-
|
|
429
|
-
// Therefore recovery from such potential WAL data loss is a prefix recovery
|
|
430
|
-
// that requires tracing
|
|
431
|
-
if ((FLAGS_sync_fault_injection || FLAGS_disable_wal ||
|
|
432
|
-
FLAGS_manual_wal_flush_one_in > 0) &&
|
|
433
|
-
IsStateTracked()) {
|
|
463
|
+
// When data loss is simulated, recovery from potential data loss is a prefix
|
|
464
|
+
// recovery that requires tracing
|
|
465
|
+
if (MightHaveUnsyncedDataLoss() && IsStateTracked()) {
|
|
434
466
|
Status s = shared->SaveAtAndAfter(db_);
|
|
435
467
|
if (!s.ok()) {
|
|
436
468
|
fprintf(stderr, "Error enabling history tracing: %s\n",
|
|
@@ -510,14 +542,12 @@ void StressTest::ProcessStatus(SharedState* shared, std::string opname,
|
|
|
510
542
|
if (s.ok()) {
|
|
511
543
|
return;
|
|
512
544
|
}
|
|
513
|
-
if (!
|
|
514
|
-
!ignore_injected_error) {
|
|
545
|
+
if (!ignore_injected_error || !IsErrorInjectedAndRetryable(s)) {
|
|
515
546
|
std::ostringstream oss;
|
|
516
547
|
oss << opname << " failed: " << s.ToString();
|
|
517
548
|
VerificationAbort(shared, oss.str());
|
|
518
549
|
assert(false);
|
|
519
550
|
}
|
|
520
|
-
fprintf(stdout, "%s failed: %s\n", opname.c_str(), s.ToString().c_str());
|
|
521
551
|
}
|
|
522
552
|
|
|
523
553
|
void StressTest::VerificationAbort(SharedState* shared, std::string msg) const {
|
|
@@ -617,8 +647,21 @@ void StressTest::PreloadDbAndReopenAsReadOnly(int64_t number_of_keys,
|
|
|
617
647
|
|
|
618
648
|
if (FLAGS_use_put_entity_one_in > 0 &&
|
|
619
649
|
(value_base % FLAGS_use_put_entity_one_in) == 0) {
|
|
620
|
-
|
|
621
|
-
|
|
650
|
+
if (!FLAGS_use_txn) {
|
|
651
|
+
if (FLAGS_use_attribute_group) {
|
|
652
|
+
s = db_->PutEntity(write_opts, key,
|
|
653
|
+
GenerateAttributeGroups({cfh}, value_base, v));
|
|
654
|
+
} else {
|
|
655
|
+
s = db_->PutEntity(write_opts, cfh, key,
|
|
656
|
+
GenerateWideColumns(value_base, v));
|
|
657
|
+
}
|
|
658
|
+
} else {
|
|
659
|
+
s = ExecuteTransaction(
|
|
660
|
+
write_opts, /*thread=*/nullptr, [&](Transaction& txn) {
|
|
661
|
+
return txn.PutEntity(cfh, key,
|
|
662
|
+
GenerateWideColumns(value_base, v));
|
|
663
|
+
});
|
|
664
|
+
}
|
|
622
665
|
} else if (FLAGS_use_merge) {
|
|
623
666
|
if (!FLAGS_use_txn) {
|
|
624
667
|
if (FLAGS_user_timestamp_size > 0) {
|
|
@@ -888,13 +931,6 @@ void StressTest::OperateDb(ThreadState* thread) {
|
|
|
888
931
|
|
|
889
932
|
const uint64_t ops_per_open = FLAGS_ops_per_thread / (FLAGS_reopen + 1);
|
|
890
933
|
|
|
891
|
-
#ifndef NDEBUG
|
|
892
|
-
if (FLAGS_read_fault_one_in) {
|
|
893
|
-
fault_fs_guard->SetThreadLocalReadErrorContext(
|
|
894
|
-
thread->shared->GetSeed(), FLAGS_read_fault_one_in,
|
|
895
|
-
FLAGS_inject_error_severity == 1 /* retryable */);
|
|
896
|
-
}
|
|
897
|
-
#endif // NDEBUG
|
|
898
934
|
thread->stats.Start();
|
|
899
935
|
for (int open_cnt = 0; open_cnt <= FLAGS_reopen; ++open_cnt) {
|
|
900
936
|
if (thread->shared->HasVerificationFailedYet() ||
|
|
@@ -920,6 +956,42 @@ void StressTest::OperateDb(ThreadState* thread) {
|
|
|
920
956
|
// thread->stats.Start();
|
|
921
957
|
}
|
|
922
958
|
|
|
959
|
+
#ifndef NDEBUG
|
|
960
|
+
if (fault_fs_guard) {
|
|
961
|
+
fault_fs_guard->SetThreadLocalErrorContext(
|
|
962
|
+
FaultInjectionIOType::kRead, thread->shared->GetSeed(),
|
|
963
|
+
FLAGS_read_fault_one_in,
|
|
964
|
+
FLAGS_inject_error_severity == 1 /* retryable */,
|
|
965
|
+
FLAGS_inject_error_severity == 2 /* has_data_loss*/);
|
|
966
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
967
|
+
FaultInjectionIOType::kRead);
|
|
968
|
+
|
|
969
|
+
fault_fs_guard->SetThreadLocalErrorContext(
|
|
970
|
+
FaultInjectionIOType::kWrite, thread->shared->GetSeed(),
|
|
971
|
+
FLAGS_write_fault_one_in,
|
|
972
|
+
FLAGS_inject_error_severity == 1 /* retryable */,
|
|
973
|
+
FLAGS_inject_error_severity == 2 /* has_data_loss*/);
|
|
974
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
975
|
+
FaultInjectionIOType::kWrite);
|
|
976
|
+
|
|
977
|
+
fault_fs_guard->SetThreadLocalErrorContext(
|
|
978
|
+
FaultInjectionIOType::kMetadataRead, thread->shared->GetSeed(),
|
|
979
|
+
FLAGS_metadata_read_fault_one_in,
|
|
980
|
+
FLAGS_inject_error_severity == 1 /* retryable */,
|
|
981
|
+
FLAGS_inject_error_severity == 2 /* has_data_loss*/);
|
|
982
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
983
|
+
FaultInjectionIOType::kMetadataRead);
|
|
984
|
+
|
|
985
|
+
fault_fs_guard->SetThreadLocalErrorContext(
|
|
986
|
+
FaultInjectionIOType::kMetadataWrite, thread->shared->GetSeed(),
|
|
987
|
+
FLAGS_metadata_write_fault_one_in,
|
|
988
|
+
FLAGS_inject_error_severity == 1 /* retryable */,
|
|
989
|
+
FLAGS_inject_error_severity == 2 /* has_data_loss*/);
|
|
990
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
991
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
992
|
+
}
|
|
993
|
+
#endif // NDEBUG
|
|
994
|
+
|
|
923
995
|
for (uint64_t i = 0; i < ops_per_open; i++) {
|
|
924
996
|
if (thread->shared->HasVerificationFailedYet()) {
|
|
925
997
|
break;
|
|
@@ -927,7 +999,8 @@ void StressTest::OperateDb(ThreadState* thread) {
|
|
|
927
999
|
|
|
928
1000
|
// Change Options
|
|
929
1001
|
if (thread->rand.OneInOpt(FLAGS_set_options_one_in)) {
|
|
930
|
-
SetOptions(thread);
|
|
1002
|
+
Status s = SetOptions(thread);
|
|
1003
|
+
ProcessStatus(shared, "SetOptions", s);
|
|
931
1004
|
}
|
|
932
1005
|
|
|
933
1006
|
if (thread->rand.OneInOpt(FLAGS_set_in_place_one_in)) {
|
|
@@ -936,7 +1009,29 @@ void StressTest::OperateDb(ThreadState* thread) {
|
|
|
936
1009
|
|
|
937
1010
|
if (thread->tid == 0 && FLAGS_verify_db_one_in > 0 &&
|
|
938
1011
|
thread->rand.OneIn(FLAGS_verify_db_one_in)) {
|
|
1012
|
+
// Temporarily disable error injection for verification
|
|
1013
|
+
if (fault_fs_guard) {
|
|
1014
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1015
|
+
FaultInjectionIOType::kRead);
|
|
1016
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1017
|
+
FaultInjectionIOType::kWrite);
|
|
1018
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1019
|
+
FaultInjectionIOType::kMetadataRead);
|
|
1020
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1021
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
1022
|
+
}
|
|
939
1023
|
ContinuouslyVerifyDb(thread);
|
|
1024
|
+
// Enable back error injection disabled for verification
|
|
1025
|
+
if (fault_fs_guard) {
|
|
1026
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
1027
|
+
FaultInjectionIOType::kRead);
|
|
1028
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
1029
|
+
FaultInjectionIOType::kWrite);
|
|
1030
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
1031
|
+
FaultInjectionIOType::kMetadataRead);
|
|
1032
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
1033
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
1034
|
+
}
|
|
940
1035
|
if (thread->shared->ShouldStopTest()) {
|
|
941
1036
|
break;
|
|
942
1037
|
}
|
|
@@ -947,7 +1042,8 @@ void StressTest::OperateDb(ThreadState* thread) {
|
|
|
947
1042
|
if (thread->rand.OneInOpt(FLAGS_manual_wal_flush_one_in)) {
|
|
948
1043
|
bool sync = thread->rand.OneIn(2) ? true : false;
|
|
949
1044
|
Status s = db_->FlushWAL(sync);
|
|
950
|
-
if (!s.ok() && !(
|
|
1045
|
+
if (!s.ok() && !IsErrorInjectedAndRetryable(s) &&
|
|
1046
|
+
!(sync && s.IsNotSupported())) {
|
|
951
1047
|
fprintf(stderr, "FlushWAL(sync=%s) failed: %s\n",
|
|
952
1048
|
(sync ? "true" : "false"), s.ToString().c_str());
|
|
953
1049
|
}
|
|
@@ -955,13 +1051,25 @@ void StressTest::OperateDb(ThreadState* thread) {
|
|
|
955
1051
|
|
|
956
1052
|
if (thread->rand.OneInOpt(FLAGS_lock_wal_one_in)) {
|
|
957
1053
|
Status s = db_->LockWAL();
|
|
958
|
-
if (!s.ok()) {
|
|
1054
|
+
if (!s.ok() && !IsErrorInjectedAndRetryable(s)) {
|
|
959
1055
|
fprintf(stderr, "LockWAL() failed: %s\n", s.ToString().c_str());
|
|
960
|
-
} else {
|
|
1056
|
+
} else if (s.ok()) {
|
|
1057
|
+
// Temporarily disable error injection for verification
|
|
1058
|
+
if (fault_fs_guard) {
|
|
1059
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1060
|
+
FaultInjectionIOType::kRead);
|
|
1061
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1062
|
+
FaultInjectionIOType::kMetadataRead);
|
|
1063
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1064
|
+
FaultInjectionIOType::kWrite);
|
|
1065
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1066
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
1067
|
+
}
|
|
1068
|
+
|
|
961
1069
|
// Verify no writes during LockWAL
|
|
962
1070
|
auto old_seqno = db_->GetLatestSequenceNumber();
|
|
963
1071
|
// And also that WAL is not changed during LockWAL()
|
|
964
|
-
std::unique_ptr<
|
|
1072
|
+
std::unique_ptr<WalFile> old_wal;
|
|
965
1073
|
s = db_->GetCurrentWalFile(&old_wal);
|
|
966
1074
|
if (!s.ok()) {
|
|
967
1075
|
fprintf(stderr, "GetCurrentWalFile() failed: %s\n",
|
|
@@ -972,7 +1080,7 @@ void StressTest::OperateDb(ThreadState* thread) {
|
|
|
972
1080
|
std::this_thread::yield();
|
|
973
1081
|
} while (thread->rand.OneIn(2));
|
|
974
1082
|
// Current WAL and size should not have changed
|
|
975
|
-
std::unique_ptr<
|
|
1083
|
+
std::unique_ptr<WalFile> new_wal;
|
|
976
1084
|
s = db_->GetCurrentWalFile(&new_wal);
|
|
977
1085
|
if (!s.ok()) {
|
|
978
1086
|
fprintf(stderr, "GetCurrentWalFile() failed: %s\n",
|
|
@@ -984,12 +1092,7 @@ void StressTest::OperateDb(ThreadState* thread) {
|
|
|
984
1092
|
" to %" PRIu64 "\n",
|
|
985
1093
|
old_wal->LogNumber(), new_wal->LogNumber());
|
|
986
1094
|
}
|
|
987
|
-
|
|
988
|
-
// reflect what has been flushed. Either that needs to be fixed
|
|
989
|
-
// or GetSortedWals/GetLiveWalFile need to stop relying on
|
|
990
|
-
// asking the FS for sizes.
|
|
991
|
-
if (!fault_fs_guard &&
|
|
992
|
-
old_wal->SizeFileBytes() != new_wal->SizeFileBytes()) {
|
|
1095
|
+
if (old_wal->SizeFileBytes() != new_wal->SizeFileBytes()) {
|
|
993
1096
|
fprintf(stderr,
|
|
994
1097
|
"Failed: WAL %" PRIu64
|
|
995
1098
|
" size changed during LockWAL(): %" PRIu64
|
|
@@ -1012,12 +1115,24 @@ void StressTest::OperateDb(ThreadState* thread) {
|
|
|
1012
1115
|
if (!s.ok()) {
|
|
1013
1116
|
fprintf(stderr, "UnlockWAL() failed: %s\n", s.ToString().c_str());
|
|
1014
1117
|
}
|
|
1118
|
+
|
|
1119
|
+
// Enable back error injection disabled for verification
|
|
1120
|
+
if (fault_fs_guard) {
|
|
1121
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
1122
|
+
FaultInjectionIOType::kRead);
|
|
1123
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
1124
|
+
FaultInjectionIOType::kMetadataRead);
|
|
1125
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
1126
|
+
FaultInjectionIOType::kWrite);
|
|
1127
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
1128
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
1129
|
+
}
|
|
1015
1130
|
}
|
|
1016
1131
|
}
|
|
1017
1132
|
|
|
1018
1133
|
if (thread->rand.OneInOpt(FLAGS_sync_wal_one_in)) {
|
|
1019
1134
|
Status s = db_->SyncWAL();
|
|
1020
|
-
if (!s.ok() && !s.IsNotSupported()) {
|
|
1135
|
+
if (!s.ok() && !s.IsNotSupported() && !IsErrorInjectedAndRetryable(s)) {
|
|
1021
1136
|
fprintf(stderr, "SyncWAL() failed: %s\n", s.ToString().c_str());
|
|
1022
1137
|
}
|
|
1023
1138
|
}
|
|
@@ -1049,39 +1164,35 @@ void StressTest::OperateDb(ThreadState* thread) {
|
|
|
1049
1164
|
|
|
1050
1165
|
if (thread->rand.OneInOpt(FLAGS_flush_one_in)) {
|
|
1051
1166
|
Status status = TestFlush(rand_column_families);
|
|
1052
|
-
|
|
1053
|
-
fprintf(stdout, "Unable to perform Flush(): %s\n",
|
|
1054
|
-
status.ToString().c_str());
|
|
1055
|
-
}
|
|
1167
|
+
ProcessStatus(shared, "Flush", status);
|
|
1056
1168
|
}
|
|
1057
1169
|
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
Status
|
|
1062
|
-
ProcessStatus(shared, "
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1170
|
+
if (thread->rand.OneInOpt(FLAGS_get_live_files_apis_one_in)) {
|
|
1171
|
+
Status s_1 = TestGetLiveFiles();
|
|
1172
|
+
ProcessStatus(shared, "GetLiveFiles", s_1);
|
|
1173
|
+
Status s_2 = TestGetLiveFilesMetaData();
|
|
1174
|
+
ProcessStatus(shared, "GetLiveFilesMetaData", s_2);
|
|
1175
|
+
// TODO: enable again after making `GetLiveFilesStorageInfo()`
|
|
1176
|
+
// compatible with `Options::recycle_log_file_num`
|
|
1177
|
+
if (FLAGS_recycle_log_file_num == 0) {
|
|
1178
|
+
Status s_3 = TestGetLiveFilesStorageInfo();
|
|
1179
|
+
ProcessStatus(shared, "GetLiveFilesStorageInfo", s_3);
|
|
1180
|
+
}
|
|
1067
1181
|
}
|
|
1068
1182
|
|
|
1069
|
-
// Verify GetAllColumnFamilyMetaData with a 1 in N chance.
|
|
1070
1183
|
if (thread->rand.OneInOpt(FLAGS_get_all_column_family_metadata_one_in)) {
|
|
1071
|
-
Status status =
|
|
1072
|
-
ProcessStatus(shared, "
|
|
1184
|
+
Status status = TestGetAllColumnFamilyMetaData();
|
|
1185
|
+
ProcessStatus(shared, "GetAllColumnFamilyMetaData", status);
|
|
1073
1186
|
}
|
|
1074
1187
|
|
|
1075
|
-
// Verify GetSortedWalFiles with a 1 in N chance.
|
|
1076
1188
|
if (thread->rand.OneInOpt(FLAGS_get_sorted_wal_files_one_in)) {
|
|
1077
|
-
Status status =
|
|
1078
|
-
ProcessStatus(shared, "
|
|
1189
|
+
Status status = TestGetSortedWalFiles();
|
|
1190
|
+
ProcessStatus(shared, "GetSortedWalFiles", status);
|
|
1079
1191
|
}
|
|
1080
1192
|
|
|
1081
|
-
// Verify GetCurrentWalFile with a 1 in N chance.
|
|
1082
1193
|
if (thread->rand.OneInOpt(FLAGS_get_current_wal_file_one_in)) {
|
|
1083
|
-
Status status =
|
|
1084
|
-
ProcessStatus(shared, "
|
|
1194
|
+
Status status = TestGetCurrentWalFile();
|
|
1195
|
+
ProcessStatus(shared, "GetCurrentWalFile", status);
|
|
1085
1196
|
}
|
|
1086
1197
|
|
|
1087
1198
|
if (thread->rand.OneInOpt(FLAGS_reset_stats_one_in)) {
|
|
@@ -1123,7 +1234,32 @@ void StressTest::OperateDb(ThreadState* thread) {
|
|
|
1123
1234
|
}
|
|
1124
1235
|
|
|
1125
1236
|
if (thread->rand.OneInOpt(FLAGS_get_property_one_in)) {
|
|
1237
|
+
// TestGetProperty doesn't return status for us to tell whether it has
|
|
1238
|
+
// failed due to injected error. So we disable fault injection to avoid
|
|
1239
|
+
// false positive
|
|
1240
|
+
if (fault_fs_guard) {
|
|
1241
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1242
|
+
FaultInjectionIOType::kMetadataRead);
|
|
1243
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1244
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
1245
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1246
|
+
FaultInjectionIOType::kRead);
|
|
1247
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1248
|
+
FaultInjectionIOType::kWrite);
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1126
1251
|
TestGetProperty(thread);
|
|
1252
|
+
|
|
1253
|
+
if (fault_fs_guard) {
|
|
1254
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
1255
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
1256
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
1257
|
+
FaultInjectionIOType::kMetadataRead);
|
|
1258
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
1259
|
+
FaultInjectionIOType::kRead);
|
|
1260
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
1261
|
+
FaultInjectionIOType::kWrite);
|
|
1262
|
+
}
|
|
1127
1263
|
}
|
|
1128
1264
|
|
|
1129
1265
|
if (thread->rand.OneInOpt(FLAGS_get_properties_of_all_tables_one_in)) {
|
|
@@ -1150,7 +1286,29 @@ void StressTest::OperateDb(ThreadState* thread) {
|
|
|
1150
1286
|
}
|
|
1151
1287
|
|
|
1152
1288
|
if (total_size <= FLAGS_backup_max_size) {
|
|
1289
|
+
// TODO(hx235): enable error injection with
|
|
1290
|
+
// backup/restore after fixing the various issues it surfaces
|
|
1291
|
+
if (fault_fs_guard) {
|
|
1292
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1293
|
+
FaultInjectionIOType::kMetadataRead);
|
|
1294
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1295
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
1296
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1297
|
+
FaultInjectionIOType::kRead);
|
|
1298
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1299
|
+
FaultInjectionIOType::kWrite);
|
|
1300
|
+
}
|
|
1153
1301
|
Status s = TestBackupRestore(thread, rand_column_families, rand_keys);
|
|
1302
|
+
if (fault_fs_guard) {
|
|
1303
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
1304
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
1305
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
1306
|
+
FaultInjectionIOType::kMetadataRead);
|
|
1307
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
1308
|
+
FaultInjectionIOType::kRead);
|
|
1309
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
1310
|
+
FaultInjectionIOType::kWrite);
|
|
1311
|
+
}
|
|
1154
1312
|
ProcessStatus(shared, "Backup/restore", s);
|
|
1155
1313
|
}
|
|
1156
1314
|
}
|
|
@@ -1278,7 +1436,15 @@ void StressTest::OperateDb(ThreadState* thread) {
|
|
|
1278
1436
|
ThreadStatusUtil::SetEnableTracking(FLAGS_enable_thread_tracking);
|
|
1279
1437
|
ThreadStatusUtil::SetThreadOperation(
|
|
1280
1438
|
ThreadStatus::OperationType::OP_DBITERATOR);
|
|
1281
|
-
|
|
1439
|
+
Status s;
|
|
1440
|
+
if (FLAGS_use_multi_cf_iterator && FLAGS_use_attribute_group) {
|
|
1441
|
+
s = TestIterateAttributeGroups(thread, read_opts,
|
|
1442
|
+
rand_column_families, rand_keys);
|
|
1443
|
+
ProcessStatus(shared, "IterateAttributeGroups", s);
|
|
1444
|
+
} else {
|
|
1445
|
+
s = TestIterate(thread, read_opts, rand_column_families, rand_keys);
|
|
1446
|
+
ProcessStatus(shared, "Iterate", s);
|
|
1447
|
+
}
|
|
1282
1448
|
ThreadStatusUtil::ResetThreadStatus();
|
|
1283
1449
|
}
|
|
1284
1450
|
} else {
|
|
@@ -1287,6 +1453,19 @@ void StressTest::OperateDb(ThreadState* thread) {
|
|
|
1287
1453
|
}
|
|
1288
1454
|
thread->stats.FinishedSingleOp();
|
|
1289
1455
|
}
|
|
1456
|
+
|
|
1457
|
+
#ifndef NDEBUG
|
|
1458
|
+
if (fault_fs_guard) {
|
|
1459
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1460
|
+
FaultInjectionIOType::kRead);
|
|
1461
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1462
|
+
FaultInjectionIOType::kWrite);
|
|
1463
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1464
|
+
FaultInjectionIOType::kMetadataRead);
|
|
1465
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
1466
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
1467
|
+
}
|
|
1468
|
+
#endif // NDEBUG
|
|
1290
1469
|
}
|
|
1291
1470
|
while (!thread->snapshot_queue.empty()) {
|
|
1292
1471
|
db_->ReleaseSnapshot(thread->snapshot_queue.front().second.snapshot);
|
|
@@ -1362,6 +1541,75 @@ Status StressTest::TestIterate(ThreadState* thread,
|
|
|
1362
1541
|
const ReadOptions& read_opts,
|
|
1363
1542
|
const std::vector<int>& rand_column_families,
|
|
1364
1543
|
const std::vector<int64_t>& rand_keys) {
|
|
1544
|
+
auto new_iter_func = [&rand_column_families, this](const ReadOptions& ro) {
|
|
1545
|
+
if (FLAGS_use_multi_cf_iterator) {
|
|
1546
|
+
std::vector<ColumnFamilyHandle*> cfhs;
|
|
1547
|
+
cfhs.reserve(rand_column_families.size());
|
|
1548
|
+
for (auto cf_index : rand_column_families) {
|
|
1549
|
+
cfhs.emplace_back(column_families_[cf_index]);
|
|
1550
|
+
}
|
|
1551
|
+
assert(!cfhs.empty());
|
|
1552
|
+
return db_->NewCoalescingIterator(ro, cfhs);
|
|
1553
|
+
} else {
|
|
1554
|
+
ColumnFamilyHandle* const cfh = column_families_[rand_column_families[0]];
|
|
1555
|
+
assert(cfh);
|
|
1556
|
+
return std::unique_ptr<Iterator>(db_->NewIterator(ro, cfh));
|
|
1557
|
+
}
|
|
1558
|
+
};
|
|
1559
|
+
|
|
1560
|
+
auto verify_func = [](Iterator* iter) {
|
|
1561
|
+
if (!VerifyWideColumns(iter->value(), iter->columns())) {
|
|
1562
|
+
fprintf(stderr,
|
|
1563
|
+
"Value and columns inconsistent for iterator: value: %s, "
|
|
1564
|
+
"columns: %s\n",
|
|
1565
|
+
iter->value().ToString(/* hex */ true).c_str(),
|
|
1566
|
+
WideColumnsToHex(iter->columns()).c_str());
|
|
1567
|
+
return false;
|
|
1568
|
+
}
|
|
1569
|
+
return true;
|
|
1570
|
+
};
|
|
1571
|
+
|
|
1572
|
+
return TestIterateImpl<Iterator>(thread, read_opts, rand_column_families,
|
|
1573
|
+
rand_keys, new_iter_func, verify_func);
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
Status StressTest::TestIterateAttributeGroups(
|
|
1577
|
+
ThreadState* thread, const ReadOptions& read_opts,
|
|
1578
|
+
const std::vector<int>& rand_column_families,
|
|
1579
|
+
const std::vector<int64_t>& rand_keys) {
|
|
1580
|
+
auto new_iter_func = [&rand_column_families, this](const ReadOptions& ro) {
|
|
1581
|
+
assert(FLAGS_use_multi_cf_iterator);
|
|
1582
|
+
std::vector<ColumnFamilyHandle*> cfhs;
|
|
1583
|
+
cfhs.reserve(rand_column_families.size());
|
|
1584
|
+
for (auto cf_index : rand_column_families) {
|
|
1585
|
+
cfhs.emplace_back(column_families_[cf_index]);
|
|
1586
|
+
}
|
|
1587
|
+
assert(!cfhs.empty());
|
|
1588
|
+
return db_->NewAttributeGroupIterator(ro, cfhs);
|
|
1589
|
+
};
|
|
1590
|
+
auto verify_func = [](AttributeGroupIterator* iter) {
|
|
1591
|
+
if (!VerifyIteratorAttributeGroups(iter->attribute_groups())) {
|
|
1592
|
+
// TODO - print out attribute group values
|
|
1593
|
+
fprintf(stderr,
|
|
1594
|
+
"one of the columns in the attribute groups inconsistent for "
|
|
1595
|
+
"iterator\n");
|
|
1596
|
+
return false;
|
|
1597
|
+
}
|
|
1598
|
+
return true;
|
|
1599
|
+
};
|
|
1600
|
+
|
|
1601
|
+
return TestIterateImpl<AttributeGroupIterator>(
|
|
1602
|
+
thread, read_opts, rand_column_families, rand_keys, new_iter_func,
|
|
1603
|
+
verify_func);
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
template <typename IterType, typename NewIterFunc, typename VerifyFunc>
|
|
1607
|
+
Status StressTest::TestIterateImpl(ThreadState* thread,
|
|
1608
|
+
const ReadOptions& read_opts,
|
|
1609
|
+
const std::vector<int>& rand_column_families,
|
|
1610
|
+
const std::vector<int64_t>& rand_keys,
|
|
1611
|
+
NewIterFunc new_iter_func,
|
|
1612
|
+
VerifyFunc verify_func) {
|
|
1365
1613
|
assert(!rand_column_families.empty());
|
|
1366
1614
|
assert(!rand_keys.empty());
|
|
1367
1615
|
|
|
@@ -1392,8 +1640,8 @@ Status StressTest::TestIterate(ThreadState* thread,
|
|
|
1392
1640
|
}
|
|
1393
1641
|
std::string upper_bound_str;
|
|
1394
1642
|
Slice upper_bound;
|
|
1395
|
-
|
|
1396
|
-
|
|
1643
|
+
// Prefer no bound with no range query filtering; prefer bound with it
|
|
1644
|
+
if (FLAGS_use_sqfc_for_range_queries ^ thread->rand.OneIn(16)) {
|
|
1397
1645
|
// Note: upper_bound can be smaller than the seek key.
|
|
1398
1646
|
const int64_t rand_upper_key = GenerateOneKey(thread, FLAGS_ops_per_thread);
|
|
1399
1647
|
upper_bound_str = Key(rand_upper_key);
|
|
@@ -1403,8 +1651,7 @@ Status StressTest::TestIterate(ThreadState* thread,
|
|
|
1403
1651
|
|
|
1404
1652
|
std::string lower_bound_str;
|
|
1405
1653
|
Slice lower_bound;
|
|
1406
|
-
if (thread->rand.OneIn(16)) {
|
|
1407
|
-
// With a 1/16 chance, enable iterator lower bound.
|
|
1654
|
+
if (FLAGS_use_sqfc_for_range_queries ^ thread->rand.OneIn(16)) {
|
|
1408
1655
|
// Note: lower_bound can be greater than the seek key.
|
|
1409
1656
|
const int64_t rand_lower_key = GenerateOneKey(thread, FLAGS_ops_per_thread);
|
|
1410
1657
|
lower_bound_str = Key(rand_lower_key);
|
|
@@ -1412,15 +1659,20 @@ Status StressTest::TestIterate(ThreadState* thread,
|
|
|
1412
1659
|
ro.iterate_lower_bound = &lower_bound;
|
|
1413
1660
|
}
|
|
1414
1661
|
|
|
1415
|
-
|
|
1416
|
-
|
|
1662
|
+
if (FLAGS_use_sqfc_for_range_queries && ro.iterate_upper_bound &&
|
|
1663
|
+
ro.iterate_lower_bound) {
|
|
1664
|
+
ro.table_filter = sqfc_factory_->GetTableFilterForRangeQuery(
|
|
1665
|
+
*ro.iterate_lower_bound, *ro.iterate_upper_bound);
|
|
1666
|
+
}
|
|
1417
1667
|
|
|
1418
|
-
std::unique_ptr<
|
|
1668
|
+
std::unique_ptr<IterType> iter = new_iter_func(ro);
|
|
1419
1669
|
|
|
1420
1670
|
std::vector<std::string> key_strs;
|
|
1421
1671
|
if (thread->rand.OneIn(16)) {
|
|
1422
1672
|
// Generate keys close to lower or upper bound of SST files.
|
|
1423
|
-
key_strs =
|
|
1673
|
+
key_strs =
|
|
1674
|
+
GetWhiteBoxKeys(thread, db_, column_families_[rand_column_families[0]],
|
|
1675
|
+
rand_keys.size());
|
|
1424
1676
|
}
|
|
1425
1677
|
if (key_strs.empty()) {
|
|
1426
1678
|
// Use the random keys passed in.
|
|
@@ -1437,8 +1689,10 @@ Status StressTest::TestIterate(ThreadState* thread,
|
|
|
1437
1689
|
op_logs = "(cleared...)\n";
|
|
1438
1690
|
}
|
|
1439
1691
|
|
|
1440
|
-
if (
|
|
1692
|
+
if (!FLAGS_use_sqfc_for_range_queries &&
|
|
1693
|
+
ro.iterate_upper_bound != nullptr && thread->rand.OneIn(2)) {
|
|
1441
1694
|
// With a 1/2 chance, change the upper bound.
|
|
1695
|
+
// Not compatible with sqfc range filter.
|
|
1442
1696
|
// It is possible that it is changed before first use, but there is no
|
|
1443
1697
|
// problem with that.
|
|
1444
1698
|
const int64_t rand_upper_key =
|
|
@@ -1446,8 +1700,10 @@ Status StressTest::TestIterate(ThreadState* thread,
|
|
|
1446
1700
|
upper_bound_str = Key(rand_upper_key);
|
|
1447
1701
|
upper_bound = Slice(upper_bound_str);
|
|
1448
1702
|
}
|
|
1449
|
-
if (
|
|
1703
|
+
if (!FLAGS_use_sqfc_for_range_queries &&
|
|
1704
|
+
ro.iterate_lower_bound != nullptr && thread->rand.OneIn(4)) {
|
|
1450
1705
|
// With a 1/4 chance, change the lower bound.
|
|
1706
|
+
// Not compatible with sqfc range filter.
|
|
1451
1707
|
// It is possible that it is changed before first use, but there is no
|
|
1452
1708
|
// problem with that.
|
|
1453
1709
|
const int64_t rand_lower_key =
|
|
@@ -1482,10 +1738,14 @@ Status StressTest::TestIterate(ThreadState* thread,
|
|
|
1482
1738
|
|
|
1483
1739
|
const bool support_seek_first_or_last = expect_total_order;
|
|
1484
1740
|
|
|
1485
|
-
// Write-prepared and Write-unprepared do not support
|
|
1741
|
+
// Write-prepared and Write-unprepared and multi-cf-iterator do not support
|
|
1742
|
+
// Refresh() yet.
|
|
1486
1743
|
if (!(FLAGS_use_txn && FLAGS_txn_write_policy != 0 /* write committed */) &&
|
|
1487
|
-
thread->rand.OneIn(4)) {
|
|
1744
|
+
!FLAGS_use_multi_cf_iterator && thread->rand.OneIn(4)) {
|
|
1488
1745
|
Status s = iter->Refresh(snapshot_guard.snapshot());
|
|
1746
|
+
if (!s.ok() && IsErrorInjectedAndRetryable(s)) {
|
|
1747
|
+
return s;
|
|
1748
|
+
}
|
|
1489
1749
|
assert(s.ok());
|
|
1490
1750
|
op_logs += "Refresh ";
|
|
1491
1751
|
}
|
|
@@ -1513,8 +1773,15 @@ Status StressTest::TestIterate(ThreadState* thread,
|
|
|
1513
1773
|
op_logs += "S " + key.ToString(true) + " ";
|
|
1514
1774
|
}
|
|
1515
1775
|
|
|
1776
|
+
if (!iter->status().ok() && IsErrorInjectedAndRetryable(iter->status())) {
|
|
1777
|
+
return iter->status();
|
|
1778
|
+
} else if (!cmp_iter->status().ok() &&
|
|
1779
|
+
IsErrorInjectedAndRetryable(cmp_iter->status())) {
|
|
1780
|
+
return cmp_iter->status();
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1516
1783
|
VerifyIterator(thread, cmp_cfh, ro, iter.get(), cmp_iter.get(), last_op,
|
|
1517
|
-
key, op_logs, &diverged);
|
|
1784
|
+
key, op_logs, verify_func, &diverged);
|
|
1518
1785
|
|
|
1519
1786
|
const bool no_reverse =
|
|
1520
1787
|
(FLAGS_memtablerep == "prefix_hash" && !expect_total_order);
|
|
@@ -1537,8 +1804,15 @@ Status StressTest::TestIterate(ThreadState* thread,
|
|
|
1537
1804
|
|
|
1538
1805
|
last_op = kLastOpNextOrPrev;
|
|
1539
1806
|
|
|
1807
|
+
if (!iter->status().ok() && IsErrorInjectedAndRetryable(iter->status())) {
|
|
1808
|
+
return iter->status();
|
|
1809
|
+
} else if (!cmp_iter->status().ok() &&
|
|
1810
|
+
IsErrorInjectedAndRetryable(cmp_iter->status())) {
|
|
1811
|
+
return cmp_iter->status();
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1540
1814
|
VerifyIterator(thread, cmp_cfh, ro, iter.get(), cmp_iter.get(), last_op,
|
|
1541
|
-
key, op_logs, &diverged);
|
|
1815
|
+
key, op_logs, verify_func, &diverged);
|
|
1542
1816
|
}
|
|
1543
1817
|
|
|
1544
1818
|
thread->stats.AddIterations(1);
|
|
@@ -1549,43 +1823,37 @@ Status StressTest::TestIterate(ThreadState* thread,
|
|
|
1549
1823
|
return Status::OK();
|
|
1550
1824
|
}
|
|
1551
1825
|
|
|
1552
|
-
|
|
1553
|
-
Status StressTest::VerifyGetLiveFiles() const {
|
|
1826
|
+
Status StressTest::TestGetLiveFiles() const {
|
|
1554
1827
|
std::vector<std::string> live_file;
|
|
1555
1828
|
uint64_t manifest_size = 0;
|
|
1556
1829
|
return db_->GetLiveFiles(live_file, &manifest_size);
|
|
1557
1830
|
}
|
|
1558
1831
|
|
|
1559
|
-
|
|
1560
|
-
Status StressTest::VerifyGetLiveFilesMetaData() const {
|
|
1832
|
+
Status StressTest::TestGetLiveFilesMetaData() const {
|
|
1561
1833
|
std::vector<LiveFileMetaData> live_file_metadata;
|
|
1562
1834
|
db_->GetLiveFilesMetaData(&live_file_metadata);
|
|
1563
1835
|
return Status::OK();
|
|
1564
1836
|
}
|
|
1565
1837
|
|
|
1566
|
-
|
|
1567
|
-
Status StressTest::VerifyGetLiveFilesStorageInfo() const {
|
|
1838
|
+
Status StressTest::TestGetLiveFilesStorageInfo() const {
|
|
1568
1839
|
std::vector<LiveFileStorageInfo> live_file_storage_info;
|
|
1569
1840
|
return db_->GetLiveFilesStorageInfo(LiveFilesStorageInfoOptions(),
|
|
1570
1841
|
&live_file_storage_info);
|
|
1571
1842
|
}
|
|
1572
1843
|
|
|
1573
|
-
|
|
1574
|
-
Status StressTest::VerifyGetAllColumnFamilyMetaData() const {
|
|
1844
|
+
Status StressTest::TestGetAllColumnFamilyMetaData() const {
|
|
1575
1845
|
std::vector<ColumnFamilyMetaData> all_cf_metadata;
|
|
1576
1846
|
db_->GetAllColumnFamilyMetaData(&all_cf_metadata);
|
|
1577
1847
|
return Status::OK();
|
|
1578
1848
|
}
|
|
1579
1849
|
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
VectorLogPtr log_ptr;
|
|
1850
|
+
Status StressTest::TestGetSortedWalFiles() const {
|
|
1851
|
+
VectorWalPtr log_ptr;
|
|
1583
1852
|
return db_->GetSortedWalFiles(log_ptr);
|
|
1584
1853
|
}
|
|
1585
1854
|
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
std::unique_ptr<LogFile> cur_wal_file;
|
|
1855
|
+
Status StressTest::TestGetCurrentWalFile() const {
|
|
1856
|
+
std::unique_ptr<WalFile> cur_wal_file;
|
|
1589
1857
|
return db_->GetCurrentWalFile(&cur_wal_file);
|
|
1590
1858
|
}
|
|
1591
1859
|
|
|
@@ -1595,12 +1863,11 @@ Status StressTest::VerifyGetCurrentWalFile() const {
|
|
|
1595
1863
|
// Will flag failure if the verification fails.
|
|
1596
1864
|
// diverged = true if the two iterator is already diverged.
|
|
1597
1865
|
// True if verification passed, false if not.
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
const std::string& op_logs, bool* diverged) {
|
|
1866
|
+
template <typename IterType, typename VerifyFuncType>
|
|
1867
|
+
void StressTest::VerifyIterator(
|
|
1868
|
+
ThreadState* thread, ColumnFamilyHandle* cmp_cfh, const ReadOptions& ro,
|
|
1869
|
+
IterType* iter, Iterator* cmp_iter, LastIterateOp op, const Slice& seek_key,
|
|
1870
|
+
const std::string& op_logs, VerifyFuncType verify_func, bool* diverged) {
|
|
1604
1871
|
assert(diverged);
|
|
1605
1872
|
|
|
1606
1873
|
if (*diverged) {
|
|
@@ -1756,17 +2023,10 @@ void StressTest::VerifyIterator(ThreadState* thread,
|
|
|
1756
2023
|
}
|
|
1757
2024
|
|
|
1758
2025
|
if (!*diverged && iter->Valid()) {
|
|
1759
|
-
if (!
|
|
1760
|
-
fprintf(stderr,
|
|
1761
|
-
"Value and columns inconsistent for iterator: value: %s, "
|
|
1762
|
-
"columns: %s\n",
|
|
1763
|
-
iter->value().ToString(/* hex */ true).c_str(),
|
|
1764
|
-
WideColumnsToHex(iter->columns()).c_str());
|
|
1765
|
-
|
|
2026
|
+
if (!verify_func(iter)) {
|
|
1766
2027
|
*diverged = true;
|
|
1767
2028
|
}
|
|
1768
2029
|
}
|
|
1769
|
-
|
|
1770
2030
|
if (*diverged) {
|
|
1771
2031
|
fprintf(stderr, "VerifyIterator failed. Control CF %s\n",
|
|
1772
2032
|
cmp_cfh->GetName().c_str());
|
|
@@ -1864,6 +2124,16 @@ Status StressTest::TestBackupRestore(
|
|
|
1864
2124
|
if (!s.ok()) {
|
|
1865
2125
|
from = "BackupEngine::Open";
|
|
1866
2126
|
}
|
|
2127
|
+
|
|
2128
|
+
if (s.ok() && FLAGS_manual_wal_flush_one_in > 0) {
|
|
2129
|
+
// To avoid missing buffered WAL data during backup and cause false-positive
|
|
2130
|
+
// inconsistent values between original DB and restored DB
|
|
2131
|
+
s = db_->FlushWAL(/*sync=*/false);
|
|
2132
|
+
if (!s.ok()) {
|
|
2133
|
+
from = "FlushWAL";
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
|
|
1867
2137
|
if (s.ok()) {
|
|
1868
2138
|
if (backup_opts.schema_version >= 2 && thread->rand.OneIn(2)) {
|
|
1869
2139
|
TEST_BackupMetaSchemaOptions test_opts;
|
|
@@ -2071,7 +2341,20 @@ Status StressTest::TestBackupRestore(
|
|
|
2071
2341
|
delete backup_engine;
|
|
2072
2342
|
backup_engine = nullptr;
|
|
2073
2343
|
}
|
|
2074
|
-
|
|
2344
|
+
|
|
2345
|
+
// Temporarily disable error injection for clean up
|
|
2346
|
+
if (fault_fs_guard) {
|
|
2347
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
2348
|
+
FaultInjectionIOType::kRead);
|
|
2349
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
2350
|
+
FaultInjectionIOType::kWrite);
|
|
2351
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
2352
|
+
FaultInjectionIOType::kMetadataRead);
|
|
2353
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
2354
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
2355
|
+
}
|
|
2356
|
+
|
|
2357
|
+
if (s.ok() || IsErrorInjectedAndRetryable(s)) {
|
|
2075
2358
|
// Preserve directories on failure, or allowed persistent backup
|
|
2076
2359
|
if (!allow_persistent) {
|
|
2077
2360
|
s = DestroyDir(db_stress_env, backup_dir);
|
|
@@ -2080,13 +2363,27 @@ Status StressTest::TestBackupRestore(
|
|
|
2080
2363
|
}
|
|
2081
2364
|
}
|
|
2082
2365
|
}
|
|
2083
|
-
|
|
2366
|
+
|
|
2367
|
+
if (s.ok() || IsErrorInjectedAndRetryable(s)) {
|
|
2084
2368
|
s = DestroyDir(db_stress_env, restore_dir);
|
|
2085
2369
|
if (!s.ok()) {
|
|
2086
2370
|
from = "Destroy restore dir";
|
|
2087
2371
|
}
|
|
2088
2372
|
}
|
|
2089
|
-
|
|
2373
|
+
|
|
2374
|
+
// Enable back error injection disabled for clean up
|
|
2375
|
+
if (fault_fs_guard) {
|
|
2376
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
2377
|
+
FaultInjectionIOType::kRead);
|
|
2378
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
2379
|
+
FaultInjectionIOType::kWrite);
|
|
2380
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
2381
|
+
FaultInjectionIOType::kMetadataRead);
|
|
2382
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
2383
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
if (!s.ok() && !IsErrorInjectedAndRetryable(s)) {
|
|
2090
2387
|
fprintf(stderr,
|
|
2091
2388
|
"Failure in %s with: %s under specified BackupEngineOptions: %s, "
|
|
2092
2389
|
"CreateBackupOptions: %s, RestoreOptions: %s (Empty string or "
|
|
@@ -2221,26 +2518,58 @@ Status StressTest::TestCheckpoint(ThreadState* thread,
|
|
|
2221
2518
|
tmp_opts.env = db_stress_env;
|
|
2222
2519
|
// Avoid delayed deletion so whole directory can be deleted
|
|
2223
2520
|
tmp_opts.sst_file_manager.reset();
|
|
2224
|
-
|
|
2521
|
+
// Temporarily disable error injection for clean-up
|
|
2522
|
+
if (fault_fs_guard) {
|
|
2523
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
2524
|
+
FaultInjectionIOType::kRead);
|
|
2525
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
2526
|
+
FaultInjectionIOType::kWrite);
|
|
2527
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
2528
|
+
FaultInjectionIOType::kMetadataRead);
|
|
2529
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
2530
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
2531
|
+
}
|
|
2225
2532
|
DestroyDB(checkpoint_dir, tmp_opts);
|
|
2226
|
-
|
|
2533
|
+
// Enable back error injection disabled for clean-up
|
|
2534
|
+
if (fault_fs_guard) {
|
|
2535
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
2536
|
+
FaultInjectionIOType::kRead);
|
|
2537
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
2538
|
+
FaultInjectionIOType::kWrite);
|
|
2539
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
2540
|
+
FaultInjectionIOType::kMetadataRead);
|
|
2541
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
2542
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
2543
|
+
}
|
|
2227
2544
|
Checkpoint* checkpoint = nullptr;
|
|
2228
2545
|
Status s = Checkpoint::Create(db_, &checkpoint);
|
|
2229
2546
|
if (s.ok()) {
|
|
2230
2547
|
s = checkpoint->CreateCheckpoint(checkpoint_dir);
|
|
2231
|
-
if (!s.ok()) {
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2548
|
+
if (!s.ok() && !IsErrorInjectedAndRetryable(s)) {
|
|
2549
|
+
fprintf(stderr, "Fail to create checkpoint to %s\n",
|
|
2550
|
+
checkpoint_dir.c_str());
|
|
2551
|
+
std::vector<std::string> files;
|
|
2552
|
+
|
|
2553
|
+
// Temporarily disable error injection to print debugging information
|
|
2554
|
+
if (fault_fs_guard) {
|
|
2555
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
2556
|
+
FaultInjectionIOType::kMetadataRead);
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
Status my_s = db_stress_env->GetChildren(checkpoint_dir, &files);
|
|
2560
|
+
|
|
2561
|
+
// Enable back disable error injection disabled for printing debugging
|
|
2562
|
+
// information
|
|
2563
|
+
if (fault_fs_guard) {
|
|
2564
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
2565
|
+
FaultInjectionIOType::kMetadataRead);
|
|
2566
|
+
}
|
|
2567
|
+
if (!my_s.ok()) {
|
|
2568
|
+
fprintf(stderr, "Fail to GetChildren under %s due to %s\n",
|
|
2569
|
+
checkpoint_dir.c_str(), my_s.ToString().c_str());
|
|
2570
|
+
} else {
|
|
2571
|
+
for (const auto& f : files) {
|
|
2572
|
+
fprintf(stderr, " %s\n", f.c_str());
|
|
2244
2573
|
}
|
|
2245
2574
|
}
|
|
2246
2575
|
}
|
|
@@ -2316,14 +2645,36 @@ Status StressTest::TestCheckpoint(ThreadState* thread,
|
|
|
2316
2645
|
checkpoint_db = nullptr;
|
|
2317
2646
|
}
|
|
2318
2647
|
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2648
|
+
// Temporarily disable error injection for clean-up
|
|
2649
|
+
if (fault_fs_guard) {
|
|
2650
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
2651
|
+
FaultInjectionIOType::kRead);
|
|
2652
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
2653
|
+
FaultInjectionIOType::kWrite);
|
|
2654
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
2655
|
+
FaultInjectionIOType::kMetadataRead);
|
|
2656
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
2657
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
if (!s.ok() && !IsErrorInjectedAndRetryable(s)) {
|
|
2661
|
+
fprintf(stderr, "A checkpoint operation failed with: %s\n",
|
|
2662
|
+
s.ToString().c_str());
|
|
2324
2663
|
} else {
|
|
2325
2664
|
DestroyDB(checkpoint_dir, tmp_opts);
|
|
2326
2665
|
}
|
|
2666
|
+
|
|
2667
|
+
// Enable back error injection disabled for clean-up
|
|
2668
|
+
if (fault_fs_guard) {
|
|
2669
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
2670
|
+
FaultInjectionIOType::kRead);
|
|
2671
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
2672
|
+
FaultInjectionIOType::kWrite);
|
|
2673
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
2674
|
+
FaultInjectionIOType::kMetadataRead);
|
|
2675
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
2676
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
2677
|
+
}
|
|
2327
2678
|
return s;
|
|
2328
2679
|
}
|
|
2329
2680
|
|
|
@@ -2457,19 +2808,18 @@ void StressTest::TestCompactFiles(ThreadState* thread,
|
|
|
2457
2808
|
auto s = db_->CompactFiles(compact_options, column_family, input_files,
|
|
2458
2809
|
static_cast<int>(output_level));
|
|
2459
2810
|
if (!s.ok()) {
|
|
2811
|
+
thread->stats.AddNumCompactFilesFailed(1);
|
|
2460
2812
|
// TOOD (hx235): allow an exact list of tolerable failures under stress
|
|
2461
2813
|
// test
|
|
2462
2814
|
bool non_ok_status_allowed =
|
|
2463
|
-
s.IsManualCompactionPaused() ||
|
|
2464
|
-
(s.getState() && std::strstr(s.getState(), "injected")) ||
|
|
2815
|
+
s.IsManualCompactionPaused() || IsErrorInjectedAndRetryable(s) ||
|
|
2465
2816
|
s.IsAborted() || s.IsInvalidArgument() || s.IsNotSupported();
|
|
2466
|
-
fprintf(non_ok_status_allowed ? stdout : stderr,
|
|
2467
|
-
"Unable to perform CompactFiles(): %s under specified "
|
|
2468
|
-
"CompactionOptions: %s (Empty string or "
|
|
2469
|
-
"missing field indicates default option or value is used)\n",
|
|
2470
|
-
s.ToString().c_str(), compact_opt_oss.str().c_str());
|
|
2471
|
-
thread->stats.AddNumCompactFilesFailed(1);
|
|
2472
2817
|
if (!non_ok_status_allowed) {
|
|
2818
|
+
fprintf(stderr,
|
|
2819
|
+
"Unable to perform CompactFiles(): %s under specified "
|
|
2820
|
+
"CompactionOptions: %s (Empty string or "
|
|
2821
|
+
"missing field indicates default option or value is used)\n",
|
|
2822
|
+
s.ToString().c_str(), compact_opt_oss.str().c_str());
|
|
2473
2823
|
thread->shared->SafeTerminate();
|
|
2474
2824
|
}
|
|
2475
2825
|
} else {
|
|
@@ -2493,11 +2843,12 @@ void StressTest::TestPromoteL0(ThreadState* thread,
|
|
|
2493
2843
|
s.ToString().find("VersionBuilder: Cannot delete table file") !=
|
|
2494
2844
|
std::string::npos &&
|
|
2495
2845
|
s.ToString().find("since it is on level") != std::string::npos);
|
|
2496
|
-
|
|
2497
|
-
"Unable to perform PromoteL0(): %s under specified "
|
|
2498
|
-
"target_level: %d.\n",
|
|
2499
|
-
s.ToString().c_str(), target_level);
|
|
2846
|
+
|
|
2500
2847
|
if (!non_ok_status_allowed) {
|
|
2848
|
+
fprintf(stderr,
|
|
2849
|
+
"Unable to perform PromoteL0(): %s under specified "
|
|
2850
|
+
"target_level: %d.\n",
|
|
2851
|
+
s.ToString().c_str(), target_level);
|
|
2501
2852
|
thread->shared->SafeTerminate();
|
|
2502
2853
|
}
|
|
2503
2854
|
}
|
|
@@ -2585,7 +2936,11 @@ void StressTest::TestAcquireSnapshot(ThreadState* thread,
|
|
|
2585
2936
|
// When taking a snapshot, we also read a key from that snapshot. We
|
|
2586
2937
|
// will later read the same key before releasing the snapshot and
|
|
2587
2938
|
// verify that the results are the same.
|
|
2588
|
-
|
|
2939
|
+
Status status_at = db_->Get(ropt, column_family, key, &value_at);
|
|
2940
|
+
if (!status_at.ok() && IsErrorInjectedAndRetryable(status_at)) {
|
|
2941
|
+
db_->ReleaseSnapshot(snapshot);
|
|
2942
|
+
return;
|
|
2943
|
+
}
|
|
2589
2944
|
std::vector<bool>* key_vec = nullptr;
|
|
2590
2945
|
|
|
2591
2946
|
if (FLAGS_compare_full_db_state_snapshot && (thread->tid == 0)) {
|
|
@@ -2691,11 +3046,34 @@ void StressTest::TestCompactRange(ThreadState* thread, int64_t rand_key,
|
|
|
2691
3046
|
const Snapshot* pre_snapshot = nullptr;
|
|
2692
3047
|
uint32_t pre_hash = 0;
|
|
2693
3048
|
if (thread->rand.OneIn(2)) {
|
|
2694
|
-
//
|
|
2695
|
-
|
|
3049
|
+
// Temporarily disable error injection to for validation
|
|
3050
|
+
if (fault_fs_guard) {
|
|
3051
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
3052
|
+
FaultInjectionIOType::kMetadataRead);
|
|
3053
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
3054
|
+
FaultInjectionIOType::kRead);
|
|
3055
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
3056
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
3057
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
3058
|
+
FaultInjectionIOType::kWrite);
|
|
3059
|
+
}
|
|
3060
|
+
|
|
3061
|
+
// Declare a snapshot and compare the data before and after the compaction
|
|
2696
3062
|
pre_snapshot = db_->GetSnapshot();
|
|
2697
3063
|
pre_hash =
|
|
2698
3064
|
GetRangeHash(thread, pre_snapshot, column_family, start_key, end_key);
|
|
3065
|
+
|
|
3066
|
+
// Enable back error injection disabled for validation
|
|
3067
|
+
if (fault_fs_guard) {
|
|
3068
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
3069
|
+
FaultInjectionIOType::kMetadataRead);
|
|
3070
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
3071
|
+
FaultInjectionIOType::kRead);
|
|
3072
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
3073
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
3074
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
3075
|
+
FaultInjectionIOType::kWrite);
|
|
3076
|
+
}
|
|
2699
3077
|
}
|
|
2700
3078
|
std::ostringstream compact_range_opt_oss;
|
|
2701
3079
|
compact_range_opt_oss << "exclusive_manual_compaction: "
|
|
@@ -2716,21 +3094,31 @@ void StressTest::TestCompactRange(ThreadState* thread, int64_t rand_key,
|
|
|
2716
3094
|
// TOOD (hx235): allow an exact list of tolerable failures under stress test
|
|
2717
3095
|
bool non_ok_status_allowed =
|
|
2718
3096
|
status.IsManualCompactionPaused() ||
|
|
2719
|
-
(status
|
|
2720
|
-
status.
|
|
2721
|
-
status.IsNotSupported();
|
|
2722
|
-
fprintf(non_ok_status_allowed ? stdout : stderr,
|
|
2723
|
-
"Unable to perform CompactRange(): %s under specified "
|
|
2724
|
-
"CompactRangeOptions: %s (Empty string or "
|
|
2725
|
-
"missing field indicates default option or value is used)\n",
|
|
2726
|
-
status.ToString().c_str(), compact_range_opt_oss.str().c_str());
|
|
3097
|
+
IsErrorInjectedAndRetryable(status) || status.IsAborted() ||
|
|
3098
|
+
status.IsInvalidArgument() || status.IsNotSupported();
|
|
2727
3099
|
if (!non_ok_status_allowed) {
|
|
3100
|
+
fprintf(stderr,
|
|
3101
|
+
"Unable to perform CompactRange(): %s under specified "
|
|
3102
|
+
"CompactRangeOptions: %s (Empty string or "
|
|
3103
|
+
"missing field indicates default option or value is used)\n",
|
|
3104
|
+
status.ToString().c_str(), compact_range_opt_oss.str().c_str());
|
|
2728
3105
|
// Fail fast to preserve the DB state.
|
|
2729
3106
|
thread->shared->SetVerificationFailure();
|
|
2730
3107
|
}
|
|
2731
3108
|
}
|
|
2732
3109
|
|
|
2733
3110
|
if (pre_snapshot != nullptr) {
|
|
3111
|
+
// Temporarily disable error injection for validation
|
|
3112
|
+
if (fault_fs_guard) {
|
|
3113
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
3114
|
+
FaultInjectionIOType::kMetadataRead);
|
|
3115
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
3116
|
+
FaultInjectionIOType::kRead);
|
|
3117
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
3118
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
3119
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
3120
|
+
FaultInjectionIOType::kWrite);
|
|
3121
|
+
}
|
|
2734
3122
|
uint32_t post_hash =
|
|
2735
3123
|
GetRangeHash(thread, pre_snapshot, column_family, start_key, end_key);
|
|
2736
3124
|
if (pre_hash != post_hash) {
|
|
@@ -2746,6 +3134,17 @@ void StressTest::TestCompactRange(ThreadState* thread, int64_t rand_key,
|
|
|
2746
3134
|
thread->shared->SetVerificationFailure();
|
|
2747
3135
|
}
|
|
2748
3136
|
db_->ReleaseSnapshot(pre_snapshot);
|
|
3137
|
+
if (fault_fs_guard) {
|
|
3138
|
+
// Enable back error injection disabled for validation
|
|
3139
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
3140
|
+
FaultInjectionIOType::kMetadataRead);
|
|
3141
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
3142
|
+
FaultInjectionIOType::kRead);
|
|
3143
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
3144
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
3145
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
3146
|
+
FaultInjectionIOType::kWrite);
|
|
3147
|
+
}
|
|
2749
3148
|
}
|
|
2750
3149
|
}
|
|
2751
3150
|
|
|
@@ -2967,11 +3366,24 @@ void StressTest::PrintEnv() const {
|
|
|
2967
3366
|
FLAGS_max_write_batch_group_size_bytes);
|
|
2968
3367
|
fprintf(stdout, "Use dynamic level : %d\n",
|
|
2969
3368
|
static_cast<int>(FLAGS_level_compaction_dynamic_level_bytes));
|
|
3369
|
+
fprintf(stdout, "Metadata read fault one in : %d\n",
|
|
3370
|
+
FLAGS_metadata_read_fault_one_in);
|
|
3371
|
+
fprintf(stdout, "Metadata write fault one in : %d\n",
|
|
3372
|
+
FLAGS_metadata_write_fault_one_in);
|
|
2970
3373
|
fprintf(stdout, "Read fault one in : %d\n", FLAGS_read_fault_one_in);
|
|
2971
3374
|
fprintf(stdout, "Write fault one in : %d\n", FLAGS_write_fault_one_in);
|
|
3375
|
+
fprintf(stdout, "Open metadata read fault one in:\n");
|
|
3376
|
+
fprintf(stdout, " %d\n",
|
|
3377
|
+
FLAGS_open_metadata_read_fault_one_in);
|
|
2972
3378
|
fprintf(stdout, "Open metadata write fault one in:\n");
|
|
2973
3379
|
fprintf(stdout, " %d\n",
|
|
2974
3380
|
FLAGS_open_metadata_write_fault_one_in);
|
|
3381
|
+
fprintf(stdout, "Open read fault one in :\n");
|
|
3382
|
+
fprintf(stdout, " %d\n",
|
|
3383
|
+
FLAGS_open_read_fault_one_in);
|
|
3384
|
+
fprintf(stdout, "Open write fault one in :\n");
|
|
3385
|
+
fprintf(stdout, " %d\n",
|
|
3386
|
+
FLAGS_open_write_fault_one_in);
|
|
2975
3387
|
fprintf(stdout, "Sync fault injection : %d\n",
|
|
2976
3388
|
FLAGS_sync_fault_injection);
|
|
2977
3389
|
fprintf(stdout, "Best efforts recovery : %d\n",
|
|
@@ -2997,7 +3409,7 @@ void StressTest::Open(SharedState* shared, bool reopen) {
|
|
|
2997
3409
|
if (!InitializeOptionsFromFile(options_)) {
|
|
2998
3410
|
InitializeOptionsFromFlags(cache_, filter_policy_, options_);
|
|
2999
3411
|
}
|
|
3000
|
-
InitializeOptionsGeneral(cache_, filter_policy_, options_);
|
|
3412
|
+
InitializeOptionsGeneral(cache_, filter_policy_, sqfc_factory_, options_);
|
|
3001
3413
|
|
|
3002
3414
|
if (FLAGS_prefix_size == 0 && FLAGS_rep_factory == kHashSkipList) {
|
|
3003
3415
|
fprintf(stderr,
|
|
@@ -3108,51 +3520,66 @@ void StressTest::Open(SharedState* shared, bool reopen) {
|
|
|
3108
3520
|
FLAGS_db, options_.db_paths, cf_descriptors, db_stress_listener_env));
|
|
3109
3521
|
RegisterAdditionalListeners();
|
|
3110
3522
|
|
|
3111
|
-
// If this is for DB reopen,
|
|
3523
|
+
// If this is for DB reopen, error injection may have been enabled.
|
|
3112
3524
|
// Disable it here in case there is no open fault injection.
|
|
3113
3525
|
if (fault_fs_guard) {
|
|
3114
|
-
fault_fs_guard->
|
|
3526
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
3527
|
+
FaultInjectionIOType::kRead);
|
|
3528
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
3529
|
+
FaultInjectionIOType::kWrite);
|
|
3530
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
3531
|
+
FaultInjectionIOType::kMetadataRead);
|
|
3532
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
3533
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
3115
3534
|
}
|
|
3535
|
+
// TODO; test transaction DB Open with fault injection
|
|
3116
3536
|
if (!FLAGS_use_txn) {
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
bool
|
|
3123
|
-
bool
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3537
|
+
bool inject_sync_fault = FLAGS_sync_fault_injection;
|
|
3538
|
+
bool inject_open_meta_read_error =
|
|
3539
|
+
FLAGS_open_metadata_read_fault_one_in > 0;
|
|
3540
|
+
bool inject_open_meta_write_error =
|
|
3541
|
+
FLAGS_open_metadata_write_fault_one_in > 0;
|
|
3542
|
+
bool inject_open_read_error = FLAGS_open_read_fault_one_in > 0;
|
|
3543
|
+
bool inject_open_write_error = FLAGS_open_write_fault_one_in > 0;
|
|
3544
|
+
if ((inject_sync_fault || inject_open_meta_read_error ||
|
|
3545
|
+
inject_open_meta_write_error || inject_open_read_error ||
|
|
3546
|
+
inject_open_write_error) &&
|
|
3127
3547
|
fault_fs_guard
|
|
3128
3548
|
->FileExists(FLAGS_db + "/CURRENT", IOOptions(), nullptr)
|
|
3129
3549
|
.ok()) {
|
|
3130
|
-
if (
|
|
3131
|
-
// When DB Stress is not sync mode, we expect all WAL writes to
|
|
3132
|
-
// WAL is durable. Buffering unsynced writes will cause false
|
|
3133
|
-
// positive in crash tests. Before we figure out a way to
|
|
3134
|
-
// solve it, skip WAL from failure injection.
|
|
3135
|
-
fault_fs_guard->SetDirectWritableTypes({kWalFile});
|
|
3136
|
-
}
|
|
3137
|
-
inject_meta_error = FLAGS_open_metadata_write_fault_one_in;
|
|
3138
|
-
inject_write_error = FLAGS_open_write_fault_one_in;
|
|
3139
|
-
inject_read_error = FLAGS_open_read_fault_one_in;
|
|
3140
|
-
if (inject_meta_error) {
|
|
3141
|
-
fault_fs_guard->EnableMetadataWriteErrorInjection();
|
|
3142
|
-
fault_fs_guard->SetRandomMetadataWriteError(
|
|
3143
|
-
FLAGS_open_metadata_write_fault_one_in);
|
|
3144
|
-
}
|
|
3145
|
-
if (inject_write_error) {
|
|
3550
|
+
if (inject_sync_fault || inject_open_write_error) {
|
|
3146
3551
|
fault_fs_guard->SetFilesystemDirectWritable(false);
|
|
3147
|
-
fault_fs_guard->
|
|
3148
|
-
fault_fs_guard->SetRandomWriteError(
|
|
3149
|
-
static_cast<uint32_t>(FLAGS_seed), FLAGS_open_write_fault_one_in,
|
|
3150
|
-
IOStatus::IOError("Injected Open Write Error"),
|
|
3151
|
-
/*inject_for_all_file_types=*/true, /*types=*/{});
|
|
3152
|
-
}
|
|
3153
|
-
if (inject_read_error) {
|
|
3154
|
-
fault_fs_guard->SetRandomReadError(FLAGS_open_read_fault_one_in);
|
|
3552
|
+
fault_fs_guard->SetInjectUnsyncedDataLoss(inject_sync_fault);
|
|
3155
3553
|
}
|
|
3554
|
+
fault_fs_guard->SetThreadLocalErrorContext(
|
|
3555
|
+
FaultInjectionIOType::kMetadataRead,
|
|
3556
|
+
static_cast<uint32_t>(FLAGS_seed),
|
|
3557
|
+
FLAGS_open_metadata_read_fault_one_in, false /* retryable */,
|
|
3558
|
+
false /* has_data_loss */);
|
|
3559
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
3560
|
+
FaultInjectionIOType::kMetadataRead);
|
|
3561
|
+
|
|
3562
|
+
fault_fs_guard->SetThreadLocalErrorContext(
|
|
3563
|
+
FaultInjectionIOType::kMetadataWrite,
|
|
3564
|
+
static_cast<uint32_t>(FLAGS_seed),
|
|
3565
|
+
FLAGS_open_metadata_write_fault_one_in, false /* retryable */,
|
|
3566
|
+
false /* has_data_loss */);
|
|
3567
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
3568
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
3569
|
+
|
|
3570
|
+
fault_fs_guard->SetThreadLocalErrorContext(
|
|
3571
|
+
FaultInjectionIOType::kRead, static_cast<uint32_t>(FLAGS_seed),
|
|
3572
|
+
FLAGS_open_read_fault_one_in, false /* retryable */,
|
|
3573
|
+
false /* has_data_loss */);
|
|
3574
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
3575
|
+
FaultInjectionIOType::kRead);
|
|
3576
|
+
|
|
3577
|
+
fault_fs_guard->SetThreadLocalErrorContext(
|
|
3578
|
+
FaultInjectionIOType::kWrite, static_cast<uint32_t>(FLAGS_seed),
|
|
3579
|
+
FLAGS_open_write_fault_one_in, false /* retryable */,
|
|
3580
|
+
false /* has_data_loss */);
|
|
3581
|
+
fault_fs_guard->EnableThreadLocalErrorInjection(
|
|
3582
|
+
FaultInjectionIOType::kWrite);
|
|
3156
3583
|
}
|
|
3157
3584
|
while (true) {
|
|
3158
3585
|
// StackableDB-based BlobDB
|
|
@@ -3181,14 +3608,18 @@ void StressTest::Open(SharedState* shared, bool reopen) {
|
|
|
3181
3608
|
}
|
|
3182
3609
|
}
|
|
3183
3610
|
|
|
3184
|
-
if (
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
fault_fs_guard->
|
|
3188
|
-
|
|
3189
|
-
fault_fs_guard->
|
|
3190
|
-
|
|
3191
|
-
fault_fs_guard->
|
|
3611
|
+
if (inject_sync_fault || inject_open_meta_read_error ||
|
|
3612
|
+
inject_open_meta_write_error || inject_open_read_error ||
|
|
3613
|
+
inject_open_write_error) {
|
|
3614
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
3615
|
+
FaultInjectionIOType::kRead);
|
|
3616
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
3617
|
+
FaultInjectionIOType::kWrite);
|
|
3618
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
3619
|
+
FaultInjectionIOType::kMetadataRead);
|
|
3620
|
+
fault_fs_guard->DisableThreadLocalErrorInjection(
|
|
3621
|
+
FaultInjectionIOType::kMetadataWrite);
|
|
3622
|
+
|
|
3192
3623
|
if (s.ok()) {
|
|
3193
3624
|
// Injected errors might happen in background compactions. We
|
|
3194
3625
|
// wait for all compactions to finish to make sure DB is in
|
|
@@ -3204,12 +3635,14 @@ void StressTest::Open(SharedState* shared, bool reopen) {
|
|
|
3204
3635
|
}
|
|
3205
3636
|
}
|
|
3206
3637
|
if (!s.ok()) {
|
|
3207
|
-
// After failure to opening a DB due to IO error
|
|
3208
|
-
// successfully open the DB with correct data if
|
|
3209
|
-
// up.
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3638
|
+
// After failure to opening a DB due to IO error or unsynced data
|
|
3639
|
+
// loss, retry should successfully open the DB with correct data if
|
|
3640
|
+
// no IO error shows up.
|
|
3641
|
+
inject_sync_fault = false;
|
|
3642
|
+
inject_open_meta_read_error = false;
|
|
3643
|
+
inject_open_meta_write_error = false;
|
|
3644
|
+
inject_open_read_error = false;
|
|
3645
|
+
inject_open_write_error = false;
|
|
3213
3646
|
|
|
3214
3647
|
// TODO: Unsynced data loss during DB reopen is not supported yet in
|
|
3215
3648
|
// stress test. Will need to recreate expected state if we decide
|
|
@@ -3360,6 +3793,27 @@ void StressTest::Reopen(ThreadState* thread) {
|
|
|
3360
3793
|
}
|
|
3361
3794
|
column_families_.clear();
|
|
3362
3795
|
|
|
3796
|
+
// Currently reopen does not restore expected state
|
|
3797
|
+
// with potential data loss in mind like the first open before
|
|
3798
|
+
// crash-recovery verification does. Therefore it always expects no data loss
|
|
3799
|
+
// and we should ensure no data loss in testing.
|
|
3800
|
+
// TODO(hx235): eliminate the FlushWAL(true /* sync */)/SyncWAL() below
|
|
3801
|
+
if (!FLAGS_disable_wal && !FLAGS_avoid_flush_during_shutdown) {
|
|
3802
|
+
Status s;
|
|
3803
|
+
if (FLAGS_manual_wal_flush_one_in > 0) {
|
|
3804
|
+
s = db_->FlushWAL(/*sync=*/true);
|
|
3805
|
+
} else {
|
|
3806
|
+
s = db_->SyncWAL();
|
|
3807
|
+
}
|
|
3808
|
+
if (!s.ok()) {
|
|
3809
|
+
fprintf(stderr,
|
|
3810
|
+
"Error persisting WAL data which is needed before reopening the "
|
|
3811
|
+
"DB: %s\n",
|
|
3812
|
+
s.ToString().c_str());
|
|
3813
|
+
exit(1);
|
|
3814
|
+
}
|
|
3815
|
+
}
|
|
3816
|
+
|
|
3363
3817
|
if (thread->rand.OneIn(2)) {
|
|
3364
3818
|
Status s = db_->Close();
|
|
3365
3819
|
if (!s.ok()) {
|
|
@@ -3381,8 +3835,7 @@ void StressTest::Reopen(ThreadState* thread) {
|
|
|
3381
3835
|
clock_->TimeToString(now / 1000000).c_str(), num_times_reopened_);
|
|
3382
3836
|
Open(thread->shared, /*reopen=*/true);
|
|
3383
3837
|
|
|
3384
|
-
if ((
|
|
3385
|
-
FLAGS_manual_wal_flush_one_in > 0) &&
|
|
3838
|
+
if (thread->shared->GetStressTest()->MightHaveUnsyncedDataLoss() &&
|
|
3386
3839
|
IsStateTracked()) {
|
|
3387
3840
|
Status s = thread->shared->SaveAtAndAfter(db_);
|
|
3388
3841
|
if (!s.ok()) {
|
|
@@ -3699,6 +4152,8 @@ void InitializeOptionsFromFlags(
|
|
|
3699
4152
|
FLAGS_universal_max_merge_width;
|
|
3700
4153
|
options.compaction_options_universal.max_size_amplification_percent =
|
|
3701
4154
|
FLAGS_universal_max_size_amplification_percent;
|
|
4155
|
+
options.compaction_options_universal.max_read_amp =
|
|
4156
|
+
FLAGS_universal_max_read_amp;
|
|
3702
4157
|
options.atomic_flush = FLAGS_atomic_flush;
|
|
3703
4158
|
options.manual_wal_flush = FLAGS_manual_wal_flush_one_in > 0 ? true : false;
|
|
3704
4159
|
options.avoid_unnecessary_blocking_io = FLAGS_avoid_unnecessary_blocking_io;
|
|
@@ -3851,11 +4306,13 @@ void InitializeOptionsFromFlags(
|
|
|
3851
4306
|
options.lowest_used_cache_tier =
|
|
3852
4307
|
static_cast<CacheTier>(FLAGS_lowest_used_cache_tier);
|
|
3853
4308
|
options.inplace_update_support = FLAGS_inplace_update_support;
|
|
4309
|
+
options.uncache_aggressiveness = FLAGS_uncache_aggressiveness;
|
|
3854
4310
|
}
|
|
3855
4311
|
|
|
3856
4312
|
void InitializeOptionsGeneral(
|
|
3857
4313
|
const std::shared_ptr<Cache>& cache,
|
|
3858
4314
|
const std::shared_ptr<const FilterPolicy>& filter_policy,
|
|
4315
|
+
const std::shared_ptr<SstQueryFilterConfigsManager::Factory>& sqfc_factory,
|
|
3859
4316
|
Options& options) {
|
|
3860
4317
|
options.create_missing_column_families = true;
|
|
3861
4318
|
options.create_if_missing = true;
|
|
@@ -3929,6 +4386,10 @@ void InitializeOptionsGeneral(
|
|
|
3929
4386
|
|
|
3930
4387
|
options.table_properties_collector_factories.emplace_back(
|
|
3931
4388
|
std::make_shared<DbStressTablePropertiesCollectorFactory>());
|
|
4389
|
+
|
|
4390
|
+
if (sqfc_factory && !sqfc_factory->GetConfigs().IsEmptyNotFound()) {
|
|
4391
|
+
options.table_properties_collector_factories.emplace_back(sqfc_factory);
|
|
4392
|
+
}
|
|
3932
4393
|
}
|
|
3933
4394
|
|
|
3934
4395
|
} // namespace ROCKSDB_NAMESPACE
|