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.
Files changed (261) hide show
  1. package/binding.c +92 -10
  2. package/index.js +9 -0
  3. package/lib/batch.js +11 -1
  4. package/lib/iterator.js +3 -1
  5. package/lib/snapshot.js +21 -0
  6. package/package.json +1 -1
  7. package/prebuilds/darwin-arm64/rocksdb-native.bare +0 -0
  8. package/prebuilds/darwin-arm64/rocksdb-native.node +0 -0
  9. package/prebuilds/darwin-x64/rocksdb-native.bare +0 -0
  10. package/prebuilds/darwin-x64/rocksdb-native.node +0 -0
  11. package/prebuilds/linux-arm64/rocksdb-native.bare +0 -0
  12. package/prebuilds/linux-arm64/rocksdb-native.node +0 -0
  13. package/prebuilds/linux-x64/rocksdb-native.bare +0 -0
  14. package/prebuilds/linux-x64/rocksdb-native.node +0 -0
  15. package/prebuilds/win32-x64/rocksdb-native.bare +0 -0
  16. package/prebuilds/win32-x64/rocksdb-native.node +0 -0
  17. package/vendor/librocksdb/include/rocksdb.h +38 -4
  18. package/vendor/librocksdb/src/rocksdb.cc +114 -14
  19. package/vendor/librocksdb/vendor/rocksdb/CMakeLists.txt +21 -4
  20. package/vendor/librocksdb/vendor/rocksdb/cache/secondary_cache_adapter.cc +6 -3
  21. package/vendor/librocksdb/vendor/rocksdb/db/arena_wrapped_db_iter.cc +4 -4
  22. package/vendor/librocksdb/vendor/rocksdb/db/arena_wrapped_db_iter.h +4 -2
  23. package/vendor/librocksdb/vendor/rocksdb/db/attribute_group_iterator_impl.cc +20 -0
  24. package/vendor/librocksdb/vendor/rocksdb/db/attribute_group_iterator_impl.h +83 -0
  25. package/vendor/librocksdb/vendor/rocksdb/db/builder.cc +9 -5
  26. package/vendor/librocksdb/vendor/rocksdb/db/builder.h +1 -1
  27. package/vendor/librocksdb/vendor/rocksdb/db/c.cc +231 -6
  28. package/vendor/librocksdb/vendor/rocksdb/db/c_test.c +202 -2
  29. package/vendor/librocksdb/vendor/rocksdb/db/coalescing_iterator.cc +47 -0
  30. package/vendor/librocksdb/vendor/rocksdb/db/coalescing_iterator.h +79 -0
  31. package/vendor/librocksdb/vendor/rocksdb/db/column_family.cc +28 -0
  32. package/vendor/librocksdb/vendor/rocksdb/db/column_family.h +17 -0
  33. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction.cc +8 -1
  34. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction.h +11 -9
  35. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_iterator.cc +50 -23
  36. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_iterator.h +13 -0
  37. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_job.cc +22 -25
  38. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_job.h +2 -0
  39. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_outputs.cc +8 -1
  40. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_outputs.h +1 -0
  41. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker.cc +40 -17
  42. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker.h +20 -14
  43. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker_level.cc +11 -6
  44. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker_universal.cc +77 -24
  45. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_service_job.cc +2 -0
  46. package/vendor/librocksdb/vendor/rocksdb/db/convenience.cc +3 -0
  47. package/vendor/librocksdb/vendor/rocksdb/db/db_filesnapshot.cc +125 -31
  48. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl.cc +457 -231
  49. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl.h +172 -73
  50. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_compaction_flush.cc +152 -133
  51. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_debug.cc +5 -0
  52. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_files.cc +58 -52
  53. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_follower.cc +348 -0
  54. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_follower.h +54 -0
  55. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_open.cc +136 -117
  56. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_secondary.cc +4 -3
  57. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_secondary.h +7 -6
  58. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_write.cc +134 -80
  59. package/vendor/librocksdb/vendor/rocksdb/db/db_iter.cc +11 -0
  60. package/vendor/librocksdb/vendor/rocksdb/db/db_test2.cc +1 -1
  61. package/vendor/librocksdb/vendor/rocksdb/db/db_test_util.cc +11 -1
  62. package/vendor/librocksdb/vendor/rocksdb/db/db_test_util.h +11 -7
  63. package/vendor/librocksdb/vendor/rocksdb/db/dbformat.cc +19 -4
  64. package/vendor/librocksdb/vendor/rocksdb/db/dbformat.h +3 -2
  65. package/vendor/librocksdb/vendor/rocksdb/db/error_handler.cc +34 -39
  66. package/vendor/librocksdb/vendor/rocksdb/db/error_handler.h +3 -4
  67. package/vendor/librocksdb/vendor/rocksdb/db/event_helpers.cc +6 -3
  68. package/vendor/librocksdb/vendor/rocksdb/db/experimental.cc +3 -2
  69. package/vendor/librocksdb/vendor/rocksdb/db/external_sst_file_ingestion_job.cc +76 -18
  70. package/vendor/librocksdb/vendor/rocksdb/db/external_sst_file_ingestion_job.h +11 -0
  71. package/vendor/librocksdb/vendor/rocksdb/db/flush_job.cc +37 -5
  72. package/vendor/librocksdb/vendor/rocksdb/db/flush_job.h +14 -0
  73. package/vendor/librocksdb/vendor/rocksdb/db/import_column_family_job.cc +49 -45
  74. package/vendor/librocksdb/vendor/rocksdb/db/internal_stats.cc +60 -1
  75. package/vendor/librocksdb/vendor/rocksdb/db/internal_stats.h +20 -1
  76. package/vendor/librocksdb/vendor/rocksdb/db/log_reader.cc +15 -6
  77. package/vendor/librocksdb/vendor/rocksdb/db/log_writer.cc +59 -10
  78. package/vendor/librocksdb/vendor/rocksdb/db/log_writer.h +8 -0
  79. package/vendor/librocksdb/vendor/rocksdb/db/memtable.cc +24 -40
  80. package/vendor/librocksdb/vendor/rocksdb/db/memtable.h +10 -10
  81. package/vendor/librocksdb/vendor/rocksdb/db/memtable_list.cc +9 -8
  82. package/vendor/librocksdb/vendor/rocksdb/db/multi_cf_iterator_impl.h +296 -0
  83. package/vendor/librocksdb/vendor/rocksdb/db/range_tombstone_fragmenter.h +8 -10
  84. package/vendor/librocksdb/vendor/rocksdb/db/repair.cc +4 -3
  85. package/vendor/librocksdb/vendor/rocksdb/db/seqno_to_time_mapping.cc +30 -0
  86. package/vendor/librocksdb/vendor/rocksdb/db/seqno_to_time_mapping.h +9 -0
  87. package/vendor/librocksdb/vendor/rocksdb/db/table_cache.cc +17 -2
  88. package/vendor/librocksdb/vendor/rocksdb/db/table_cache.h +9 -1
  89. package/vendor/librocksdb/vendor/rocksdb/db/table_properties_collector.h +9 -2
  90. package/vendor/librocksdb/vendor/rocksdb/db/transaction_log_impl.cc +3 -3
  91. package/vendor/librocksdb/vendor/rocksdb/db/transaction_log_impl.h +7 -7
  92. package/vendor/librocksdb/vendor/rocksdb/db/version_edit.cc +0 -1
  93. package/vendor/librocksdb/vendor/rocksdb/db/version_edit_handler.cc +39 -5
  94. package/vendor/librocksdb/vendor/rocksdb/db/version_edit_handler.h +24 -15
  95. package/vendor/librocksdb/vendor/rocksdb/db/version_set.cc +117 -64
  96. package/vendor/librocksdb/vendor/rocksdb/db/version_set.h +27 -10
  97. package/vendor/librocksdb/vendor/rocksdb/db/wal_manager.cc +37 -29
  98. package/vendor/librocksdb/vendor/rocksdb/db/wal_manager.h +6 -5
  99. package/vendor/librocksdb/vendor/rocksdb/db/wide/wide_columns.cc +2 -3
  100. package/vendor/librocksdb/vendor/rocksdb/db/wide/wide_columns_helper.cc +6 -0
  101. package/vendor/librocksdb/vendor/rocksdb/db/write_batch.cc +89 -31
  102. package/vendor/librocksdb/vendor/rocksdb/db/write_thread.cc +53 -5
  103. package/vendor/librocksdb/vendor/rocksdb/db/write_thread.h +36 -4
  104. package/vendor/librocksdb/vendor/rocksdb/env/composite_env_wrapper.h +21 -0
  105. package/vendor/librocksdb/vendor/rocksdb/env/env.cc +15 -0
  106. package/vendor/librocksdb/vendor/rocksdb/env/fs_on_demand.cc +331 -0
  107. package/vendor/librocksdb/vendor/rocksdb/env/fs_on_demand.h +139 -0
  108. package/vendor/librocksdb/vendor/rocksdb/env/io_posix.cc +8 -6
  109. package/vendor/librocksdb/vendor/rocksdb/env/io_posix.h +1 -1
  110. package/vendor/librocksdb/vendor/rocksdb/file/delete_scheduler.cc +130 -27
  111. package/vendor/librocksdb/vendor/rocksdb/file/delete_scheduler.h +61 -8
  112. package/vendor/librocksdb/vendor/rocksdb/file/file_util.cc +25 -4
  113. package/vendor/librocksdb/vendor/rocksdb/file/file_util.h +15 -0
  114. package/vendor/librocksdb/vendor/rocksdb/file/sequence_file_reader.cc +1 -0
  115. package/vendor/librocksdb/vendor/rocksdb/file/sequence_file_reader.h +9 -4
  116. package/vendor/librocksdb/vendor/rocksdb/file/sst_file_manager_impl.cc +18 -0
  117. package/vendor/librocksdb/vendor/rocksdb/file/sst_file_manager_impl.h +31 -4
  118. package/vendor/librocksdb/vendor/rocksdb/file/writable_file_writer.cc +40 -38
  119. package/vendor/librocksdb/vendor/rocksdb/file/writable_file_writer.h +48 -15
  120. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/advanced_options.h +12 -3
  121. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/attribute_groups.h +114 -0
  122. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/c.h +90 -0
  123. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/cache.h +5 -0
  124. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/comparator.h +27 -0
  125. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/db.h +71 -12
  126. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/env.h +9 -0
  127. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/experimental.h +5 -0
  128. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/file_system.h +14 -0
  129. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/iterator.h +9 -71
  130. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/iterator_base.h +90 -0
  131. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/listener.h +21 -0
  132. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/options.h +125 -12
  133. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/perf_context.h +1 -1
  134. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/sst_file_reader.h +11 -1
  135. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/table.h +6 -6
  136. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/table_properties.h +19 -0
  137. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/transaction_log.h +12 -6
  138. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/types.h +12 -0
  139. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/universal_compaction.h +31 -0
  140. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/user_write_callback.h +29 -0
  141. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/cache_dump_load.h +4 -0
  142. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/checkpoint.h +4 -2
  143. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/customizable_util.h +0 -1
  144. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/env_mirror.h +1 -1
  145. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/ldb_cmd.h +24 -7
  146. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/option_change_migration.h +4 -4
  147. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/stackable_db.h +24 -5
  148. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/table_properties_collectors.h +46 -0
  149. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/transaction.h +42 -17
  150. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/transaction_db.h +5 -0
  151. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/types_util.h +36 -0
  152. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/write_batch_with_index.h +71 -3
  153. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/version.h +2 -2
  154. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/wide_columns.h +87 -72
  155. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/write_batch_base.h +1 -1
  156. package/vendor/librocksdb/vendor/rocksdb/memory/memory_allocator.cc +1 -0
  157. package/vendor/librocksdb/vendor/rocksdb/options/cf_options.cc +13 -2
  158. package/vendor/librocksdb/vendor/rocksdb/options/cf_options.h +6 -2
  159. package/vendor/librocksdb/vendor/rocksdb/options/db_options.cc +27 -1
  160. package/vendor/librocksdb/vendor/rocksdb/options/db_options.h +10 -3
  161. package/vendor/librocksdb/vendor/rocksdb/options/options.cc +3 -0
  162. package/vendor/librocksdb/vendor/rocksdb/options/options_helper.cc +1 -0
  163. package/vendor/librocksdb/vendor/rocksdb/port/jemalloc_helper.h +2 -2
  164. package/vendor/librocksdb/vendor/rocksdb/port/stack_trace.cc +1 -0
  165. package/vendor/librocksdb/vendor/rocksdb/port/win/port_win.cc +3 -2
  166. package/vendor/librocksdb/vendor/rocksdb/table/block_based/binary_search_index_reader.cc +1 -2
  167. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_builder.cc +47 -31
  168. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_factory.cc +15 -0
  169. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_iterator.cc +37 -18
  170. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_iterator.h +10 -3
  171. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader.cc +102 -41
  172. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader.h +15 -7
  173. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader_impl.h +1 -3
  174. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +5 -6
  175. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_cache.h +31 -0
  176. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_prefetcher.cc +6 -0
  177. package/vendor/librocksdb/vendor/rocksdb/table/block_based/cachable_entry.h +10 -5
  178. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_block.h +34 -28
  179. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_block_reader_common.cc +17 -11
  180. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_block_reader_common.h +5 -2
  181. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_policy.cc +12 -3
  182. package/vendor/librocksdb/vendor/rocksdb/table/block_based/full_filter_block.cc +37 -30
  183. package/vendor/librocksdb/vendor/rocksdb/table/block_based/full_filter_block.h +11 -13
  184. package/vendor/librocksdb/vendor/rocksdb/table/block_based/hash_index_reader.cc +1 -2
  185. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_builder.cc +62 -53
  186. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_builder.h +60 -38
  187. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_reader_common.cc +14 -9
  188. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_reader_common.h +4 -1
  189. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_filter_block.cc +135 -94
  190. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_filter_block.h +52 -46
  191. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_index_reader.cc +51 -13
  192. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_index_reader.h +2 -0
  193. package/vendor/librocksdb/vendor/rocksdb/table/block_based/uncompression_dict_reader.cc +3 -11
  194. package/vendor/librocksdb/vendor/rocksdb/table/block_based/uncompression_dict_reader.h +2 -3
  195. package/vendor/librocksdb/vendor/rocksdb/table/block_fetcher.cc +8 -10
  196. package/vendor/librocksdb/vendor/rocksdb/table/block_fetcher.h +2 -1
  197. package/vendor/librocksdb/vendor/rocksdb/table/compaction_merging_iterator.cc +9 -10
  198. package/vendor/librocksdb/vendor/rocksdb/table/compaction_merging_iterator.h +3 -2
  199. package/vendor/librocksdb/vendor/rocksdb/table/format.cc +1 -2
  200. package/vendor/librocksdb/vendor/rocksdb/table/iterator.cc +4 -0
  201. package/vendor/librocksdb/vendor/rocksdb/table/merging_iterator.cc +18 -13
  202. package/vendor/librocksdb/vendor/rocksdb/table/merging_iterator.h +5 -3
  203. package/vendor/librocksdb/vendor/rocksdb/table/meta_blocks.cc +18 -4
  204. package/vendor/librocksdb/vendor/rocksdb/table/meta_blocks.h +4 -0
  205. package/vendor/librocksdb/vendor/rocksdb/table/plain/plain_table_builder.cc +2 -2
  206. package/vendor/librocksdb/vendor/rocksdb/table/sst_file_dumper.cc +6 -6
  207. package/vendor/librocksdb/vendor/rocksdb/table/sst_file_reader.cc +24 -2
  208. package/vendor/librocksdb/vendor/rocksdb/table/sst_file_writer_collectors.h +3 -1
  209. package/vendor/librocksdb/vendor/rocksdb/table/table_builder.h +8 -7
  210. package/vendor/librocksdb/vendor/rocksdb/table/table_iterator.h +69 -0
  211. package/vendor/librocksdb/vendor/rocksdb/table/table_reader.h +9 -0
  212. package/vendor/librocksdb/vendor/rocksdb/test_util/testutil.cc +25 -0
  213. package/vendor/librocksdb/vendor/rocksdb/test_util/testutil.h +12 -0
  214. package/vendor/librocksdb/vendor/rocksdb/tools/db_bench_tool.cc +32 -0
  215. package/vendor/librocksdb/vendor/rocksdb/tools/ldb_cmd.cc +618 -124
  216. package/vendor/librocksdb/vendor/rocksdb/tools/ldb_cmd_impl.h +19 -1
  217. package/vendor/librocksdb/vendor/rocksdb/tools/ldb_tool.cc +9 -0
  218. package/vendor/librocksdb/vendor/rocksdb/util/aligned_storage.h +24 -0
  219. package/vendor/librocksdb/vendor/rocksdb/util/autovector.h +4 -0
  220. package/vendor/librocksdb/vendor/rocksdb/util/comparator.cc +12 -0
  221. package/vendor/librocksdb/vendor/rocksdb/util/filter_bench.cc +1 -1
  222. package/vendor/librocksdb/vendor/rocksdb/util/random.cc +2 -1
  223. package/vendor/librocksdb/vendor/rocksdb/util/stderr_logger.cc +3 -4
  224. package/vendor/librocksdb/vendor/rocksdb/util/stderr_logger.h +1 -1
  225. package/vendor/librocksdb/vendor/rocksdb/util/udt_util.cc +33 -0
  226. package/vendor/librocksdb/vendor/rocksdb/util/udt_util.h +7 -0
  227. package/vendor/librocksdb/vendor/rocksdb/util/write_batch_util.h +5 -0
  228. package/vendor/librocksdb/vendor/rocksdb/util/xxhash.h +36 -29
  229. package/vendor/librocksdb/vendor/rocksdb/utilities/blob_db/blob_db_impl.h +3 -0
  230. package/vendor/librocksdb/vendor/rocksdb/utilities/blob_db/blob_db_impl_filesnapshot.cc +20 -0
  231. package/vendor/librocksdb/vendor/rocksdb/utilities/cache_dump_load_impl.cc +29 -9
  232. package/vendor/librocksdb/vendor/rocksdb/utilities/cache_dump_load_impl.h +14 -3
  233. package/vendor/librocksdb/vendor/rocksdb/utilities/debug.cc +16 -4
  234. package/vendor/librocksdb/vendor/rocksdb/utilities/fault_injection_fs.cc +677 -248
  235. package/vendor/librocksdb/vendor/rocksdb/utilities/fault_injection_fs.h +325 -158
  236. package/vendor/librocksdb/vendor/rocksdb/utilities/option_change_migration/option_change_migration.cc +1 -8
  237. package/vendor/librocksdb/vendor/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.cc +144 -0
  238. package/vendor/librocksdb/vendor/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.h +45 -0
  239. package/vendor/librocksdb/vendor/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.cc +12 -0
  240. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h +1 -1
  241. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/growable_array.h +3 -3
  242. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction.cc +116 -20
  243. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction.h +33 -1
  244. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction_db.cc +78 -13
  245. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction_db.h +33 -1
  246. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_base.cc +106 -7
  247. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_base.h +68 -10
  248. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_test.h +7 -3
  249. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_util.cc +8 -5
  250. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_util.h +7 -4
  251. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_prepared_txn.cc +18 -12
  252. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_prepared_txn_db.cc +4 -4
  253. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_prepared_txn_db.h +17 -0
  254. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_unprepared_txn.cc +11 -9
  255. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_unprepared_txn_db.cc +2 -1
  256. package/vendor/librocksdb/vendor/rocksdb/utilities/types_util.cc +88 -0
  257. package/vendor/librocksdb/vendor/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc +313 -14
  258. package/vendor/librocksdb/vendor/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc +7 -0
  259. package/vendor/librocksdb/vendor/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h +1 -1
  260. package/vendor/librocksdb/vendor/rocksdb/db/multi_cf_iterator.cc +0 -102
  261. package/vendor/librocksdb/vendor/rocksdb/db/multi_cf_iterator.h +0 -159
