@nxtedition/rocksdb 10.1.5 → 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 +5 -7
- 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/package.json +1 -1
- package/prebuilds/darwin-arm64/@nxtedition+rocksdb.node +0 -0
- 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
|
@@ -32,22 +32,25 @@ namespace ROCKSDB_NAMESPACE {
|
|
|
32
32
|
class TestFSWritableFile;
|
|
33
33
|
class FaultInjectionTestFS;
|
|
34
34
|
|
|
35
|
+
enum class FaultInjectionIOType {
|
|
36
|
+
kRead = 0,
|
|
37
|
+
kWrite,
|
|
38
|
+
kMetadataRead,
|
|
39
|
+
kMetadataWrite,
|
|
40
|
+
};
|
|
41
|
+
|
|
35
42
|
struct FSFileState {
|
|
36
43
|
std::string filename_;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
ssize_t pos_at_last_flush_;
|
|
44
|
+
uint64_t pos_at_last_append_ = 0;
|
|
45
|
+
uint64_t pos_at_last_sync_ = 0;
|
|
40
46
|
std::string buffer_;
|
|
41
47
|
|
|
42
|
-
explicit FSFileState(const std::string& filename)
|
|
43
|
-
: filename_(filename)
|
|
44
|
-
pos_(-1),
|
|
45
|
-
pos_at_last_sync_(-1),
|
|
46
|
-
pos_at_last_flush_(-1) {}
|
|
47
|
-
|
|
48
|
-
FSFileState() : pos_(-1), pos_at_last_sync_(-1), pos_at_last_flush_(-1) {}
|
|
48
|
+
explicit FSFileState(const std::string& filename = {})
|
|
49
|
+
: filename_(filename) {}
|
|
49
50
|
|
|
50
|
-
bool IsFullySynced() const {
|
|
51
|
+
bool IsFullySynced() const {
|
|
52
|
+
return pos_at_last_append_ == pos_at_last_sync_;
|
|
53
|
+
}
|
|
51
54
|
|
|
52
55
|
IOStatus DropUnsyncedData();
|
|
53
56
|
|
|
@@ -69,9 +72,7 @@ class TestFSWritableFile : public FSWritableFile {
|
|
|
69
72
|
const DataVerificationInfo& verification_info,
|
|
70
73
|
IODebugContext* dbg) override;
|
|
71
74
|
IOStatus Truncate(uint64_t size, const IOOptions& options,
|
|
72
|
-
IODebugContext* dbg) override
|
|
73
|
-
return target_->Truncate(size, options, dbg);
|
|
74
|
-
}
|
|
75
|
+
IODebugContext* dbg) override;
|
|
75
76
|
IOStatus Close(const IOOptions& options, IODebugContext* dbg) override;
|
|
76
77
|
IOStatus Flush(const IOOptions&, IODebugContext*) override;
|
|
77
78
|
IOStatus Sync(const IOOptions& options, IODebugContext* dbg) override;
|
|
@@ -80,9 +81,7 @@ class TestFSWritableFile : public FSWritableFile {
|
|
|
80
81
|
bool IsSyncThreadSafe() const override { return true; }
|
|
81
82
|
IOStatus PositionedAppend(const Slice& data, uint64_t offset,
|
|
82
83
|
const IOOptions& options,
|
|
83
|
-
IODebugContext* dbg) override
|
|
84
|
-
return target_->PositionedAppend(data, offset, options, dbg);
|
|
85
|
-
}
|
|
84
|
+
IODebugContext* dbg) override;
|
|
86
85
|
IOStatus PositionedAppend(const Slice& data, uint64_t offset,
|
|
87
86
|
const IOOptions& options,
|
|
88
87
|
const DataVerificationInfo& verification_info,
|
|
@@ -104,6 +103,7 @@ class TestFSWritableFile : public FSWritableFile {
|
|
|
104
103
|
bool writable_file_opened_;
|
|
105
104
|
FaultInjectionTestFS* fs_;
|
|
106
105
|
port::Mutex mutex_;
|
|
106
|
+
const bool unsync_data_loss_;
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
// A wrapper around WritableFileWriter* file
|
|
@@ -163,8 +163,10 @@ class TestFSRandomAccessFile : public FSRandomAccessFile {
|
|
|
163
163
|
class TestFSSequentialFile : public FSSequentialFileOwnerWrapper {
|
|
164
164
|
public:
|
|
165
165
|
explicit TestFSSequentialFile(std::unique_ptr<FSSequentialFile>&& f,
|
|
166
|
-
FaultInjectionTestFS* fs)
|
|
167
|
-
: FSSequentialFileOwnerWrapper(std::move(f)),
|
|
166
|
+
FaultInjectionTestFS* fs, std::string fname)
|
|
167
|
+
: FSSequentialFileOwnerWrapper(std::move(f)),
|
|
168
|
+
fs_(fs),
|
|
169
|
+
fname_(std::move(fname)) {}
|
|
168
170
|
IOStatus Read(size_t n, const IOOptions& options, Slice* result,
|
|
169
171
|
char* scratch, IODebugContext* dbg) override;
|
|
170
172
|
IOStatus PositionedRead(uint64_t offset, size_t n, const IOOptions& options,
|
|
@@ -173,13 +175,16 @@ class TestFSSequentialFile : public FSSequentialFileOwnerWrapper {
|
|
|
173
175
|
|
|
174
176
|
private:
|
|
175
177
|
FaultInjectionTestFS* fs_;
|
|
178
|
+
std::string fname_;
|
|
179
|
+
uint64_t read_pos_ = 0;
|
|
180
|
+
uint64_t target_read_pos_ = 0;
|
|
176
181
|
};
|
|
177
182
|
|
|
178
183
|
class TestFSDirectory : public FSDirectory {
|
|
179
184
|
public:
|
|
180
185
|
explicit TestFSDirectory(FaultInjectionTestFS* fs, std::string dirname,
|
|
181
186
|
FSDirectory* dir)
|
|
182
|
-
: fs_(fs), dirname_(dirname), dir_(dir) {}
|
|
187
|
+
: fs_(fs), dirname_(std::move(dirname)), dir_(dir) {}
|
|
183
188
|
~TestFSDirectory() {}
|
|
184
189
|
|
|
185
190
|
IOStatus Fsync(const IOOptions& options, IODebugContext* dbg) override;
|
|
@@ -202,17 +207,19 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
202
207
|
: FileSystemWrapper(base),
|
|
203
208
|
filesystem_active_(true),
|
|
204
209
|
filesystem_writable_(false),
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
inject_unsynced_data_loss_(false),
|
|
211
|
+
read_unsynced_data_(true),
|
|
212
|
+
allow_link_open_file_(false),
|
|
213
|
+
injected_thread_local_read_error_(DeleteThreadLocalErrorContext),
|
|
214
|
+
injected_thread_local_write_error_(DeleteThreadLocalErrorContext),
|
|
215
|
+
injected_thread_local_metadata_read_error_(
|
|
216
|
+
DeleteThreadLocalErrorContext),
|
|
217
|
+
injected_thread_local_metadata_write_error_(
|
|
218
|
+
DeleteThreadLocalErrorContext),
|
|
212
219
|
ingest_data_corruption_before_write_(false),
|
|
213
220
|
checksum_handoff_func_type_(kCRC32c),
|
|
214
221
|
fail_get_file_unique_id_(false) {}
|
|
215
|
-
virtual ~FaultInjectionTestFS() {
|
|
222
|
+
virtual ~FaultInjectionTestFS() override { fs_error_.PermitUncheckedError(); }
|
|
216
223
|
|
|
217
224
|
static const char* kClassName() { return "FaultInjectionTestFS"; }
|
|
218
225
|
const char* Name() const override { return kClassName(); }
|
|
@@ -221,6 +228,18 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
221
228
|
std::unique_ptr<FSDirectory>* result,
|
|
222
229
|
IODebugContext* dbg) override;
|
|
223
230
|
|
|
231
|
+
IOStatus FileExists(const std::string& fname, const IOOptions& options,
|
|
232
|
+
IODebugContext* dbg) override;
|
|
233
|
+
|
|
234
|
+
IOStatus GetChildren(const std::string& dir, const IOOptions& options,
|
|
235
|
+
std::vector<std::string>* result,
|
|
236
|
+
IODebugContext* dbg) override;
|
|
237
|
+
|
|
238
|
+
IOStatus GetChildrenFileAttributes(const std::string& dir,
|
|
239
|
+
const IOOptions& options,
|
|
240
|
+
std::vector<FileAttributes>* result,
|
|
241
|
+
IODebugContext* dbg) override;
|
|
242
|
+
|
|
224
243
|
IOStatus NewWritableFile(const std::string& fname,
|
|
225
244
|
const FileOptions& file_opts,
|
|
226
245
|
std::unique_ptr<FSWritableFile>* result,
|
|
@@ -253,26 +272,51 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
253
272
|
IOStatus DeleteFile(const std::string& f, const IOOptions& options,
|
|
254
273
|
IODebugContext* dbg) override;
|
|
255
274
|
|
|
275
|
+
IOStatus GetFileSize(const std::string& f, const IOOptions& options,
|
|
276
|
+
uint64_t* file_size, IODebugContext* dbg) override;
|
|
277
|
+
|
|
278
|
+
IOStatus GetFileModificationTime(const std::string& fname,
|
|
279
|
+
const IOOptions& options,
|
|
280
|
+
uint64_t* file_mtime,
|
|
281
|
+
IODebugContext* dbg) override;
|
|
282
|
+
|
|
256
283
|
IOStatus RenameFile(const std::string& s, const std::string& t,
|
|
257
284
|
const IOOptions& options, IODebugContext* dbg) override;
|
|
258
285
|
|
|
259
286
|
IOStatus LinkFile(const std::string& src, const std::string& target,
|
|
260
287
|
const IOOptions& options, IODebugContext* dbg) override;
|
|
261
288
|
|
|
289
|
+
IOStatus NumFileLinks(const std::string& fname, const IOOptions& options,
|
|
290
|
+
uint64_t* count, IODebugContext* dbg) override;
|
|
291
|
+
|
|
292
|
+
IOStatus AreFilesSame(const std::string& first, const std::string& second,
|
|
293
|
+
const IOOptions& options, bool* res,
|
|
294
|
+
IODebugContext* dbg) override;
|
|
295
|
+
IOStatus GetAbsolutePath(const std::string& db_path, const IOOptions& options,
|
|
296
|
+
std::string* output_path,
|
|
297
|
+
IODebugContext* dbg) override;
|
|
298
|
+
|
|
262
299
|
// Undef to eliminate clash on Windows
|
|
263
300
|
#undef GetFreeSpace
|
|
264
301
|
IOStatus GetFreeSpace(const std::string& path, const IOOptions& options,
|
|
265
302
|
uint64_t* disk_free, IODebugContext* dbg) override {
|
|
266
303
|
IOStatus io_s;
|
|
267
304
|
if (!IsFilesystemActive() &&
|
|
268
|
-
|
|
305
|
+
fs_error_.subcode() == IOStatus::SubCode::kNoSpace) {
|
|
269
306
|
*disk_free = 0;
|
|
270
307
|
} else {
|
|
271
|
-
io_s =
|
|
308
|
+
io_s = MaybeInjectThreadLocalError(FaultInjectionIOType::kMetadataRead,
|
|
309
|
+
options);
|
|
310
|
+
if (io_s.ok()) {
|
|
311
|
+
io_s = target()->GetFreeSpace(path, options, disk_free, dbg);
|
|
312
|
+
}
|
|
272
313
|
}
|
|
273
314
|
return io_s;
|
|
274
315
|
}
|
|
275
316
|
|
|
317
|
+
IOStatus IsDirectory(const std::string& path, const IOOptions& options,
|
|
318
|
+
bool* is_dir, IODebugContext* dgb) override;
|
|
319
|
+
|
|
276
320
|
IOStatus Poll(std::vector<void*>& io_handles,
|
|
277
321
|
size_t min_completions) override;
|
|
278
322
|
|
|
@@ -316,25 +360,12 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
316
360
|
MutexLock l(&mutex_);
|
|
317
361
|
return filesystem_writable_;
|
|
318
362
|
}
|
|
319
|
-
bool ShouldUseDiretWritable(const std::string& file_name) {
|
|
320
|
-
MutexLock l(&mutex_);
|
|
321
|
-
if (filesystem_writable_) {
|
|
322
|
-
return true;
|
|
323
|
-
}
|
|
324
|
-
FileType file_type = kTempFile;
|
|
325
|
-
uint64_t file_number = 0;
|
|
326
|
-
if (!TryParseFileName(file_name, &file_number, &file_type)) {
|
|
327
|
-
return false;
|
|
328
|
-
}
|
|
329
|
-
return direct_writable_types_.find(file_type) !=
|
|
330
|
-
direct_writable_types_.end();
|
|
331
|
-
}
|
|
332
363
|
void SetFilesystemActiveNoLock(
|
|
333
364
|
bool active, IOStatus error = IOStatus::Corruption("Not active")) {
|
|
334
365
|
error.PermitUncheckedError();
|
|
335
366
|
filesystem_active_ = active;
|
|
336
367
|
if (!active) {
|
|
337
|
-
|
|
368
|
+
fs_error_ = error;
|
|
338
369
|
}
|
|
339
370
|
}
|
|
340
371
|
void SetFilesystemActive(
|
|
@@ -347,14 +378,56 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
347
378
|
MutexLock l(&mutex_);
|
|
348
379
|
filesystem_writable_ = writable;
|
|
349
380
|
}
|
|
381
|
+
|
|
382
|
+
// If true, we buffer write data in memory to simulate data loss upon system
|
|
383
|
+
// crash by only having process crashes
|
|
384
|
+
void SetInjectUnsyncedDataLoss(bool inject) {
|
|
385
|
+
MutexLock l(&mutex_);
|
|
386
|
+
inject_unsynced_data_loss_ = inject;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
bool InjectUnsyncedDataLoss() {
|
|
390
|
+
MutexLock l(&mutex_);
|
|
391
|
+
return inject_unsynced_data_loss_;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// In places (e.g. GetSortedWals()) RocksDB relies on querying the file size
|
|
395
|
+
// or even reading the contents of files currently open for writing, and
|
|
396
|
+
// as in POSIX semantics, expects to see the flushed size and contents
|
|
397
|
+
// regardless of what has been synced. FaultInjectionTestFS historically
|
|
398
|
+
// did not emulate this behavior, only showing synced data from such read
|
|
399
|
+
// operations. (Different from FaultInjectionTestEnv--sigh.) Calling this
|
|
400
|
+
// function with false restores this historical behavior for testing
|
|
401
|
+
// stability, but use of this semantics must be phased out as it is
|
|
402
|
+
// inconsistent with expected FileSystem semantics. In other words, this
|
|
403
|
+
// functionality is DEPRECATED. Intended to be set after construction and
|
|
404
|
+
// unchanged (not thread safe).
|
|
405
|
+
void SetReadUnsyncedData(bool read_unsynced_data) {
|
|
406
|
+
read_unsynced_data_ = read_unsynced_data;
|
|
407
|
+
}
|
|
408
|
+
bool ReadUnsyncedData() const { return read_unsynced_data_; }
|
|
409
|
+
|
|
410
|
+
// FaultInjectionTestFS normally includes a hygiene check for FileSystem
|
|
411
|
+
// implementations that only support LinkFile() on closed files (not open
|
|
412
|
+
// for write). Setting this to true bypasses the check.
|
|
413
|
+
void SetAllowLinkOpenFile(bool allow_link_open_file = true) {
|
|
414
|
+
allow_link_open_file_ = allow_link_open_file;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
bool ShouldIOActivtiesExcludedFromFaultInjection(Env::IOActivity io_activty) {
|
|
418
|
+
MutexLock l(&mutex_);
|
|
419
|
+
return io_activties_excluded_from_fault_injection.find(io_activty) !=
|
|
420
|
+
io_activties_excluded_from_fault_injection.end();
|
|
421
|
+
}
|
|
422
|
+
|
|
350
423
|
void AssertNoOpenFile() { assert(open_managed_files_.empty()); }
|
|
351
424
|
|
|
352
|
-
IOStatus GetError() { return
|
|
425
|
+
IOStatus GetError() { return fs_error_; }
|
|
353
426
|
|
|
354
427
|
void SetFileSystemIOError(IOStatus io_error) {
|
|
355
428
|
MutexLock l(&mutex_);
|
|
356
429
|
io_error.PermitUncheckedError();
|
|
357
|
-
|
|
430
|
+
fs_error_ = io_error;
|
|
358
431
|
}
|
|
359
432
|
|
|
360
433
|
// To simulate the data corruption before data is written in FS
|
|
@@ -399,23 +472,19 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
399
472
|
kMultiReadSingleReq = 1,
|
|
400
473
|
kMultiRead = 2,
|
|
401
474
|
kOpen,
|
|
475
|
+
kUnknown,
|
|
402
476
|
};
|
|
403
477
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
thread_local_error_->Reset(ctx);
|
|
415
|
-
}
|
|
416
|
-
ctx->one_in = one_in;
|
|
417
|
-
ctx->count = 0;
|
|
418
|
-
ctx->retryable = retryable;
|
|
478
|
+
void SetThreadLocalErrorContext(FaultInjectionIOType type, uint32_t seed,
|
|
479
|
+
int one_in, bool retryable,
|
|
480
|
+
bool has_data_loss) {
|
|
481
|
+
struct ErrorContext* new_ctx = new ErrorContext(seed);
|
|
482
|
+
new_ctx->one_in = one_in;
|
|
483
|
+
new_ctx->count = 0;
|
|
484
|
+
new_ctx->retryable = retryable;
|
|
485
|
+
new_ctx->has_data_loss = has_data_loss;
|
|
486
|
+
|
|
487
|
+
SetErrorContextOfFaultInjectionIOType(type, new_ctx);
|
|
419
488
|
}
|
|
420
489
|
|
|
421
490
|
static void DeleteThreadLocalErrorContext(void* p) {
|
|
@@ -423,112 +492,69 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
423
492
|
delete ctx;
|
|
424
493
|
}
|
|
425
494
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
// error (e.g., Wal files, SST files), which is empty by default.
|
|
432
|
-
void SetRandomWriteError(uint32_t seed, int one_in, IOStatus error,
|
|
433
|
-
bool inject_for_all_file_types,
|
|
434
|
-
const std::vector<FileType>& types) {
|
|
435
|
-
MutexLock l(&mutex_);
|
|
436
|
-
Random tmp_rand(seed);
|
|
437
|
-
error.PermitUncheckedError();
|
|
438
|
-
error_ = error;
|
|
439
|
-
write_error_rand_ = tmp_rand;
|
|
440
|
-
write_error_one_in_ = one_in;
|
|
441
|
-
inject_for_all_file_types_ = inject_for_all_file_types;
|
|
442
|
-
write_error_allowed_types_ = types;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
void SetDirectWritableTypes(const std::set<FileType>& types) {
|
|
446
|
-
MutexLock l(&mutex_);
|
|
447
|
-
direct_writable_types_ = types;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
void SetRandomMetadataWriteError(int one_in) {
|
|
451
|
-
MutexLock l(&mutex_);
|
|
452
|
-
metadata_write_error_one_in_ = one_in;
|
|
453
|
-
}
|
|
454
|
-
// If the value is not 0, it is enabled. Otherwise, it is disabled.
|
|
455
|
-
void SetRandomReadError(int one_in) { read_error_one_in_ = one_in; }
|
|
456
|
-
|
|
457
|
-
bool ShouldInjectRandomReadError() {
|
|
458
|
-
auto one_in = read_error_one_in();
|
|
459
|
-
return one_in > 0 && Random::GetTLSInstance()->OneIn(one_in);
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
// Inject an write error with randomlized parameter and the predefined
|
|
463
|
-
// error type. Only the allowed file types will inject the write error
|
|
464
|
-
IOStatus InjectWriteError(const std::string& file_name);
|
|
465
|
-
|
|
466
|
-
// Ingest error to metadata operations.
|
|
467
|
-
IOStatus InjectMetadataWriteError();
|
|
495
|
+
IOStatus MaybeInjectThreadLocalError(
|
|
496
|
+
FaultInjectionIOType type, const IOOptions& io_options,
|
|
497
|
+
const std::string& file_name = "", ErrorOperation op = kUnknown,
|
|
498
|
+
Slice* slice = nullptr, bool direct_io = false, char* scratch = nullptr,
|
|
499
|
+
bool need_count_increase = false, bool* fault_injected = nullptr);
|
|
468
500
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
// are the types of error with equal probability. For OPEN,
|
|
472
|
-
// its always an IOError.
|
|
473
|
-
// fault_injected returns whether a fault is injected. It is needed
|
|
474
|
-
// because some fault is inected with IOStatus to be OK.
|
|
475
|
-
IOStatus InjectThreadSpecificReadError(ErrorOperation op, Slice* slice,
|
|
476
|
-
bool direct_io, char* scratch,
|
|
477
|
-
bool need_count_increase,
|
|
478
|
-
bool* fault_injected);
|
|
479
|
-
|
|
480
|
-
// Get the count of how many times we injected since the previous call
|
|
481
|
-
int GetAndResetErrorCount() {
|
|
482
|
-
ErrorContext* ctx = static_cast<ErrorContext*>(thread_local_error_->Get());
|
|
501
|
+
int GetAndResetInjectedThreadLocalErrorCount(FaultInjectionIOType type) {
|
|
502
|
+
ErrorContext* ctx = GetErrorContextFromFaultInjectionIOType(type);
|
|
483
503
|
int count = 0;
|
|
484
|
-
if (ctx
|
|
504
|
+
if (ctx) {
|
|
485
505
|
count = ctx->count;
|
|
486
506
|
ctx->count = 0;
|
|
487
507
|
}
|
|
488
508
|
return count;
|
|
489
509
|
}
|
|
490
510
|
|
|
491
|
-
void
|
|
492
|
-
|
|
493
|
-
if (ctx) {
|
|
494
|
-
ctx->enable_error_injection = true;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
void EnableWriteErrorInjection() {
|
|
511
|
+
void SetIOActivtiesExcludedFromFaultInjection(
|
|
512
|
+
const std::set<Env::IOActivity>& io_activties) {
|
|
499
513
|
MutexLock l(&mutex_);
|
|
500
|
-
|
|
514
|
+
io_activties_excluded_from_fault_injection = io_activties;
|
|
501
515
|
}
|
|
502
|
-
|
|
516
|
+
|
|
517
|
+
void SetFileTypesExcludedFromWriteFaultInjection(
|
|
518
|
+
const std::set<FileType>& types) {
|
|
503
519
|
MutexLock l(&mutex_);
|
|
504
|
-
|
|
520
|
+
file_types_excluded_from_write_fault_injection_ = types;
|
|
505
521
|
}
|
|
506
522
|
|
|
507
|
-
|
|
523
|
+
bool ShouldExcludeFromWriteFaultInjection(const std::string& file_name) {
|
|
508
524
|
MutexLock l(&mutex_);
|
|
509
|
-
|
|
525
|
+
FileType file_type = kTempFile;
|
|
526
|
+
uint64_t file_number = 0;
|
|
527
|
+
if (!TryParseFileName(file_name, &file_number, &file_type)) {
|
|
528
|
+
return false;
|
|
529
|
+
}
|
|
530
|
+
return file_types_excluded_from_write_fault_injection_.find(file_type) !=
|
|
531
|
+
file_types_excluded_from_write_fault_injection_.end();
|
|
510
532
|
}
|
|
511
533
|
|
|
512
|
-
void
|
|
513
|
-
ErrorContext* ctx =
|
|
534
|
+
void EnableThreadLocalErrorInjection(FaultInjectionIOType type) {
|
|
535
|
+
ErrorContext* ctx = GetErrorContextFromFaultInjectionIOType(type);
|
|
514
536
|
if (ctx) {
|
|
515
|
-
ctx->enable_error_injection =
|
|
537
|
+
ctx->enable_error_injection = true;
|
|
516
538
|
}
|
|
517
539
|
}
|
|
518
540
|
|
|
519
|
-
void
|
|
520
|
-
|
|
521
|
-
|
|
541
|
+
void DisableThreadLocalErrorInjection(FaultInjectionIOType type) {
|
|
542
|
+
ErrorContext* ctx = GetErrorContextFromFaultInjectionIOType(type);
|
|
543
|
+
if (ctx) {
|
|
544
|
+
ctx->enable_error_injection = false;
|
|
545
|
+
}
|
|
522
546
|
}
|
|
523
547
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
int write_error_one_in() const { return write_error_one_in_; }
|
|
548
|
+
void PrintInjectedThreadLocalErrorBacktrace(FaultInjectionIOType type);
|
|
527
549
|
|
|
528
|
-
//
|
|
529
|
-
//
|
|
530
|
-
//
|
|
531
|
-
|
|
550
|
+
// If there is unsynced data in the specified file within the specified
|
|
551
|
+
// range [offset, offset + n), return the unsynced data overlapping with
|
|
552
|
+
// that range, in a corresponding range of scratch. When known, also return
|
|
553
|
+
// the position of the last sync, so that the caller can determine whether
|
|
554
|
+
// more data is available from the target file when not available from
|
|
555
|
+
// unsynced.
|
|
556
|
+
void ReadUnsynced(const std::string& fname, uint64_t offset, size_t n,
|
|
557
|
+
Slice* result, char* scratch, int64_t* pos_at_last_sync);
|
|
532
558
|
|
|
533
559
|
private:
|
|
534
560
|
port::Mutex mutex_;
|
|
@@ -543,7 +569,10 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
543
569
|
bool filesystem_active_; // Record flushes, syncs, writes
|
|
544
570
|
bool filesystem_writable_; // Bypass FaultInjectionTestFS and go directly
|
|
545
571
|
// to underlying FS for writable files
|
|
546
|
-
|
|
572
|
+
bool inject_unsynced_data_loss_; // See InjectUnsyncedDataLoss()
|
|
573
|
+
bool read_unsynced_data_; // See SetReadUnsyncedData()
|
|
574
|
+
bool allow_link_open_file_; // See SetAllowLinkOpenFile()
|
|
575
|
+
IOStatus fs_error_;
|
|
547
576
|
|
|
548
577
|
enum ErrorType : int {
|
|
549
578
|
kErrorTypeStatus = 0,
|
|
@@ -562,13 +591,15 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
562
591
|
int frames;
|
|
563
592
|
ErrorType type;
|
|
564
593
|
bool retryable;
|
|
594
|
+
bool has_data_loss;
|
|
565
595
|
|
|
566
596
|
explicit ErrorContext(uint32_t seed)
|
|
567
597
|
: rand(seed),
|
|
568
598
|
enable_error_injection(false),
|
|
569
599
|
callstack(nullptr),
|
|
570
600
|
frames(0),
|
|
571
|
-
retryable(false)
|
|
601
|
+
retryable(false),
|
|
602
|
+
has_data_loss(false) {}
|
|
572
603
|
~ErrorContext() {
|
|
573
604
|
if (callstack) {
|
|
574
605
|
free(callstack);
|
|
@@ -576,25 +607,111 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
576
607
|
}
|
|
577
608
|
};
|
|
578
609
|
|
|
579
|
-
std::
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
std::atomic<int> read_error_one_in_;
|
|
586
|
-
bool inject_for_all_file_types_;
|
|
587
|
-
std::vector<FileType> write_error_allowed_types_;
|
|
588
|
-
// File types where direct writable is skipped.
|
|
589
|
-
std::set<FileType> direct_writable_types_;
|
|
610
|
+
std::set<FileType> file_types_excluded_from_write_fault_injection_;
|
|
611
|
+
std::set<Env::IOActivity> io_activties_excluded_from_fault_injection;
|
|
612
|
+
ThreadLocalPtr injected_thread_local_read_error_;
|
|
613
|
+
ThreadLocalPtr injected_thread_local_write_error_;
|
|
614
|
+
ThreadLocalPtr injected_thread_local_metadata_read_error_;
|
|
615
|
+
ThreadLocalPtr injected_thread_local_metadata_write_error_;
|
|
590
616
|
bool ingest_data_corruption_before_write_;
|
|
591
617
|
ChecksumType checksum_handoff_func_type_;
|
|
592
618
|
bool fail_get_file_unique_id_;
|
|
593
619
|
|
|
620
|
+
// Inject an error. For a READ operation, a status of IOError(), a
|
|
621
|
+
// corruption in the contents of scratch, or truncation of slice
|
|
622
|
+
// are the types of error with equal probability. For OPEN,
|
|
623
|
+
// its always an IOError.
|
|
624
|
+
// fault_injected returns whether a fault is injected. It is needed
|
|
625
|
+
// because some fault is inected with IOStatus to be OK.
|
|
626
|
+
IOStatus MaybeInjectThreadLocalReadError(const IOOptions& io_options,
|
|
627
|
+
ErrorOperation op, Slice* slice,
|
|
628
|
+
bool direct_io, char* scratch,
|
|
629
|
+
bool need_count_increase,
|
|
630
|
+
bool* fault_injected);
|
|
594
631
|
// Extract number of type from file name. Return false if failing to fine
|
|
595
632
|
// them.
|
|
596
633
|
bool TryParseFileName(const std::string& file_name, uint64_t* number,
|
|
597
634
|
FileType* type);
|
|
635
|
+
|
|
636
|
+
ErrorContext* GetErrorContextFromFaultInjectionIOType(
|
|
637
|
+
FaultInjectionIOType type) {
|
|
638
|
+
ErrorContext* ctx = nullptr;
|
|
639
|
+
switch (type) {
|
|
640
|
+
case FaultInjectionIOType::kRead:
|
|
641
|
+
ctx = static_cast<struct ErrorContext*>(
|
|
642
|
+
injected_thread_local_read_error_.Get());
|
|
643
|
+
break;
|
|
644
|
+
case FaultInjectionIOType::kWrite:
|
|
645
|
+
ctx = static_cast<struct ErrorContext*>(
|
|
646
|
+
injected_thread_local_write_error_.Get());
|
|
647
|
+
break;
|
|
648
|
+
case FaultInjectionIOType::kMetadataRead:
|
|
649
|
+
ctx = static_cast<struct ErrorContext*>(
|
|
650
|
+
injected_thread_local_metadata_read_error_.Get());
|
|
651
|
+
break;
|
|
652
|
+
case FaultInjectionIOType::kMetadataWrite:
|
|
653
|
+
ctx = static_cast<struct ErrorContext*>(
|
|
654
|
+
injected_thread_local_metadata_write_error_.Get());
|
|
655
|
+
break;
|
|
656
|
+
default:
|
|
657
|
+
assert(false);
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
return ctx;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
void SetErrorContextOfFaultInjectionIOType(FaultInjectionIOType type,
|
|
664
|
+
ErrorContext* new_ctx) {
|
|
665
|
+
ErrorContext* old_ctx = nullptr;
|
|
666
|
+
switch (type) {
|
|
667
|
+
case FaultInjectionIOType::kRead:
|
|
668
|
+
old_ctx = static_cast<struct ErrorContext*>(
|
|
669
|
+
injected_thread_local_read_error_.Swap(new_ctx));
|
|
670
|
+
break;
|
|
671
|
+
case FaultInjectionIOType::kWrite:
|
|
672
|
+
old_ctx = static_cast<struct ErrorContext*>(
|
|
673
|
+
injected_thread_local_write_error_.Swap(new_ctx));
|
|
674
|
+
break;
|
|
675
|
+
case FaultInjectionIOType::kMetadataRead:
|
|
676
|
+
old_ctx = static_cast<struct ErrorContext*>(
|
|
677
|
+
injected_thread_local_metadata_read_error_.Swap(new_ctx));
|
|
678
|
+
break;
|
|
679
|
+
case FaultInjectionIOType::kMetadataWrite:
|
|
680
|
+
old_ctx = static_cast<struct ErrorContext*>(
|
|
681
|
+
injected_thread_local_metadata_write_error_.Swap(new_ctx));
|
|
682
|
+
break;
|
|
683
|
+
default:
|
|
684
|
+
assert(false);
|
|
685
|
+
break;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
if (old_ctx) {
|
|
689
|
+
DeleteThreadLocalErrorContext(old_ctx);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
std::string GetErrorMessageFromFaultInjectionIOType(
|
|
694
|
+
FaultInjectionIOType type) {
|
|
695
|
+
std::string msg = "";
|
|
696
|
+
switch (type) {
|
|
697
|
+
case FaultInjectionIOType::kRead:
|
|
698
|
+
msg = "injected read error";
|
|
699
|
+
break;
|
|
700
|
+
case FaultInjectionIOType::kWrite:
|
|
701
|
+
msg = "injected write error";
|
|
702
|
+
break;
|
|
703
|
+
case FaultInjectionIOType::kMetadataRead:
|
|
704
|
+
msg = "injected metadata read error";
|
|
705
|
+
break;
|
|
706
|
+
case FaultInjectionIOType::kMetadataWrite:
|
|
707
|
+
msg = "injected metadata write error";
|
|
708
|
+
break;
|
|
709
|
+
default:
|
|
710
|
+
assert(false);
|
|
711
|
+
break;
|
|
712
|
+
}
|
|
713
|
+
return msg;
|
|
714
|
+
}
|
|
598
715
|
};
|
|
599
716
|
|
|
600
717
|
} // namespace ROCKSDB_NAMESPACE
|