rocksdb-native 2.2.0 → 2.3.0
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.c +92 -10
- package/index.js +9 -0
- package/lib/batch.js +11 -1
- package/lib/iterator.js +3 -1
- package/lib/snapshot.js +21 -0
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/rocksdb-native.bare +0 -0
- package/prebuilds/darwin-arm64/rocksdb-native.node +0 -0
- package/prebuilds/darwin-x64/rocksdb-native.bare +0 -0
- package/prebuilds/darwin-x64/rocksdb-native.node +0 -0
- package/prebuilds/linux-arm64/rocksdb-native.bare +0 -0
- package/prebuilds/linux-arm64/rocksdb-native.node +0 -0
- package/prebuilds/linux-x64/rocksdb-native.bare +0 -0
- package/prebuilds/linux-x64/rocksdb-native.node +0 -0
- package/prebuilds/win32-x64/rocksdb-native.bare +0 -0
- package/prebuilds/win32-x64/rocksdb-native.node +0 -0
- package/vendor/librocksdb/include/rocksdb.h +38 -4
- package/vendor/librocksdb/src/rocksdb.cc +114 -14
- package/vendor/librocksdb/vendor/rocksdb/CMakeLists.txt +21 -4
- package/vendor/librocksdb/vendor/rocksdb/cache/secondary_cache_adapter.cc +6 -3
- package/vendor/librocksdb/vendor/rocksdb/db/arena_wrapped_db_iter.cc +4 -4
- package/vendor/librocksdb/vendor/rocksdb/db/arena_wrapped_db_iter.h +4 -2
- package/vendor/librocksdb/vendor/rocksdb/db/attribute_group_iterator_impl.cc +20 -0
- package/vendor/librocksdb/vendor/rocksdb/db/attribute_group_iterator_impl.h +83 -0
- package/vendor/librocksdb/vendor/rocksdb/db/builder.cc +9 -5
- package/vendor/librocksdb/vendor/rocksdb/db/builder.h +1 -1
- package/vendor/librocksdb/vendor/rocksdb/db/c.cc +231 -6
- package/vendor/librocksdb/vendor/rocksdb/db/c_test.c +202 -2
- package/vendor/librocksdb/vendor/rocksdb/db/coalescing_iterator.cc +47 -0
- package/vendor/librocksdb/vendor/rocksdb/db/coalescing_iterator.h +79 -0
- package/vendor/librocksdb/vendor/rocksdb/db/column_family.cc +28 -0
- package/vendor/librocksdb/vendor/rocksdb/db/column_family.h +17 -0
- package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction.cc +8 -1
- package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction.h +11 -9
- package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_iterator.cc +50 -23
- package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_iterator.h +13 -0
- package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_job.cc +22 -25
- package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_job.h +2 -0
- package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_outputs.cc +8 -1
- package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_outputs.h +1 -0
- package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker.cc +40 -17
- package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker.h +20 -14
- package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker_level.cc +11 -6
- package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker_universal.cc +77 -24
- package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_service_job.cc +2 -0
- package/vendor/librocksdb/vendor/rocksdb/db/convenience.cc +3 -0
- package/vendor/librocksdb/vendor/rocksdb/db/db_filesnapshot.cc +125 -31
- package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl.cc +457 -231
- package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl.h +172 -73
- package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_compaction_flush.cc +152 -133
- package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_debug.cc +5 -0
- package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_files.cc +58 -52
- package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_follower.cc +348 -0
- package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_follower.h +54 -0
- package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_open.cc +136 -117
- package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_secondary.cc +4 -3
- package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_secondary.h +7 -6
- package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_write.cc +134 -80
- package/vendor/librocksdb/vendor/rocksdb/db/db_iter.cc +11 -0
- package/vendor/librocksdb/vendor/rocksdb/db/db_test2.cc +1 -1
- package/vendor/librocksdb/vendor/rocksdb/db/db_test_util.cc +11 -1
- package/vendor/librocksdb/vendor/rocksdb/db/db_test_util.h +11 -7
- package/vendor/librocksdb/vendor/rocksdb/db/dbformat.cc +19 -4
- package/vendor/librocksdb/vendor/rocksdb/db/dbformat.h +3 -2
- package/vendor/librocksdb/vendor/rocksdb/db/error_handler.cc +34 -39
- package/vendor/librocksdb/vendor/rocksdb/db/error_handler.h +3 -4
- package/vendor/librocksdb/vendor/rocksdb/db/event_helpers.cc +6 -3
- package/vendor/librocksdb/vendor/rocksdb/db/experimental.cc +3 -2
- package/vendor/librocksdb/vendor/rocksdb/db/external_sst_file_ingestion_job.cc +76 -18
- package/vendor/librocksdb/vendor/rocksdb/db/external_sst_file_ingestion_job.h +11 -0
- package/vendor/librocksdb/vendor/rocksdb/db/flush_job.cc +37 -5
- package/vendor/librocksdb/vendor/rocksdb/db/flush_job.h +14 -0
- package/vendor/librocksdb/vendor/rocksdb/db/import_column_family_job.cc +49 -45
- package/vendor/librocksdb/vendor/rocksdb/db/internal_stats.cc +60 -1
- package/vendor/librocksdb/vendor/rocksdb/db/internal_stats.h +20 -1
- package/vendor/librocksdb/vendor/rocksdb/db/log_reader.cc +15 -6
- package/vendor/librocksdb/vendor/rocksdb/db/log_writer.cc +59 -10
- package/vendor/librocksdb/vendor/rocksdb/db/log_writer.h +8 -0
- package/vendor/librocksdb/vendor/rocksdb/db/memtable.cc +24 -40
- package/vendor/librocksdb/vendor/rocksdb/db/memtable.h +10 -10
- package/vendor/librocksdb/vendor/rocksdb/db/memtable_list.cc +9 -8
- package/vendor/librocksdb/vendor/rocksdb/db/multi_cf_iterator_impl.h +296 -0
- package/vendor/librocksdb/vendor/rocksdb/db/range_tombstone_fragmenter.h +8 -10
- package/vendor/librocksdb/vendor/rocksdb/db/repair.cc +4 -3
- package/vendor/librocksdb/vendor/rocksdb/db/seqno_to_time_mapping.cc +30 -0
- package/vendor/librocksdb/vendor/rocksdb/db/seqno_to_time_mapping.h +9 -0
- package/vendor/librocksdb/vendor/rocksdb/db/table_cache.cc +17 -2
- package/vendor/librocksdb/vendor/rocksdb/db/table_cache.h +9 -1
- package/vendor/librocksdb/vendor/rocksdb/db/table_properties_collector.h +9 -2
- package/vendor/librocksdb/vendor/rocksdb/db/transaction_log_impl.cc +3 -3
- package/vendor/librocksdb/vendor/rocksdb/db/transaction_log_impl.h +7 -7
- package/vendor/librocksdb/vendor/rocksdb/db/version_edit.cc +0 -1
- package/vendor/librocksdb/vendor/rocksdb/db/version_edit_handler.cc +39 -5
- package/vendor/librocksdb/vendor/rocksdb/db/version_edit_handler.h +24 -15
- package/vendor/librocksdb/vendor/rocksdb/db/version_set.cc +117 -64
- package/vendor/librocksdb/vendor/rocksdb/db/version_set.h +27 -10
- package/vendor/librocksdb/vendor/rocksdb/db/wal_manager.cc +37 -29
- package/vendor/librocksdb/vendor/rocksdb/db/wal_manager.h +6 -5
- package/vendor/librocksdb/vendor/rocksdb/db/wide/wide_columns.cc +2 -3
- package/vendor/librocksdb/vendor/rocksdb/db/wide/wide_columns_helper.cc +6 -0
- package/vendor/librocksdb/vendor/rocksdb/db/write_batch.cc +89 -31
- package/vendor/librocksdb/vendor/rocksdb/db/write_thread.cc +53 -5
- package/vendor/librocksdb/vendor/rocksdb/db/write_thread.h +36 -4
- package/vendor/librocksdb/vendor/rocksdb/env/composite_env_wrapper.h +21 -0
- package/vendor/librocksdb/vendor/rocksdb/env/env.cc +15 -0
- package/vendor/librocksdb/vendor/rocksdb/env/fs_on_demand.cc +331 -0
- package/vendor/librocksdb/vendor/rocksdb/env/fs_on_demand.h +139 -0
- package/vendor/librocksdb/vendor/rocksdb/env/io_posix.cc +8 -6
- package/vendor/librocksdb/vendor/rocksdb/env/io_posix.h +1 -1
- package/vendor/librocksdb/vendor/rocksdb/file/delete_scheduler.cc +130 -27
- package/vendor/librocksdb/vendor/rocksdb/file/delete_scheduler.h +61 -8
- package/vendor/librocksdb/vendor/rocksdb/file/file_util.cc +25 -4
- package/vendor/librocksdb/vendor/rocksdb/file/file_util.h +15 -0
- package/vendor/librocksdb/vendor/rocksdb/file/sequence_file_reader.cc +1 -0
- package/vendor/librocksdb/vendor/rocksdb/file/sequence_file_reader.h +9 -4
- package/vendor/librocksdb/vendor/rocksdb/file/sst_file_manager_impl.cc +18 -0
- package/vendor/librocksdb/vendor/rocksdb/file/sst_file_manager_impl.h +31 -4
- package/vendor/librocksdb/vendor/rocksdb/file/writable_file_writer.cc +40 -38
- package/vendor/librocksdb/vendor/rocksdb/file/writable_file_writer.h +48 -15
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/advanced_options.h +12 -3
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/attribute_groups.h +114 -0
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/c.h +90 -0
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/cache.h +5 -0
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/comparator.h +27 -0
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/db.h +71 -12
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/env.h +9 -0
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/experimental.h +5 -0
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/file_system.h +14 -0
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/iterator.h +9 -71
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/iterator_base.h +90 -0
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/listener.h +21 -0
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/options.h +125 -12
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/perf_context.h +1 -1
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/sst_file_reader.h +11 -1
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/table.h +6 -6
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/table_properties.h +19 -0
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/transaction_log.h +12 -6
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/types.h +12 -0
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/universal_compaction.h +31 -0
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/user_write_callback.h +29 -0
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/cache_dump_load.h +4 -0
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/checkpoint.h +4 -2
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/customizable_util.h +0 -1
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/env_mirror.h +1 -1
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/ldb_cmd.h +24 -7
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/option_change_migration.h +4 -4
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/stackable_db.h +24 -5
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/table_properties_collectors.h +46 -0
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/transaction.h +42 -17
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/transaction_db.h +5 -0
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/types_util.h +36 -0
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/write_batch_with_index.h +71 -3
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/version.h +2 -2
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/wide_columns.h +87 -72
- package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/write_batch_base.h +1 -1
- package/vendor/librocksdb/vendor/rocksdb/memory/memory_allocator.cc +1 -0
- package/vendor/librocksdb/vendor/rocksdb/options/cf_options.cc +13 -2
- package/vendor/librocksdb/vendor/rocksdb/options/cf_options.h +6 -2
- package/vendor/librocksdb/vendor/rocksdb/options/db_options.cc +27 -1
- package/vendor/librocksdb/vendor/rocksdb/options/db_options.h +10 -3
- package/vendor/librocksdb/vendor/rocksdb/options/options.cc +3 -0
- package/vendor/librocksdb/vendor/rocksdb/options/options_helper.cc +1 -0
- package/vendor/librocksdb/vendor/rocksdb/port/jemalloc_helper.h +2 -2
- package/vendor/librocksdb/vendor/rocksdb/port/stack_trace.cc +1 -0
- package/vendor/librocksdb/vendor/rocksdb/port/win/port_win.cc +3 -2
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/binary_search_index_reader.cc +1 -2
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_builder.cc +47 -31
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_factory.cc +15 -0
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_iterator.cc +37 -18
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_iterator.h +10 -3
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader.cc +102 -41
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader.h +15 -7
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader_impl.h +1 -3
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +5 -6
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_cache.h +31 -0
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_prefetcher.cc +6 -0
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/cachable_entry.h +10 -5
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_block.h +34 -28
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_block_reader_common.cc +17 -11
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_block_reader_common.h +5 -2
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_policy.cc +12 -3
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/full_filter_block.cc +37 -30
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/full_filter_block.h +11 -13
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/hash_index_reader.cc +1 -2
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_builder.cc +62 -53
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_builder.h +60 -38
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_reader_common.cc +14 -9
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_reader_common.h +4 -1
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_filter_block.cc +135 -94
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_filter_block.h +52 -46
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_index_reader.cc +51 -13
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_index_reader.h +2 -0
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/uncompression_dict_reader.cc +3 -11
- package/vendor/librocksdb/vendor/rocksdb/table/block_based/uncompression_dict_reader.h +2 -3
- package/vendor/librocksdb/vendor/rocksdb/table/block_fetcher.cc +8 -10
- package/vendor/librocksdb/vendor/rocksdb/table/block_fetcher.h +2 -1
- package/vendor/librocksdb/vendor/rocksdb/table/compaction_merging_iterator.cc +9 -10
- package/vendor/librocksdb/vendor/rocksdb/table/compaction_merging_iterator.h +3 -2
- package/vendor/librocksdb/vendor/rocksdb/table/format.cc +1 -2
- package/vendor/librocksdb/vendor/rocksdb/table/iterator.cc +4 -0
- package/vendor/librocksdb/vendor/rocksdb/table/merging_iterator.cc +18 -13
- package/vendor/librocksdb/vendor/rocksdb/table/merging_iterator.h +5 -3
- package/vendor/librocksdb/vendor/rocksdb/table/meta_blocks.cc +18 -4
- package/vendor/librocksdb/vendor/rocksdb/table/meta_blocks.h +4 -0
- package/vendor/librocksdb/vendor/rocksdb/table/plain/plain_table_builder.cc +2 -2
- package/vendor/librocksdb/vendor/rocksdb/table/sst_file_dumper.cc +6 -6
- package/vendor/librocksdb/vendor/rocksdb/table/sst_file_reader.cc +24 -2
- package/vendor/librocksdb/vendor/rocksdb/table/sst_file_writer_collectors.h +3 -1
- package/vendor/librocksdb/vendor/rocksdb/table/table_builder.h +8 -7
- package/vendor/librocksdb/vendor/rocksdb/table/table_iterator.h +69 -0
- package/vendor/librocksdb/vendor/rocksdb/table/table_reader.h +9 -0
- package/vendor/librocksdb/vendor/rocksdb/test_util/testutil.cc +25 -0
- package/vendor/librocksdb/vendor/rocksdb/test_util/testutil.h +12 -0
- package/vendor/librocksdb/vendor/rocksdb/tools/db_bench_tool.cc +32 -0
- package/vendor/librocksdb/vendor/rocksdb/tools/ldb_cmd.cc +618 -124
- package/vendor/librocksdb/vendor/rocksdb/tools/ldb_cmd_impl.h +19 -1
- package/vendor/librocksdb/vendor/rocksdb/tools/ldb_tool.cc +9 -0
- package/vendor/librocksdb/vendor/rocksdb/util/aligned_storage.h +24 -0
- package/vendor/librocksdb/vendor/rocksdb/util/autovector.h +4 -0
- package/vendor/librocksdb/vendor/rocksdb/util/comparator.cc +12 -0
- package/vendor/librocksdb/vendor/rocksdb/util/filter_bench.cc +1 -1
- package/vendor/librocksdb/vendor/rocksdb/util/random.cc +2 -1
- package/vendor/librocksdb/vendor/rocksdb/util/stderr_logger.cc +3 -4
- package/vendor/librocksdb/vendor/rocksdb/util/stderr_logger.h +1 -1
- package/vendor/librocksdb/vendor/rocksdb/util/udt_util.cc +33 -0
- package/vendor/librocksdb/vendor/rocksdb/util/udt_util.h +7 -0
- package/vendor/librocksdb/vendor/rocksdb/util/write_batch_util.h +5 -0
- package/vendor/librocksdb/vendor/rocksdb/util/xxhash.h +36 -29
- package/vendor/librocksdb/vendor/rocksdb/utilities/blob_db/blob_db_impl.h +3 -0
- package/vendor/librocksdb/vendor/rocksdb/utilities/blob_db/blob_db_impl_filesnapshot.cc +20 -0
- package/vendor/librocksdb/vendor/rocksdb/utilities/cache_dump_load_impl.cc +29 -9
- package/vendor/librocksdb/vendor/rocksdb/utilities/cache_dump_load_impl.h +14 -3
- package/vendor/librocksdb/vendor/rocksdb/utilities/debug.cc +16 -4
- package/vendor/librocksdb/vendor/rocksdb/utilities/fault_injection_fs.cc +677 -248
- package/vendor/librocksdb/vendor/rocksdb/utilities/fault_injection_fs.h +325 -158
- package/vendor/librocksdb/vendor/rocksdb/utilities/option_change_migration/option_change_migration.cc +1 -8
- package/vendor/librocksdb/vendor/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.cc +144 -0
- package/vendor/librocksdb/vendor/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.h +45 -0
- package/vendor/librocksdb/vendor/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.cc +12 -0
- package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h +1 -1
- package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/growable_array.h +3 -3
- package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction.cc +116 -20
- package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction.h +33 -1
- package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction_db.cc +78 -13
- package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction_db.h +33 -1
- package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_base.cc +106 -7
- package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_base.h +68 -10
- package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_test.h +7 -3
- package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_util.cc +8 -5
- package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_util.h +7 -4
- package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_prepared_txn.cc +18 -12
- package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_prepared_txn_db.cc +4 -4
- package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_prepared_txn_db.h +17 -0
- package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_unprepared_txn.cc +11 -9
- package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_unprepared_txn_db.cc +2 -1
- package/vendor/librocksdb/vendor/rocksdb/utilities/types_util.cc +88 -0
- package/vendor/librocksdb/vendor/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc +313 -14
- package/vendor/librocksdb/vendor/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc +7 -0
- package/vendor/librocksdb/vendor/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h +1 -1
- package/vendor/librocksdb/vendor/rocksdb/db/multi_cf_iterator.cc +0 -102
- package/vendor/librocksdb/vendor/rocksdb/db/multi_cf_iterator.h +0 -159
|
@@ -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) {}
|
|
48
|
+
explicit FSFileState(const std::string& filename = {})
|
|
49
|
+
: filename_(filename) {}
|
|
47
50
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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,24 +207,49 @@ 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),
|
|
220
|
+
checksum_handoff_func_type_(kCRC32c),
|
|
213
221
|
fail_get_file_unique_id_(false) {}
|
|
214
|
-
virtual ~FaultInjectionTestFS() {
|
|
222
|
+
virtual ~FaultInjectionTestFS() override { fs_error_.PermitUncheckedError(); }
|
|
215
223
|
|
|
216
224
|
static const char* kClassName() { return "FaultInjectionTestFS"; }
|
|
217
225
|
const char* Name() const override { return kClassName(); }
|
|
218
226
|
|
|
227
|
+
static bool IsInjectedError(const Status& s) {
|
|
228
|
+
assert(!s.ok());
|
|
229
|
+
return std::strstr(s.getState(), kInjected.c_str());
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
static bool IsFailedToWriteToWALError(const Status& s) {
|
|
233
|
+
assert(!s.ok());
|
|
234
|
+
return std::strstr(s.getState(), kFailedToWriteToWAL.c_str());
|
|
235
|
+
}
|
|
236
|
+
|
|
219
237
|
IOStatus NewDirectory(const std::string& name, const IOOptions& options,
|
|
220
238
|
std::unique_ptr<FSDirectory>* result,
|
|
221
239
|
IODebugContext* dbg) override;
|
|
222
240
|
|
|
241
|
+
IOStatus FileExists(const std::string& fname, const IOOptions& options,
|
|
242
|
+
IODebugContext* dbg) override;
|
|
243
|
+
|
|
244
|
+
IOStatus GetChildren(const std::string& dir, const IOOptions& options,
|
|
245
|
+
std::vector<std::string>* result,
|
|
246
|
+
IODebugContext* dbg) override;
|
|
247
|
+
|
|
248
|
+
IOStatus GetChildrenFileAttributes(const std::string& dir,
|
|
249
|
+
const IOOptions& options,
|
|
250
|
+
std::vector<FileAttributes>* result,
|
|
251
|
+
IODebugContext* dbg) override;
|
|
252
|
+
|
|
223
253
|
IOStatus NewWritableFile(const std::string& fname,
|
|
224
254
|
const FileOptions& file_opts,
|
|
225
255
|
std::unique_ptr<FSWritableFile>* result,
|
|
@@ -230,6 +260,12 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
230
260
|
std::unique_ptr<FSWritableFile>* result,
|
|
231
261
|
IODebugContext* dbg) override;
|
|
232
262
|
|
|
263
|
+
IOStatus ReuseWritableFile(const std::string& fname,
|
|
264
|
+
const std::string& old_fname,
|
|
265
|
+
const FileOptions& file_opts,
|
|
266
|
+
std::unique_ptr<FSWritableFile>* result,
|
|
267
|
+
IODebugContext* dbg) override;
|
|
268
|
+
|
|
233
269
|
IOStatus NewRandomRWFile(const std::string& fname,
|
|
234
270
|
const FileOptions& file_opts,
|
|
235
271
|
std::unique_ptr<FSRandomRWFile>* result,
|
|
@@ -246,26 +282,51 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
246
282
|
IOStatus DeleteFile(const std::string& f, const IOOptions& options,
|
|
247
283
|
IODebugContext* dbg) override;
|
|
248
284
|
|
|
285
|
+
IOStatus GetFileSize(const std::string& f, const IOOptions& options,
|
|
286
|
+
uint64_t* file_size, IODebugContext* dbg) override;
|
|
287
|
+
|
|
288
|
+
IOStatus GetFileModificationTime(const std::string& fname,
|
|
289
|
+
const IOOptions& options,
|
|
290
|
+
uint64_t* file_mtime,
|
|
291
|
+
IODebugContext* dbg) override;
|
|
292
|
+
|
|
249
293
|
IOStatus RenameFile(const std::string& s, const std::string& t,
|
|
250
294
|
const IOOptions& options, IODebugContext* dbg) override;
|
|
251
295
|
|
|
252
296
|
IOStatus LinkFile(const std::string& src, const std::string& target,
|
|
253
297
|
const IOOptions& options, IODebugContext* dbg) override;
|
|
254
298
|
|
|
299
|
+
IOStatus NumFileLinks(const std::string& fname, const IOOptions& options,
|
|
300
|
+
uint64_t* count, IODebugContext* dbg) override;
|
|
301
|
+
|
|
302
|
+
IOStatus AreFilesSame(const std::string& first, const std::string& second,
|
|
303
|
+
const IOOptions& options, bool* res,
|
|
304
|
+
IODebugContext* dbg) override;
|
|
305
|
+
IOStatus GetAbsolutePath(const std::string& db_path, const IOOptions& options,
|
|
306
|
+
std::string* output_path,
|
|
307
|
+
IODebugContext* dbg) override;
|
|
308
|
+
|
|
255
309
|
// Undef to eliminate clash on Windows
|
|
256
310
|
#undef GetFreeSpace
|
|
257
311
|
IOStatus GetFreeSpace(const std::string& path, const IOOptions& options,
|
|
258
312
|
uint64_t* disk_free, IODebugContext* dbg) override {
|
|
259
313
|
IOStatus io_s;
|
|
260
314
|
if (!IsFilesystemActive() &&
|
|
261
|
-
|
|
315
|
+
fs_error_.subcode() == IOStatus::SubCode::kNoSpace) {
|
|
262
316
|
*disk_free = 0;
|
|
263
317
|
} else {
|
|
264
|
-
io_s =
|
|
318
|
+
io_s = MaybeInjectThreadLocalError(FaultInjectionIOType::kMetadataRead,
|
|
319
|
+
options);
|
|
320
|
+
if (io_s.ok()) {
|
|
321
|
+
io_s = target()->GetFreeSpace(path, options, disk_free, dbg);
|
|
322
|
+
}
|
|
265
323
|
}
|
|
266
324
|
return io_s;
|
|
267
325
|
}
|
|
268
326
|
|
|
327
|
+
IOStatus IsDirectory(const std::string& path, const IOOptions& options,
|
|
328
|
+
bool* is_dir, IODebugContext* dgb) override;
|
|
329
|
+
|
|
269
330
|
IOStatus Poll(std::vector<void*>& io_handles,
|
|
270
331
|
size_t min_completions) override;
|
|
271
332
|
|
|
@@ -309,25 +370,12 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
309
370
|
MutexLock l(&mutex_);
|
|
310
371
|
return filesystem_writable_;
|
|
311
372
|
}
|
|
312
|
-
bool ShouldUseDiretWritable(const std::string& file_name) {
|
|
313
|
-
MutexLock l(&mutex_);
|
|
314
|
-
if (filesystem_writable_) {
|
|
315
|
-
return true;
|
|
316
|
-
}
|
|
317
|
-
FileType file_type = kTempFile;
|
|
318
|
-
uint64_t file_number = 0;
|
|
319
|
-
if (!TryParseFileName(file_name, &file_number, &file_type)) {
|
|
320
|
-
return false;
|
|
321
|
-
}
|
|
322
|
-
return direct_writable_types_.find(file_type) !=
|
|
323
|
-
direct_writable_types_.end();
|
|
324
|
-
}
|
|
325
373
|
void SetFilesystemActiveNoLock(
|
|
326
374
|
bool active, IOStatus error = IOStatus::Corruption("Not active")) {
|
|
327
375
|
error.PermitUncheckedError();
|
|
328
376
|
filesystem_active_ = active;
|
|
329
377
|
if (!active) {
|
|
330
|
-
|
|
378
|
+
fs_error_ = error;
|
|
331
379
|
}
|
|
332
380
|
}
|
|
333
381
|
void SetFilesystemActive(
|
|
@@ -340,14 +388,56 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
340
388
|
MutexLock l(&mutex_);
|
|
341
389
|
filesystem_writable_ = writable;
|
|
342
390
|
}
|
|
391
|
+
|
|
392
|
+
// If true, we buffer write data in memory to simulate data loss upon system
|
|
393
|
+
// crash by only having process crashes
|
|
394
|
+
void SetInjectUnsyncedDataLoss(bool inject) {
|
|
395
|
+
MutexLock l(&mutex_);
|
|
396
|
+
inject_unsynced_data_loss_ = inject;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
bool InjectUnsyncedDataLoss() {
|
|
400
|
+
MutexLock l(&mutex_);
|
|
401
|
+
return inject_unsynced_data_loss_;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// In places (e.g. GetSortedWals()) RocksDB relies on querying the file size
|
|
405
|
+
// or even reading the contents of files currently open for writing, and
|
|
406
|
+
// as in POSIX semantics, expects to see the flushed size and contents
|
|
407
|
+
// regardless of what has been synced. FaultInjectionTestFS historically
|
|
408
|
+
// did not emulate this behavior, only showing synced data from such read
|
|
409
|
+
// operations. (Different from FaultInjectionTestEnv--sigh.) Calling this
|
|
410
|
+
// function with false restores this historical behavior for testing
|
|
411
|
+
// stability, but use of this semantics must be phased out as it is
|
|
412
|
+
// inconsistent with expected FileSystem semantics. In other words, this
|
|
413
|
+
// functionality is DEPRECATED. Intended to be set after construction and
|
|
414
|
+
// unchanged (not thread safe).
|
|
415
|
+
void SetReadUnsyncedData(bool read_unsynced_data) {
|
|
416
|
+
read_unsynced_data_ = read_unsynced_data;
|
|
417
|
+
}
|
|
418
|
+
bool ReadUnsyncedData() const { return read_unsynced_data_; }
|
|
419
|
+
|
|
420
|
+
// FaultInjectionTestFS normally includes a hygiene check for FileSystem
|
|
421
|
+
// implementations that only support LinkFile() on closed files (not open
|
|
422
|
+
// for write). Setting this to true bypasses the check.
|
|
423
|
+
void SetAllowLinkOpenFile(bool allow_link_open_file = true) {
|
|
424
|
+
allow_link_open_file_ = allow_link_open_file;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
bool ShouldIOActivtiesExcludedFromFaultInjection(Env::IOActivity io_activty) {
|
|
428
|
+
MutexLock l(&mutex_);
|
|
429
|
+
return io_activties_excluded_from_fault_injection.find(io_activty) !=
|
|
430
|
+
io_activties_excluded_from_fault_injection.end();
|
|
431
|
+
}
|
|
432
|
+
|
|
343
433
|
void AssertNoOpenFile() { assert(open_managed_files_.empty()); }
|
|
344
434
|
|
|
345
|
-
IOStatus GetError() { return
|
|
435
|
+
IOStatus GetError() { return fs_error_; }
|
|
346
436
|
|
|
347
437
|
void SetFileSystemIOError(IOStatus io_error) {
|
|
348
438
|
MutexLock l(&mutex_);
|
|
349
439
|
io_error.PermitUncheckedError();
|
|
350
|
-
|
|
440
|
+
fs_error_ = io_error;
|
|
351
441
|
}
|
|
352
442
|
|
|
353
443
|
// To simulate the data corruption before data is written in FS
|
|
@@ -368,12 +458,12 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
368
458
|
|
|
369
459
|
void SetChecksumHandoffFuncType(const ChecksumType& func_type) {
|
|
370
460
|
MutexLock l(&mutex_);
|
|
371
|
-
|
|
461
|
+
checksum_handoff_func_type_ = func_type;
|
|
372
462
|
}
|
|
373
463
|
|
|
374
464
|
const ChecksumType& GetChecksumHandoffFuncType() {
|
|
375
465
|
MutexLock l(&mutex_);
|
|
376
|
-
return
|
|
466
|
+
return checksum_handoff_func_type_;
|
|
377
467
|
}
|
|
378
468
|
|
|
379
469
|
void SetFailGetUniqueId(bool flag) {
|
|
@@ -392,23 +482,21 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
392
482
|
kMultiReadSingleReq = 1,
|
|
393
483
|
kMultiRead = 2,
|
|
394
484
|
kOpen,
|
|
485
|
+
kAppend,
|
|
486
|
+
kPositionedAppend,
|
|
487
|
+
kUnknown,
|
|
395
488
|
};
|
|
396
489
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
thread_local_error_->Reset(ctx);
|
|
408
|
-
}
|
|
409
|
-
ctx->one_in = one_in;
|
|
410
|
-
ctx->count = 0;
|
|
411
|
-
ctx->retryable = retryable;
|
|
490
|
+
void SetThreadLocalErrorContext(FaultInjectionIOType type, uint32_t seed,
|
|
491
|
+
int one_in, bool retryable,
|
|
492
|
+
bool has_data_loss) {
|
|
493
|
+
struct ErrorContext* new_ctx = new ErrorContext(seed);
|
|
494
|
+
new_ctx->one_in = one_in;
|
|
495
|
+
new_ctx->count = 0;
|
|
496
|
+
new_ctx->retryable = retryable;
|
|
497
|
+
new_ctx->has_data_loss = has_data_loss;
|
|
498
|
+
|
|
499
|
+
SetErrorContextOfFaultInjectionIOType(type, new_ctx);
|
|
412
500
|
}
|
|
413
501
|
|
|
414
502
|
static void DeleteThreadLocalErrorContext(void* p) {
|
|
@@ -416,114 +504,78 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
416
504
|
delete ctx;
|
|
417
505
|
}
|
|
418
506
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
// error (e.g., Wal files, SST files), which is empty by default.
|
|
425
|
-
void SetRandomWriteError(uint32_t seed, int one_in, IOStatus error,
|
|
426
|
-
bool inject_for_all_file_types,
|
|
427
|
-
const std::vector<FileType>& types) {
|
|
428
|
-
MutexLock l(&mutex_);
|
|
429
|
-
Random tmp_rand(seed);
|
|
430
|
-
error.PermitUncheckedError();
|
|
431
|
-
error_ = error;
|
|
432
|
-
write_error_rand_ = tmp_rand;
|
|
433
|
-
write_error_one_in_ = one_in;
|
|
434
|
-
inject_for_all_file_types_ = inject_for_all_file_types;
|
|
435
|
-
write_error_allowed_types_ = types;
|
|
436
|
-
}
|
|
507
|
+
IOStatus MaybeInjectThreadLocalError(
|
|
508
|
+
FaultInjectionIOType type, const IOOptions& io_options,
|
|
509
|
+
const std::string& file_name = "", ErrorOperation op = kUnknown,
|
|
510
|
+
Slice* slice = nullptr, bool direct_io = false, char* scratch = nullptr,
|
|
511
|
+
bool need_count_increase = false, bool* fault_injected = nullptr);
|
|
437
512
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
direct_writable_types_ = types;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
void SetRandomMetadataWriteError(int one_in) {
|
|
444
|
-
MutexLock l(&mutex_);
|
|
445
|
-
metadata_write_error_one_in_ = one_in;
|
|
446
|
-
}
|
|
447
|
-
// If the value is not 0, it is enabled. Otherwise, it is disabled.
|
|
448
|
-
void SetRandomReadError(int one_in) { read_error_one_in_ = one_in; }
|
|
449
|
-
|
|
450
|
-
bool ShouldInjectRandomReadError() {
|
|
451
|
-
auto one_in = read_error_one_in();
|
|
452
|
-
return one_in > 0 && Random::GetTLSInstance()->OneIn(one_in);
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
// Inject an write error with randomlized parameter and the predefined
|
|
456
|
-
// error type. Only the allowed file types will inject the write error
|
|
457
|
-
IOStatus InjectWriteError(const std::string& file_name);
|
|
458
|
-
|
|
459
|
-
// Ingest error to metadata operations.
|
|
460
|
-
IOStatus InjectMetadataWriteError();
|
|
461
|
-
|
|
462
|
-
// Inject an error. For a READ operation, a status of IOError(), a
|
|
463
|
-
// corruption in the contents of scratch, or truncation of slice
|
|
464
|
-
// are the types of error with equal probability. For OPEN,
|
|
465
|
-
// its always an IOError.
|
|
466
|
-
// fault_injected returns whether a fault is injected. It is needed
|
|
467
|
-
// because some fault is inected with IOStatus to be OK.
|
|
468
|
-
IOStatus InjectThreadSpecificReadError(ErrorOperation op, Slice* slice,
|
|
469
|
-
bool direct_io, char* scratch,
|
|
470
|
-
bool need_count_increase,
|
|
471
|
-
bool* fault_injected);
|
|
472
|
-
|
|
473
|
-
// Get the count of how many times we injected since the previous call
|
|
474
|
-
int GetAndResetErrorCount() {
|
|
475
|
-
ErrorContext* ctx = static_cast<ErrorContext*>(thread_local_error_->Get());
|
|
513
|
+
int GetAndResetInjectedThreadLocalErrorCount(FaultInjectionIOType type) {
|
|
514
|
+
ErrorContext* ctx = GetErrorContextFromFaultInjectionIOType(type);
|
|
476
515
|
int count = 0;
|
|
477
|
-
if (ctx
|
|
516
|
+
if (ctx) {
|
|
478
517
|
count = ctx->count;
|
|
479
518
|
ctx->count = 0;
|
|
480
519
|
}
|
|
481
520
|
return count;
|
|
482
521
|
}
|
|
483
522
|
|
|
484
|
-
void
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
}
|
|
523
|
+
void SetIOActivtiesExcludedFromFaultInjection(
|
|
524
|
+
const std::set<Env::IOActivity>& io_activties) {
|
|
525
|
+
MutexLock l(&mutex_);
|
|
526
|
+
io_activties_excluded_from_fault_injection = io_activties;
|
|
489
527
|
}
|
|
490
528
|
|
|
491
|
-
void
|
|
529
|
+
void SetFileTypesExcludedFromWriteFaultInjection(
|
|
530
|
+
const std::set<FileType>& types) {
|
|
492
531
|
MutexLock l(&mutex_);
|
|
493
|
-
|
|
532
|
+
file_types_excluded_from_write_fault_injection_ = types;
|
|
494
533
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
534
|
+
|
|
535
|
+
void EnableThreadLocalErrorInjection(FaultInjectionIOType type) {
|
|
536
|
+
ErrorContext* ctx = GetErrorContextFromFaultInjectionIOType(type);
|
|
537
|
+
if (ctx) {
|
|
538
|
+
ctx->enable_error_injection = true;
|
|
539
|
+
}
|
|
498
540
|
}
|
|
499
541
|
|
|
500
|
-
void
|
|
501
|
-
|
|
502
|
-
|
|
542
|
+
void EnableAllThreadLocalErrorInjection() {
|
|
543
|
+
EnableThreadLocalErrorInjection(FaultInjectionIOType::kRead);
|
|
544
|
+
EnableThreadLocalErrorInjection(FaultInjectionIOType::kWrite);
|
|
545
|
+
EnableThreadLocalErrorInjection(FaultInjectionIOType::kMetadataRead);
|
|
546
|
+
EnableThreadLocalErrorInjection(FaultInjectionIOType::kMetadataWrite);
|
|
503
547
|
}
|
|
504
548
|
|
|
505
|
-
void
|
|
506
|
-
ErrorContext* ctx =
|
|
549
|
+
void DisableThreadLocalErrorInjection(FaultInjectionIOType type) {
|
|
550
|
+
ErrorContext* ctx = GetErrorContextFromFaultInjectionIOType(type);
|
|
507
551
|
if (ctx) {
|
|
508
552
|
ctx->enable_error_injection = false;
|
|
509
553
|
}
|
|
510
554
|
}
|
|
511
555
|
|
|
512
|
-
void
|
|
513
|
-
|
|
514
|
-
|
|
556
|
+
void DisableAllThreadLocalErrorInjection() {
|
|
557
|
+
DisableThreadLocalErrorInjection(FaultInjectionIOType::kRead);
|
|
558
|
+
DisableThreadLocalErrorInjection(FaultInjectionIOType::kWrite);
|
|
559
|
+
DisableThreadLocalErrorInjection(FaultInjectionIOType::kMetadataRead);
|
|
560
|
+
DisableThreadLocalErrorInjection(FaultInjectionIOType::kMetadataWrite);
|
|
515
561
|
}
|
|
516
562
|
|
|
517
|
-
|
|
563
|
+
void PrintInjectedThreadLocalErrorBacktrace(FaultInjectionIOType type);
|
|
518
564
|
|
|
519
|
-
|
|
565
|
+
// If there is unsynced data in the specified file within the specified
|
|
566
|
+
// range [offset, offset + n), return the unsynced data overlapping with
|
|
567
|
+
// that range, in a corresponding range of scratch. When known, also return
|
|
568
|
+
// the position of the last sync, so that the caller can determine whether
|
|
569
|
+
// more data is available from the target file when not available from
|
|
570
|
+
// unsynced.
|
|
571
|
+
void ReadUnsynced(const std::string& fname, uint64_t offset, size_t n,
|
|
572
|
+
Slice* result, char* scratch, int64_t* pos_at_last_sync);
|
|
520
573
|
|
|
521
|
-
|
|
522
|
-
// purposes. This call prints the backtrace to stderr and frees the
|
|
523
|
-
// saved callstack
|
|
524
|
-
void PrintFaultBacktrace();
|
|
574
|
+
inline static const std::string kInjected = "injected";
|
|
525
575
|
|
|
526
576
|
private:
|
|
577
|
+
inline static const std::string kFailedToWriteToWAL =
|
|
578
|
+
"failed to write to WAL";
|
|
527
579
|
port::Mutex mutex_;
|
|
528
580
|
std::map<std::string, FSFileState> db_file_state_;
|
|
529
581
|
std::set<std::string> open_managed_files_;
|
|
@@ -536,7 +588,10 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
536
588
|
bool filesystem_active_; // Record flushes, syncs, writes
|
|
537
589
|
bool filesystem_writable_; // Bypass FaultInjectionTestFS and go directly
|
|
538
590
|
// to underlying FS for writable files
|
|
539
|
-
|
|
591
|
+
bool inject_unsynced_data_loss_; // See InjectUnsyncedDataLoss()
|
|
592
|
+
bool read_unsynced_data_; // See SetReadUnsyncedData()
|
|
593
|
+
bool allow_link_open_file_; // See SetAllowLinkOpenFile()
|
|
594
|
+
IOStatus fs_error_;
|
|
540
595
|
|
|
541
596
|
enum ErrorType : int {
|
|
542
597
|
kErrorTypeStatus = 0,
|
|
@@ -555,13 +610,15 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
555
610
|
int frames;
|
|
556
611
|
ErrorType type;
|
|
557
612
|
bool retryable;
|
|
613
|
+
bool has_data_loss;
|
|
558
614
|
|
|
559
615
|
explicit ErrorContext(uint32_t seed)
|
|
560
616
|
: rand(seed),
|
|
561
617
|
enable_error_injection(false),
|
|
562
618
|
callstack(nullptr),
|
|
563
619
|
frames(0),
|
|
564
|
-
retryable(false)
|
|
620
|
+
retryable(false),
|
|
621
|
+
has_data_loss(false) {}
|
|
565
622
|
~ErrorContext() {
|
|
566
623
|
if (callstack) {
|
|
567
624
|
free(callstack);
|
|
@@ -569,25 +626,135 @@ class FaultInjectionTestFS : public FileSystemWrapper {
|
|
|
569
626
|
}
|
|
570
627
|
};
|
|
571
628
|
|
|
572
|
-
std::
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
std::atomic<int> read_error_one_in_;
|
|
579
|
-
bool inject_for_all_file_types_;
|
|
580
|
-
std::vector<FileType> write_error_allowed_types_;
|
|
581
|
-
// File types where direct writable is skipped.
|
|
582
|
-
std::set<FileType> direct_writable_types_;
|
|
629
|
+
std::set<FileType> file_types_excluded_from_write_fault_injection_;
|
|
630
|
+
std::set<Env::IOActivity> io_activties_excluded_from_fault_injection;
|
|
631
|
+
ThreadLocalPtr injected_thread_local_read_error_;
|
|
632
|
+
ThreadLocalPtr injected_thread_local_write_error_;
|
|
633
|
+
ThreadLocalPtr injected_thread_local_metadata_read_error_;
|
|
634
|
+
ThreadLocalPtr injected_thread_local_metadata_write_error_;
|
|
583
635
|
bool ingest_data_corruption_before_write_;
|
|
584
|
-
ChecksumType
|
|
636
|
+
ChecksumType checksum_handoff_func_type_;
|
|
585
637
|
bool fail_get_file_unique_id_;
|
|
586
638
|
|
|
639
|
+
// Inject an error. For a READ operation, a status of IOError(), a
|
|
640
|
+
// corruption in the contents of scratch, or truncation of slice
|
|
641
|
+
// are the types of error with equal probability. For OPEN,
|
|
642
|
+
// its always an IOError.
|
|
643
|
+
// fault_injected returns whether a fault is injected. It is needed
|
|
644
|
+
// because some fault is inected with IOStatus to be OK.
|
|
645
|
+
IOStatus MaybeInjectThreadLocalReadError(const IOOptions& io_options,
|
|
646
|
+
ErrorOperation op, Slice* slice,
|
|
647
|
+
bool direct_io, char* scratch,
|
|
648
|
+
bool need_count_increase,
|
|
649
|
+
bool* fault_injected);
|
|
650
|
+
|
|
651
|
+
bool ShouldExcludeFromWriteFaultInjection(const std::string& file_name) {
|
|
652
|
+
MutexLock l(&mutex_);
|
|
653
|
+
FileType file_type = kTempFile;
|
|
654
|
+
uint64_t file_number = 0;
|
|
655
|
+
if (!TryParseFileName(file_name, &file_number, &file_type)) {
|
|
656
|
+
return false;
|
|
657
|
+
}
|
|
658
|
+
return file_types_excluded_from_write_fault_injection_.find(file_type) !=
|
|
659
|
+
file_types_excluded_from_write_fault_injection_.end();
|
|
660
|
+
}
|
|
661
|
+
|
|
587
662
|
// Extract number of type from file name. Return false if failing to fine
|
|
588
663
|
// them.
|
|
589
664
|
bool TryParseFileName(const std::string& file_name, uint64_t* number,
|
|
590
665
|
FileType* type);
|
|
666
|
+
|
|
667
|
+
ErrorContext* GetErrorContextFromFaultInjectionIOType(
|
|
668
|
+
FaultInjectionIOType type) {
|
|
669
|
+
ErrorContext* ctx = nullptr;
|
|
670
|
+
switch (type) {
|
|
671
|
+
case FaultInjectionIOType::kRead:
|
|
672
|
+
ctx = static_cast<struct ErrorContext*>(
|
|
673
|
+
injected_thread_local_read_error_.Get());
|
|
674
|
+
break;
|
|
675
|
+
case FaultInjectionIOType::kWrite:
|
|
676
|
+
ctx = static_cast<struct ErrorContext*>(
|
|
677
|
+
injected_thread_local_write_error_.Get());
|
|
678
|
+
break;
|
|
679
|
+
case FaultInjectionIOType::kMetadataRead:
|
|
680
|
+
ctx = static_cast<struct ErrorContext*>(
|
|
681
|
+
injected_thread_local_metadata_read_error_.Get());
|
|
682
|
+
break;
|
|
683
|
+
case FaultInjectionIOType::kMetadataWrite:
|
|
684
|
+
ctx = static_cast<struct ErrorContext*>(
|
|
685
|
+
injected_thread_local_metadata_write_error_.Get());
|
|
686
|
+
break;
|
|
687
|
+
default:
|
|
688
|
+
assert(false);
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
return ctx;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
void SetErrorContextOfFaultInjectionIOType(FaultInjectionIOType type,
|
|
695
|
+
ErrorContext* new_ctx) {
|
|
696
|
+
ErrorContext* old_ctx = nullptr;
|
|
697
|
+
switch (type) {
|
|
698
|
+
case FaultInjectionIOType::kRead:
|
|
699
|
+
old_ctx = static_cast<struct ErrorContext*>(
|
|
700
|
+
injected_thread_local_read_error_.Swap(new_ctx));
|
|
701
|
+
break;
|
|
702
|
+
case FaultInjectionIOType::kWrite:
|
|
703
|
+
old_ctx = static_cast<struct ErrorContext*>(
|
|
704
|
+
injected_thread_local_write_error_.Swap(new_ctx));
|
|
705
|
+
break;
|
|
706
|
+
case FaultInjectionIOType::kMetadataRead:
|
|
707
|
+
old_ctx = static_cast<struct ErrorContext*>(
|
|
708
|
+
injected_thread_local_metadata_read_error_.Swap(new_ctx));
|
|
709
|
+
break;
|
|
710
|
+
case FaultInjectionIOType::kMetadataWrite:
|
|
711
|
+
old_ctx = static_cast<struct ErrorContext*>(
|
|
712
|
+
injected_thread_local_metadata_write_error_.Swap(new_ctx));
|
|
713
|
+
break;
|
|
714
|
+
default:
|
|
715
|
+
assert(false);
|
|
716
|
+
break;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
if (old_ctx) {
|
|
720
|
+
DeleteThreadLocalErrorContext(old_ctx);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
std::string GetErrorMessage(FaultInjectionIOType type,
|
|
725
|
+
const std::string& file_name, ErrorOperation op) {
|
|
726
|
+
std::ostringstream msg;
|
|
727
|
+
msg << kInjected << " ";
|
|
728
|
+
switch (type) {
|
|
729
|
+
case FaultInjectionIOType::kRead:
|
|
730
|
+
msg << "read error";
|
|
731
|
+
break;
|
|
732
|
+
case FaultInjectionIOType::kWrite:
|
|
733
|
+
msg << "write error";
|
|
734
|
+
break;
|
|
735
|
+
case FaultInjectionIOType::kMetadataRead:
|
|
736
|
+
msg << "metadata read error";
|
|
737
|
+
break;
|
|
738
|
+
case FaultInjectionIOType::kMetadataWrite:
|
|
739
|
+
msg << "metadata write error";
|
|
740
|
+
break;
|
|
741
|
+
default:
|
|
742
|
+
assert(false);
|
|
743
|
+
break;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
if (type == FaultInjectionIOType::kWrite &&
|
|
747
|
+
(op == ErrorOperation::kOpen || op == ErrorOperation::kAppend ||
|
|
748
|
+
op == ErrorOperation::kPositionedAppend)) {
|
|
749
|
+
FileType file_type = kTempFile;
|
|
750
|
+
uint64_t ignore = 0;
|
|
751
|
+
if (TryParseFileName(file_name, &ignore, &file_type) &&
|
|
752
|
+
file_type == FileType::kWalFile) {
|
|
753
|
+
msg << " " << kFailedToWriteToWAL;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
return msg.str();
|
|
757
|
+
}
|
|
591
758
|
};
|
|
592
759
|
|
|
593
760
|
} // namespace ROCKSDB_NAMESPACE
|