@@ -227,6 +227,7 @@ class UniversalCompactionBuilder {
227
227
  const InternalKeyComparator* icmp_;
228
228
  double score_;
229
229
  std::vector<SortedRun> sorted_runs_;
230
+ uint64_t max_run_size_;
230
231
  const std::string& cf_name_;
231
232
  const MutableCFOptions& mutable_cf_options_;
232
233
  const MutableDBOptions& mutable_db_options_;
@@ -235,7 +236,8 @@ class UniversalCompactionBuilder {
235
236
  LogBuffer* log_buffer_;
236
237
 
237
238
  static std::vector<UniversalCompactionBuilder::SortedRun> CalculateSortedRuns(
238
- const VersionStorageInfo& vstorage, int last_level);
239
+ const VersionStorageInfo& vstorage, int last_level,
240
+ uint64_t* max_run_size);
239
241
 
240
242
  // Pick a path ID to place a newly generated file, with its estimated file
241
243
  // size.
@@ -440,11 +442,15 @@ void UniversalCompactionBuilder::SortedRun::DumpSizeInfo(
440
442
 
441
443
  std::vector<UniversalCompactionBuilder::SortedRun>
442
444
  UniversalCompactionBuilder::CalculateSortedRuns(
443
- const VersionStorageInfo& vstorage, int last_level) {
445
+ const VersionStorageInfo& vstorage, int last_level,
446
+ uint64_t* max_run_size) {
447
+ assert(max_run_size);
448
+ *max_run_size = 0;
444
449
  std::vector<UniversalCompactionBuilder::SortedRun> ret;
445
450
  for (FileMetaData* f : vstorage.LevelFiles(0)) {
446
451
  ret.emplace_back(0, f, f->fd.GetFileSize(), f->compensated_file_size,
447
452
  f->being_compacted);
453
+ *max_run_size = std::max(*max_run_size, f->fd.GetFileSize());
448
454
  }
449
455
  for (int level = 1; level <= last_level; level++) {
450
456
  uint64_t total_compensated_size = 0U;
@@ -466,6 +472,7 @@ UniversalCompactionBuilder::CalculateSortedRuns(
466
472
  ret.emplace_back(level, nullptr, total_size, total_compensated_size,
467
473
  being_compacted);
468
474
  }
475
+ *max_run_size = std::max(*max_run_size, total_size);
469
476
  }
470
477
  return ret;
471
478
  }
@@ -477,13 +484,16 @@ Compaction* UniversalCompactionBuilder::PickCompaction() {
477
484
  score_ = vstorage_->CompactionScore(kLevel0);
478
485
  int max_output_level =
479
486
  vstorage_->MaxOutputLevel(ioptions_.allow_ingest_behind);
480
- sorted_runs_ = CalculateSortedRuns(*vstorage_, max_output_level);
487
+ max_run_size_ = 0;
488
+ sorted_runs_ =
489
+ CalculateSortedRuns(*vstorage_, max_output_level, &max_run_size_);
490
+ int file_num_compaction_trigger =
491
+ mutable_cf_options_.level0_file_num_compaction_trigger;
481
492
 
482
493
  if (sorted_runs_.size() == 0 ||
483
494
  (vstorage_->FilesMarkedForPeriodicCompaction().empty() &&
484
495
  vstorage_->FilesMarkedForCompaction().empty() &&
485
- sorted_runs_.size() < (unsigned int)mutable_cf_options_
486
- .level0_file_num_compaction_trigger)) {
496
+ sorted_runs_.size() < (unsigned int)file_num_compaction_trigger)) {
487
497
  ROCKS_LOG_BUFFER(log_buffer_, "[%s] Universal: nothing to do\n",
488
498
  cf_name_.c_str());
489
499
  TEST_SYNC_POINT_CALLBACK(
@@ -505,11 +515,9 @@ Compaction* UniversalCompactionBuilder::PickCompaction() {
505
515
  TEST_SYNC_POINT_CALLBACK("PostPickPeriodicCompaction", c);
506
516
  }
507
517
 
508
- // Check for size amplification.
509
518
  if (c == nullptr &&
510
- sorted_runs_.size() >=
511
- static_cast<size_t>(
512
- mutable_cf_options_.level0_file_num_compaction_trigger)) {
519
+ sorted_runs_.size() >= static_cast<size_t>(file_num_compaction_trigger)) {
520
+ // Check for size amplification.
513
521
  if ((c = PickCompactionToReduceSizeAmp()) != nullptr) {
514
522
  TEST_SYNC_POINT("PickCompactionToReduceSizeAmpReturnNonnullptr");
515
523
  ROCKS_LOG_BUFFER(log_buffer_, "[%s] Universal: compacting for size amp\n",
@@ -527,13 +535,48 @@ Compaction* UniversalCompactionBuilder::PickCompaction() {
527
535
  cf_name_.c_str());
528
536
  } else {
529
537
  // Size amplification and file size ratios are within configured limits.
530
- // If max read amplification is exceeding configured limits, then force
531
- // compaction without looking at filesize ratios and try to reduce
532
- // the number of files to fewer than level0_file_num_compaction_trigger.
538
+ // If max read amplification exceeds configured limits, then force
539
+ // compaction to reduce the number sorted runs without looking at file
540
+ // size ratios.
541
+
533
542
  // This is guaranteed by NeedsCompaction()
534
543
  assert(sorted_runs_.size() >=
535
- static_cast<size_t>(
536
- mutable_cf_options_.level0_file_num_compaction_trigger));
544
+ static_cast<size_t>(file_num_compaction_trigger));
545
+ int max_num_runs =
546
+ mutable_cf_options_.compaction_options_universal.max_read_amp;
547
+ if (max_num_runs < 0) {
548
+ // any value < -1 is not valid
549
+ assert(max_num_runs == -1);
550
+ // By default, fall back to `level0_file_num_compaction_trigger`
551
+ max_num_runs = file_num_compaction_trigger;
552
+ } else if (max_num_runs == 0) {
553
+ if (mutable_cf_options_.compaction_options_universal.stop_style ==
554
+ kCompactionStopStyleTotalSize) {
555
+ // 0 means auto-tuning by RocksDB. We estimate max num run based on
556
+ // max_run_size, size_ratio and write buffer size:
557
+ // Assume the size of the lowest level size is equal to
558
+ // write_buffer_size. Each subsequent level is the max size without
559
+ // triggering size_ratio compaction. `max_num_runs` is the minimum
560
+ // number of levels required such that the target size of the
561
+ // largest level is at least `max_run_size_`.
562
+ max_num_runs = 1;
563
+ double cur_level_max_size =
564
+ static_cast<double>(mutable_cf_options_.write_buffer_size);
565
+ double total_run_size = 0;
566
+ while (cur_level_max_size < static_cast<double>(max_run_size_)) {
567
+ // This loop should not take too many iterations since
568
+ // cur_level_max_size at least doubles each iteration.
569
+ total_run_size += cur_level_max_size;
570
+ cur_level_max_size = (100.0 + ratio) / 100.0 * total_run_size;
571
+ ++max_num_runs;
572
+ }
573
+ } else {
574
+ // TODO: implement the auto-tune logic for this stop style
575
+ max_num_runs = file_num_compaction_trigger;
576
+ }
577
+ } else {
578
+ // max_num_runs > 0, it's the limit on the number of sorted run
579
+ }
537
580
  // Get the total number of sorted runs that are not being compacted
538
581
  int num_sr_not_compacted = 0;
539
582
  for (size_t i = 0; i < sorted_runs_.size(); i++) {
@@ -544,17 +587,25 @@ Compaction* UniversalCompactionBuilder::PickCompaction() {
544
587
 
545
588
  // The number of sorted runs that are not being compacted is greater
546
589
  // than the maximum allowed number of sorted runs
547
- if (num_sr_not_compacted >
548
- mutable_cf_options_.level0_file_num_compaction_trigger) {
549
- unsigned int num_files =
550
- num_sr_not_compacted -
551
- mutable_cf_options_.level0_file_num_compaction_trigger + 1;
590
+ if (num_sr_not_compacted > max_num_runs) {
591
+ unsigned int num_files = num_sr_not_compacted - max_num_runs + 1;
552
592
  if ((c = PickCompactionToReduceSortedRuns(UINT_MAX, num_files)) !=
553
593
  nullptr) {
554
594
  ROCKS_LOG_BUFFER(log_buffer_,
555
- "[%s] Universal: compacting for file num -- %u\n",
556
- cf_name_.c_str(), num_files);
595
+ "[%s] Universal: compacting for file num, to "
596
+ "compact file num -- %u, max num runs allowed"
597
+ "-- %d, max_run_size -- %" PRIu64 "\n",
598
+ cf_name_.c_str(), num_files, max_num_runs,
599
+ max_run_size_);
557
600
  }
601
+ } else {
602
+ ROCKS_LOG_BUFFER(
603
+ log_buffer_,
604
+ "[%s] Universal: skipping compaction for file num, num runs not "
605
+ "being compacted -- %u, max num runs allowed -- %d, max_run_size "
606
+ "-- %" PRIu64 "\n",
607
+ cf_name_.c_str(), num_sr_not_compacted, max_num_runs,
608
+ max_run_size_);
558
609
  }
559
610
  }
560
611
  }
@@ -1139,7 +1190,8 @@ Compaction* UniversalCompactionBuilder::PickIncrementalForReduceSizeAmp(
1139
1190
  // from bottom_start_idx and bottom_end_idx, but for now, we use
1140
1191
  // SetupOtherInputs() for simplicity.
1141
1192
  int parent_index = -1; // Create and use bottom_start_idx?
1142
- if (!picker_->SetupOtherInputs(cf_name_, vstorage_, &second_last_level_inputs,
1193
+ if (!picker_->SetupOtherInputs(cf_name_, mutable_cf_options_, vstorage_,
1194
+ &second_last_level_inputs,
1143
1195
  &bottom_level_inputs, &parent_index,
1144
1196
  /*base_index=*/-1)) {
1145
1197
  return nullptr;
@@ -1310,8 +1362,9 @@ Compaction* UniversalCompactionBuilder::PickDeleteTriggeredCompaction() {
1310
1362
  int parent_index = -1;
1311
1363
 
1312
1364
  output_level_inputs.level = output_level;
1313
- if (!picker_->SetupOtherInputs(cf_name_, vstorage_, &start_level_inputs,
1314
- &output_level_inputs, &parent_index, -1)) {
1365
+ if (!picker_->SetupOtherInputs(cf_name_, mutable_cf_options_, vstorage_,
1366
+ &start_level_inputs, &output_level_inputs,
1367
+ &parent_index, -1)) {
1315
1368
  return nullptr;
1316
1369
  }
1317
1370
  inputs.push_back(start_level_inputs);
@@ -275,6 +275,8 @@ Status CompactionServiceCompactionJob::Run() {
275
275
  log_buffer_->FlushBufferToLog();
276
276
  LogCompaction();
277
277
  const uint64_t start_micros = db_options_.clock->NowMicros();
278
+ c->GetOrInitInputTableProperties();
279
+
278
280
  // Pick the only sub-compaction we should have
279
281
  assert(compact_->sub_compact_states.size() == 1);
280
282
  SubcompactionState* sub_compact = compact_->sub_compact_states.data();
@@ -71,6 +71,9 @@ Status VerifySstFileChecksumInternal(const Options& options,
71
71
  } else {
72
72
  return s;
73
73
  }
74
+ if (!s.ok()) {
75
+ return s;
76
+ }
74
77
  std::unique_ptr<TableReader> table_reader;
75
78
  std::unique_ptr<RandomAccessFileReader> file_reader(
76
79
  new RandomAccessFileReader(
@@ -21,6 +21,7 @@
21
21
  #include "rocksdb/db.h"
22
22
  #include "rocksdb/env.h"
23
23
  #include "rocksdb/metadata.h"
24
+ #include "rocksdb/transaction_log.h"
24
25
  #include "rocksdb/types.h"
25
26
  #include "test_util/sync_point.h"
26
27
  #include "util/file_checksum_helper.h"
@@ -91,7 +92,12 @@ Status DBImpl::GetLiveFiles(std::vector<std::string>& ret,
91
92
  return Status::OK();
92
93
  }
93
94
 
94
- Status DBImpl::GetSortedWalFiles(VectorLogPtr& files) {
95
+ Status DBImpl::GetSortedWalFiles(VectorWalPtr& files) {
96
+ return GetSortedWalFilesImpl(files,
97
+ /*need_seqnos*/ true);
98
+ }
99
+
100
+ Status DBImpl::GetSortedWalFilesImpl(VectorWalPtr& files, bool need_seqnos) {
95
101
  // Record tracked WALs as a (minimum) cross-check for directory scan
96
102
  std::vector<uint64_t> required_by_manifest;
97
103
 
@@ -117,7 +123,10 @@ Status DBImpl::GetSortedWalFiles(VectorLogPtr& files) {
117
123
  }
118
124
  }
119
125
 
120
- Status s = wal_manager_.GetSortedWalFiles(files);
126
+ // NOTE: need to include archived WALs because needed WALs might have been
127
+ // archived since getting required_by_manifest set
128
+ Status s = wal_manager_.GetSortedWalFiles(files, need_seqnos,
129
+ /*include_archived*/ true);
121
130
 
122
131
  // DisableFileDeletions / EnableFileDeletions not supported in read-only DB
123
132
  if (deletions_disabled.ok()) {
@@ -151,10 +160,33 @@ Status DBImpl::GetSortedWalFiles(VectorLogPtr& files) {
151
160
  }
152
161
  }
153
162
 
163
+ if (s.ok()) {
164
+ size_t wal_count = files.size();
165
+ ROCKS_LOG_INFO(immutable_db_options_.info_log,
166
+ "Number of WAL files %" ROCKSDB_PRIszt " (%" ROCKSDB_PRIszt
167
+ " required by manifest)",
168
+ wal_count, required_by_manifest.size());
169
+ #ifndef NDEBUG
170
+ std::ostringstream wal_names;
171
+ for (const auto& wal : files) {
172
+ wal_names << wal->PathName() << " ";
173
+ }
174
+
175
+ std::ostringstream wal_required_by_manifest_names;
176
+ for (const auto& wal : required_by_manifest) {
177
+ wal_required_by_manifest_names << wal << ".log ";
178
+ }
179
+
180
+ ROCKS_LOG_INFO(immutable_db_options_.info_log,
181
+ "Log files : %s .Log files required by manifest: %s.",
182
+ wal_names.str().c_str(),
183
+ wal_required_by_manifest_names.str().c_str());
184
+ #endif // NDEBUG
185
+ }
154
186
  return s;
155
187
  }
156
188
 
157
- Status DBImpl::GetCurrentWalFile(std::unique_ptr<LogFile>* current_log_file) {
189
+ Status DBImpl::GetCurrentWalFile(std::unique_ptr<WalFile>* current_log_file) {
158
190
  uint64_t current_logfile_number;
159
191
  {
160
192
  InstrumentedMutexLock l(&mutex_);
@@ -175,14 +207,20 @@ Status DBImpl::GetLiveFilesStorageInfo(
175
207
  // NOTE: This implementation was largely migrated from Checkpoint.
176
208
 
177
209
  Status s;
178
- VectorLogPtr live_wal_files;
210
+ VectorWalPtr live_wal_files;
179
211
  bool flush_memtable = true;
180
212
  if (!immutable_db_options_.allow_2pc) {
181
213
  if (opts.wal_size_for_flush == std::numeric_limits<uint64_t>::max()) {
182
214
  flush_memtable = false;
183
215
  } else if (opts.wal_size_for_flush > 0) {
184
- // If the outstanding log files are small, we skip the flush.
185
- s = GetSortedWalFiles(live_wal_files);
216
+ // FIXME: avoid querying the filesystem for current WAL state
217
+ // If the outstanding WAL files are small, we skip the flush.
218
+ // Don't take archived log size into account when calculating wal
219
+ // size for flush, and don't need to verify consistency with manifest
220
+ // here & now.
221
+ s = wal_manager_.GetSortedWalFiles(live_wal_files,
222
+ /* need_seqnos */ false,
223
+ /*include_archived*/ false);
186
224
 
187
225
  if (!s.ok()) {
188
226
  return s;
@@ -193,6 +231,7 @@ Status DBImpl::GetLiveFilesStorageInfo(
193
231
  // We may be able to cover 2PC case too.
194
232
  uint64_t total_wal_size = 0;
195
233
  for (auto& wal : live_wal_files) {
234
+ assert(wal->Type() == kAliveLogFile);
196
235
  total_wal_size += wal->SizeFileBytes();
197
236
  }
198
237
  if (total_wal_size < opts.wal_size_for_flush) {
@@ -206,12 +245,18 @@ Status DBImpl::GetLiveFilesStorageInfo(
206
245
  // metadata.
207
246
  mutex_.Lock();
208
247
  if (flush_memtable) {
209
- Status status = FlushForGetLiveFiles();
210
- if (!status.ok()) {
211
- mutex_.Unlock();
212
- ROCKS_LOG_ERROR(immutable_db_options_.info_log, "Cannot Flush data %s\n",
213
- status.ToString().c_str());
214
- return status;
248
+ bool wal_locked = lock_wal_count_ > 0;
249
+ if (wal_locked) {
250
+ ROCKS_LOG_INFO(immutable_db_options_.info_log,
251
+ "Can't FlushForGetLiveFiles while WAL is locked");
252
+ } else {
253
+ Status status = FlushForGetLiveFiles();
254
+ if (!status.ok()) {
255
+ mutex_.Unlock();
256
+ ROCKS_LOG_ERROR(immutable_db_options_.info_log,
257
+ "Cannot Flush data %s\n", status.ToString().c_str());
258
+ return status;
259
+ }
215
260
  }
216
261
  }
217
262
 
@@ -287,6 +332,8 @@ Status DBImpl::GetLiveFilesStorageInfo(
287
332
  const uint64_t options_number = versions_->options_file_number();
288
333
  const uint64_t options_size = versions_->options_file_size_;
289
334
  const uint64_t min_log_num = MinLogNumberToKeep();
335
+ // Ensure consistency with manifest for track_and_verify_wals_in_manifest
336
+ const uint64_t max_log_num = logfile_number_;
290
337
 
291
338
  mutex_.Unlock();
292
339
 
@@ -350,10 +397,13 @@ Status DBImpl::GetLiveFilesStorageInfo(
350
397
  TEST_SYNC_POINT("CheckpointImpl::CreateCheckpoint:SavedLiveFiles2");
351
398
 
352
399
  if (s.ok()) {
353
- // To maximize the effectiveness of track_and_verify_wals_in_manifest,
354
- // sync WAL when it is enabled.
355
- s = FlushWAL(
356
- immutable_db_options_.track_and_verify_wals_in_manifest /* sync */);
400
+ // FlushWAL is required to ensure we can physically copy everything
401
+ // logically written to the WAL. (Sync not strictly required for
402
+ // active WAL to be copied rather than hard linked, even when
403
+ // Checkpoint guarantees that the copied-to file is sync-ed. Plus we can't
404
+ // help track_and_verify_wals_in_manifest after manifest_size is
405
+ // already determined.)
406
+ s = FlushWAL(/*sync=*/false);
357
407
  if (s.IsNotSupported()) { // read-only DB or similar
358
408
  s = Status::OK();
359
409
  }
@@ -362,25 +412,52 @@ Status DBImpl::GetLiveFilesStorageInfo(
362
412
  TEST_SYNC_POINT("CheckpointImpl::CreateCustomCheckpoint:AfterGetLive1");
363
413
  TEST_SYNC_POINT("CheckpointImpl::CreateCustomCheckpoint:AfterGetLive2");
364
414
 
365
- // If we have more than one column family, we also need to get WAL files.
415
+ // Even after WAL flush, there could be multiple WALs that are not
416
+ // fully synced. Although the output DB of a Checkpoint or Backup needs
417
+ // to be fully synced on return, we don't strictly need to sync this
418
+ // DB (the input DB). If we allow Checkpoint to hard link an inactive
419
+ // WAL that isn't fully synced, that could result in an insufficiently
420
+ // sync-ed Checkpoint. Here we get the set of WALs that are potentially
421
+ // unsynced or still being written to, to prevent them from being hard
422
+ // linked. Enforcing max_log_num from above ensures any new WALs after
423
+ // GetOpenWalSizes() and before GetSortedWalFiles() are not included in
424
+ // the results.
425
+ // NOTE: we might still hard link a file that is open for writing, even
426
+ // if we don't do any more writes to it.
427
+ //
428
+ // In a step toward reducing unnecessary file metadata queries, we also
429
+ // get and use our known flushed sizes for those WALs.
430
+ // FIXME: eventually we should not be using filesystem queries at all for
431
+ // the required set of WAL files.
432
+ //
433
+ // However for recycled log files, we just copy the whole file,
434
+ // for better or worse.
435
+ //
436
+ std::map<uint64_t, uint64_t> open_wal_number_to_size;
437
+ bool recycling_log_files = immutable_db_options_.recycle_log_file_num > 0;
438
+ if (s.ok() && !recycling_log_files) {
439
+ s = GetOpenWalSizes(open_wal_number_to_size);
440
+ }
441
+
442
+ // [old comment] If we have more than one column family, we also need to get
443
+ // WAL files.
366
444
  if (s.ok()) {
367
- s = GetSortedWalFiles(live_wal_files);
445
+ // FIXME: avoid querying the filesystem for current WAL state
446
+ s = GetSortedWalFilesImpl(live_wal_files,
447
+ /* need_seqnos */ false);
368
448
  }
369
449
  if (!s.ok()) {
370
450
  return s;
371
451
  }
372
452
 
373
- size_t wal_size = live_wal_files.size();
374
-
375
- ROCKS_LOG_INFO(immutable_db_options_.info_log,
376
- "Number of log files %" ROCKSDB_PRIszt, live_wal_files.size());
377
-
453
+ size_t wal_count = live_wal_files.size();
378
454
  // Link WAL files. Copy exact size of last one because it is the only one
379
455
  // that has changes after the last flush.
380
456
  auto wal_dir = immutable_db_options_.GetWalDir();
381
- for (size_t i = 0; s.ok() && i < wal_size; ++i) {
457
+ for (size_t i = 0; s.ok() && i < wal_count; ++i) {
382
458
  if ((live_wal_files[i]->Type() == kAliveLogFile) &&
383
- (!flush_memtable || live_wal_files[i]->LogNumber() >= min_log_num)) {
459
+ (!flush_memtable || live_wal_files[i]->LogNumber() >= min_log_num) &&
460
+ live_wal_files[i]->LogNumber() <= max_log_num) {
384
461
  results.emplace_back();
385
462
  LiveFileStorageInfo& info = results.back();
386
463
  auto f = live_wal_files[i]->PathName();
@@ -389,12 +466,29 @@ Status DBImpl::GetLiveFilesStorageInfo(
389
466
  info.directory = wal_dir;
390
467
  info.file_number = live_wal_files[i]->LogNumber();
391
468
  info.file_type = kWalFile;
392
- info.size = live_wal_files[i]->SizeFileBytes();
393
- // Trim the log either if its the last one, or log file recycling is
394
- // enabled. In the latter case, a hard link doesn't prevent the file
395
- // from being renamed and recycled. So we need to copy it instead.
396
- info.trim_to_size = (i + 1 == wal_size) ||
397
- (immutable_db_options_.recycle_log_file_num > 0);
469
+ if (recycling_log_files) {
470
+ info.size = live_wal_files[i]->SizeFileBytes();
471
+ // Recyclable WAL files must be copied instead of hard linked
472
+ info.trim_to_size = true;
473
+ } else {
474
+ auto it = open_wal_number_to_size.find(info.file_number);
475
+ if (it == open_wal_number_to_size.end()) {
476
+ // Known fully synced and no future writes (in part from
477
+ // max_log_num check). Ok to hard link
478
+ info.size = live_wal_files[i]->SizeFileBytes();
479
+ assert(!info.trim_to_size);
480
+ } else {
481
+ // Marked as (possibly) still open -> use our known flushed size
482
+ // and force file copy instead of hard link
483
+ info.size = it->second;
484
+ info.trim_to_size = true;
485
+ // FIXME: this is needed as long as db_stress uses
486
+ // SetReadUnsyncedData(false), because it will only be able to
487
+ // copy the synced portion of the WAL, which under
488
+ // SetReadUnsyncedData(false) is given by the reported file size.
489
+ info.size = std::min(info.size, live_wal_files[i]->SizeFileBytes());
490
+ }
491
+ }
398
492
  if (opts.include_checksum_info) {
399
493
  info.file_checksum_func_name = kUnknownFileChecksumFuncName;
400
494
  info.file_checksum = kUnknownFileChecksum;