@nxtedition/rocksdb 1.0.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 (1088) hide show
  1. package/CHANGELOG.md +294 -0
  2. package/LICENSE +21 -0
  3. package/README.md +102 -0
  4. package/UPGRADING.md +91 -0
  5. package/binding.cc +1276 -0
  6. package/binding.gyp +73 -0
  7. package/binding.js +1 -0
  8. package/chained-batch.js +44 -0
  9. package/deps/rocksdb/build_version.cc +4 -0
  10. package/deps/rocksdb/rocksdb/CMakeLists.txt +1356 -0
  11. package/deps/rocksdb/rocksdb/COPYING +339 -0
  12. package/deps/rocksdb/rocksdb/LICENSE.Apache +202 -0
  13. package/deps/rocksdb/rocksdb/LICENSE.leveldb +29 -0
  14. package/deps/rocksdb/rocksdb/Makefile +2521 -0
  15. package/deps/rocksdb/rocksdb/TARGETS +2100 -0
  16. package/deps/rocksdb/rocksdb/cache/cache.cc +63 -0
  17. package/deps/rocksdb/rocksdb/cache/cache_bench.cc +381 -0
  18. package/deps/rocksdb/rocksdb/cache/cache_helpers.h +114 -0
  19. package/deps/rocksdb/rocksdb/cache/cache_test.cc +775 -0
  20. package/deps/rocksdb/rocksdb/cache/clock_cache.cc +769 -0
  21. package/deps/rocksdb/rocksdb/cache/clock_cache.h +16 -0
  22. package/deps/rocksdb/rocksdb/cache/lru_cache.cc +574 -0
  23. package/deps/rocksdb/rocksdb/cache/lru_cache.h +339 -0
  24. package/deps/rocksdb/rocksdb/cache/lru_cache_test.cc +199 -0
  25. package/deps/rocksdb/rocksdb/cache/sharded_cache.cc +162 -0
  26. package/deps/rocksdb/rocksdb/cache/sharded_cache.h +111 -0
  27. package/deps/rocksdb/rocksdb/cmake/RocksDBConfig.cmake.in +54 -0
  28. package/deps/rocksdb/rocksdb/cmake/modules/CxxFlags.cmake +7 -0
  29. package/deps/rocksdb/rocksdb/cmake/modules/FindJeMalloc.cmake +29 -0
  30. package/deps/rocksdb/rocksdb/cmake/modules/FindNUMA.cmake +29 -0
  31. package/deps/rocksdb/rocksdb/cmake/modules/FindSnappy.cmake +29 -0
  32. package/deps/rocksdb/rocksdb/cmake/modules/FindTBB.cmake +33 -0
  33. package/deps/rocksdb/rocksdb/cmake/modules/Findgflags.cmake +29 -0
  34. package/deps/rocksdb/rocksdb/cmake/modules/Findlz4.cmake +29 -0
  35. package/deps/rocksdb/rocksdb/cmake/modules/Findzstd.cmake +29 -0
  36. package/deps/rocksdb/rocksdb/cmake/modules/ReadVersion.cmake +10 -0
  37. package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.cc +108 -0
  38. package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.h +115 -0
  39. package/deps/rocksdb/rocksdb/db/blob/blob_constants.h +16 -0
  40. package/deps/rocksdb/rocksdb/db/blob/blob_file_addition.cc +154 -0
  41. package/deps/rocksdb/rocksdb/db/blob/blob_file_addition.h +67 -0
  42. package/deps/rocksdb/rocksdb/db/blob/blob_file_addition_test.cc +206 -0
  43. package/deps/rocksdb/rocksdb/db/blob/blob_file_builder.cc +316 -0
  44. package/deps/rocksdb/rocksdb/db/blob/blob_file_builder.h +91 -0
  45. package/deps/rocksdb/rocksdb/db/blob/blob_file_builder_test.cc +660 -0
  46. package/deps/rocksdb/rocksdb/db/blob/blob_file_cache.cc +99 -0
  47. package/deps/rocksdb/rocksdb/db/blob/blob_file_cache.h +49 -0
  48. package/deps/rocksdb/rocksdb/db/blob/blob_file_cache_test.cc +268 -0
  49. package/deps/rocksdb/rocksdb/db/blob/blob_file_garbage.cc +134 -0
  50. package/deps/rocksdb/rocksdb/db/blob/blob_file_garbage.h +57 -0
  51. package/deps/rocksdb/rocksdb/db/blob/blob_file_garbage_test.cc +173 -0
  52. package/deps/rocksdb/rocksdb/db/blob/blob_file_meta.cc +55 -0
  53. package/deps/rocksdb/rocksdb/db/blob/blob_file_meta.h +164 -0
  54. package/deps/rocksdb/rocksdb/db/blob/blob_file_reader.cc +423 -0
  55. package/deps/rocksdb/rocksdb/db/blob/blob_file_reader.h +81 -0
  56. package/deps/rocksdb/rocksdb/db/blob/blob_file_reader_test.cc +771 -0
  57. package/deps/rocksdb/rocksdb/db/blob/blob_index.h +184 -0
  58. package/deps/rocksdb/rocksdb/db/blob/blob_log_format.cc +145 -0
  59. package/deps/rocksdb/rocksdb/db/blob/blob_log_format.h +148 -0
  60. package/deps/rocksdb/rocksdb/db/blob/blob_log_sequential_reader.cc +132 -0
  61. package/deps/rocksdb/rocksdb/db/blob/blob_log_sequential_reader.h +76 -0
  62. package/deps/rocksdb/rocksdb/db/blob/blob_log_writer.cc +168 -0
  63. package/deps/rocksdb/rocksdb/db/blob/blob_log_writer.h +83 -0
  64. package/deps/rocksdb/rocksdb/db/blob/db_blob_basic_test.cc +307 -0
  65. package/deps/rocksdb/rocksdb/db/blob/db_blob_index_test.cc +464 -0
  66. package/deps/rocksdb/rocksdb/db/builder.cc +358 -0
  67. package/deps/rocksdb/rocksdb/db/builder.h +95 -0
  68. package/deps/rocksdb/rocksdb/db/c.cc +5281 -0
  69. package/deps/rocksdb/rocksdb/db/c_test.c +2883 -0
  70. package/deps/rocksdb/rocksdb/db/column_family.cc +1602 -0
  71. package/deps/rocksdb/rocksdb/db/column_family.h +787 -0
  72. package/deps/rocksdb/rocksdb/db/column_family_test.cc +3427 -0
  73. package/deps/rocksdb/rocksdb/db/compact_files_test.cc +425 -0
  74. package/deps/rocksdb/rocksdb/db/compacted_db_impl.cc +169 -0
  75. package/deps/rocksdb/rocksdb/db/compacted_db_impl.h +118 -0
  76. package/deps/rocksdb/rocksdb/db/compaction/compaction.cc +591 -0
  77. package/deps/rocksdb/rocksdb/db/compaction/compaction.h +389 -0
  78. package/deps/rocksdb/rocksdb/db/compaction/compaction_iteration_stats.h +37 -0
  79. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.cc +1023 -0
  80. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.h +353 -0
  81. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator_test.cc +1254 -0
  82. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.cc +1917 -0
  83. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.h +208 -0
  84. package/deps/rocksdb/rocksdb/db/compaction/compaction_job_stats_test.cc +1037 -0
  85. package/deps/rocksdb/rocksdb/db/compaction/compaction_job_test.cc +1224 -0
  86. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.cc +1135 -0
  87. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.h +318 -0
  88. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_fifo.cc +255 -0
  89. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_fifo.h +57 -0
  90. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_level.cc +510 -0
  91. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_level.h +33 -0
  92. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_test.cc +2190 -0
  93. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.cc +1103 -0
  94. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.h +32 -0
  95. package/deps/rocksdb/rocksdb/db/compaction/sst_partitioner.cc +44 -0
  96. package/deps/rocksdb/rocksdb/db/comparator_db_test.cc +660 -0
  97. package/deps/rocksdb/rocksdb/db/convenience.cc +78 -0
  98. package/deps/rocksdb/rocksdb/db/corruption_test.cc +921 -0
  99. package/deps/rocksdb/rocksdb/db/cuckoo_table_db_test.cc +359 -0
  100. package/deps/rocksdb/rocksdb/db/db_basic_test.cc +3820 -0
  101. package/deps/rocksdb/rocksdb/db/db_block_cache_test.cc +1058 -0
  102. package/deps/rocksdb/rocksdb/db/db_bloom_filter_test.cc +2128 -0
  103. package/deps/rocksdb/rocksdb/db/db_compaction_filter_test.cc +851 -0
  104. package/deps/rocksdb/rocksdb/db/db_compaction_test.cc +6292 -0
  105. package/deps/rocksdb/rocksdb/db/db_dynamic_level_test.cc +509 -0
  106. package/deps/rocksdb/rocksdb/db/db_encryption_test.cc +130 -0
  107. package/deps/rocksdb/rocksdb/db/db_filesnapshot.cc +137 -0
  108. package/deps/rocksdb/rocksdb/db/db_flush_test.cc +1119 -0
  109. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +5057 -0
  110. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +2274 -0
  111. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_compaction_flush.cc +3421 -0
  112. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_debug.cc +298 -0
  113. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_experimental.cc +151 -0
  114. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_files.cc +967 -0
  115. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +1806 -0
  116. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_readonly.cc +270 -0
  117. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_readonly.h +146 -0
  118. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.cc +683 -0
  119. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.h +333 -0
  120. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_write.cc +2024 -0
  121. package/deps/rocksdb/rocksdb/db/db_impl/db_secondary_test.cc +932 -0
  122. package/deps/rocksdb/rocksdb/db/db_info_dumper.cc +137 -0
  123. package/deps/rocksdb/rocksdb/db/db_info_dumper.h +15 -0
  124. package/deps/rocksdb/rocksdb/db/db_inplace_update_test.cc +178 -0
  125. package/deps/rocksdb/rocksdb/db/db_io_failure_test.cc +592 -0
  126. package/deps/rocksdb/rocksdb/db/db_iter.cc +1493 -0
  127. package/deps/rocksdb/rocksdb/db/db_iter.h +390 -0
  128. package/deps/rocksdb/rocksdb/db/db_iter_stress_test.cc +657 -0
  129. package/deps/rocksdb/rocksdb/db/db_iter_test.cc +3268 -0
  130. package/deps/rocksdb/rocksdb/db/db_iterator_test.cc +3197 -0
  131. package/deps/rocksdb/rocksdb/db/db_log_iter_test.cc +299 -0
  132. package/deps/rocksdb/rocksdb/db/db_logical_block_size_cache_test.cc +513 -0
  133. package/deps/rocksdb/rocksdb/db/db_memtable_test.cc +329 -0
  134. package/deps/rocksdb/rocksdb/db/db_merge_operand_test.cc +241 -0
  135. package/deps/rocksdb/rocksdb/db/db_merge_operator_test.cc +671 -0
  136. package/deps/rocksdb/rocksdb/db/db_options_test.cc +1022 -0
  137. package/deps/rocksdb/rocksdb/db/db_properties_test.cc +1723 -0
  138. package/deps/rocksdb/rocksdb/db/db_range_del_test.cc +1694 -0
  139. package/deps/rocksdb/rocksdb/db/db_sst_test.cc +1261 -0
  140. package/deps/rocksdb/rocksdb/db/db_statistics_test.cc +164 -0
  141. package/deps/rocksdb/rocksdb/db/db_table_properties_test.cc +488 -0
  142. package/deps/rocksdb/rocksdb/db/db_tailing_iter_test.cc +567 -0
  143. package/deps/rocksdb/rocksdb/db/db_test.cc +6736 -0
  144. package/deps/rocksdb/rocksdb/db/db_test2.cc +5408 -0
  145. package/deps/rocksdb/rocksdb/db/db_test_util.cc +1633 -0
  146. package/deps/rocksdb/rocksdb/db/db_test_util.h +1194 -0
  147. package/deps/rocksdb/rocksdb/db/db_universal_compaction_test.cc +2235 -0
  148. package/deps/rocksdb/rocksdb/db/db_wal_test.cc +1780 -0
  149. package/deps/rocksdb/rocksdb/db/db_with_timestamp_basic_test.cc +2520 -0
  150. package/deps/rocksdb/rocksdb/db/db_with_timestamp_compaction_test.cc +119 -0
  151. package/deps/rocksdb/rocksdb/db/db_write_test.cc +465 -0
  152. package/deps/rocksdb/rocksdb/db/dbformat.cc +222 -0
  153. package/deps/rocksdb/rocksdb/db/dbformat.h +786 -0
  154. package/deps/rocksdb/rocksdb/db/dbformat_test.cc +206 -0
  155. package/deps/rocksdb/rocksdb/db/deletefile_test.cc +580 -0
  156. package/deps/rocksdb/rocksdb/db/error_handler.cc +726 -0
  157. package/deps/rocksdb/rocksdb/db/error_handler.h +117 -0
  158. package/deps/rocksdb/rocksdb/db/error_handler_fs_test.cc +2598 -0
  159. package/deps/rocksdb/rocksdb/db/event_helpers.cc +233 -0
  160. package/deps/rocksdb/rocksdb/db/event_helpers.h +57 -0
  161. package/deps/rocksdb/rocksdb/db/experimental.cc +50 -0
  162. package/deps/rocksdb/rocksdb/db/external_sst_file_basic_test.cc +1559 -0
  163. package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.cc +910 -0
  164. package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.h +195 -0
  165. package/deps/rocksdb/rocksdb/db/external_sst_file_test.cc +2936 -0
  166. package/deps/rocksdb/rocksdb/db/fault_injection_test.cc +556 -0
  167. package/deps/rocksdb/rocksdb/db/file_indexer.cc +216 -0
  168. package/deps/rocksdb/rocksdb/db/file_indexer.h +142 -0
  169. package/deps/rocksdb/rocksdb/db/file_indexer_test.cc +350 -0
  170. package/deps/rocksdb/rocksdb/db/filename_test.cc +179 -0
  171. package/deps/rocksdb/rocksdb/db/flush_job.cc +514 -0
  172. package/deps/rocksdb/rocksdb/db/flush_job.h +169 -0
  173. package/deps/rocksdb/rocksdb/db/flush_job_test.cc +647 -0
  174. package/deps/rocksdb/rocksdb/db/flush_scheduler.cc +86 -0
  175. package/deps/rocksdb/rocksdb/db/flush_scheduler.h +54 -0
  176. package/deps/rocksdb/rocksdb/db/forward_iterator.cc +1023 -0
  177. package/deps/rocksdb/rocksdb/db/forward_iterator.h +163 -0
  178. package/deps/rocksdb/rocksdb/db/forward_iterator_bench.cc +377 -0
  179. package/deps/rocksdb/rocksdb/db/import_column_family_job.cc +282 -0
  180. package/deps/rocksdb/rocksdb/db/import_column_family_job.h +75 -0
  181. package/deps/rocksdb/rocksdb/db/import_column_family_test.cc +632 -0
  182. package/deps/rocksdb/rocksdb/db/internal_stats.cc +1461 -0
  183. package/deps/rocksdb/rocksdb/db/internal_stats.h +712 -0
  184. package/deps/rocksdb/rocksdb/db/job_context.h +226 -0
  185. package/deps/rocksdb/rocksdb/db/listener_test.cc +1118 -0
  186. package/deps/rocksdb/rocksdb/db/log_format.h +48 -0
  187. package/deps/rocksdb/rocksdb/db/log_reader.cc +654 -0
  188. package/deps/rocksdb/rocksdb/db/log_reader.h +192 -0
  189. package/deps/rocksdb/rocksdb/db/log_test.cc +901 -0
  190. package/deps/rocksdb/rocksdb/db/log_writer.cc +164 -0
  191. package/deps/rocksdb/rocksdb/db/log_writer.h +115 -0
  192. package/deps/rocksdb/rocksdb/db/logs_with_prep_tracker.cc +67 -0
  193. package/deps/rocksdb/rocksdb/db/logs_with_prep_tracker.h +63 -0
  194. package/deps/rocksdb/rocksdb/db/lookup_key.h +66 -0
  195. package/deps/rocksdb/rocksdb/db/malloc_stats.cc +54 -0
  196. package/deps/rocksdb/rocksdb/db/malloc_stats.h +24 -0
  197. package/deps/rocksdb/rocksdb/db/manual_compaction_test.cc +296 -0
  198. package/deps/rocksdb/rocksdb/db/memtable.cc +1169 -0
  199. package/deps/rocksdb/rocksdb/db/memtable.h +554 -0
  200. package/deps/rocksdb/rocksdb/db/memtable_list.cc +888 -0
  201. package/deps/rocksdb/rocksdb/db/memtable_list.h +438 -0
  202. package/deps/rocksdb/rocksdb/db/memtable_list_test.cc +935 -0
  203. package/deps/rocksdb/rocksdb/db/merge_context.h +134 -0
  204. package/deps/rocksdb/rocksdb/db/merge_helper.cc +421 -0
  205. package/deps/rocksdb/rocksdb/db/merge_helper.h +197 -0
  206. package/deps/rocksdb/rocksdb/db/merge_helper_test.cc +290 -0
  207. package/deps/rocksdb/rocksdb/db/merge_operator.cc +86 -0
  208. package/deps/rocksdb/rocksdb/db/merge_test.cc +608 -0
  209. package/deps/rocksdb/rocksdb/db/obsolete_files_test.cc +338 -0
  210. package/deps/rocksdb/rocksdb/db/options_file_test.cc +119 -0
  211. package/deps/rocksdb/rocksdb/db/output_validator.cc +30 -0
  212. package/deps/rocksdb/rocksdb/db/output_validator.h +47 -0
  213. package/deps/rocksdb/rocksdb/db/perf_context_test.cc +993 -0
  214. package/deps/rocksdb/rocksdb/db/periodic_work_scheduler.cc +113 -0
  215. package/deps/rocksdb/rocksdb/db/periodic_work_scheduler.h +76 -0
  216. package/deps/rocksdb/rocksdb/db/periodic_work_scheduler_test.cc +231 -0
  217. package/deps/rocksdb/rocksdb/db/pinned_iterators_manager.h +87 -0
  218. package/deps/rocksdb/rocksdb/db/plain_table_db_test.cc +1374 -0
  219. package/deps/rocksdb/rocksdb/db/pre_release_callback.h +38 -0
  220. package/deps/rocksdb/rocksdb/db/prefix_test.cc +910 -0
  221. package/deps/rocksdb/rocksdb/db/range_del_aggregator.cc +489 -0
  222. package/deps/rocksdb/rocksdb/db/range_del_aggregator.h +446 -0
  223. package/deps/rocksdb/rocksdb/db/range_del_aggregator_bench.cc +260 -0
  224. package/deps/rocksdb/rocksdb/db/range_del_aggregator_test.cc +709 -0
  225. package/deps/rocksdb/rocksdb/db/range_tombstone_fragmenter.cc +439 -0
  226. package/deps/rocksdb/rocksdb/db/range_tombstone_fragmenter.h +256 -0
  227. package/deps/rocksdb/rocksdb/db/range_tombstone_fragmenter_test.cc +552 -0
  228. package/deps/rocksdb/rocksdb/db/read_callback.h +53 -0
  229. package/deps/rocksdb/rocksdb/db/repair.cc +722 -0
  230. package/deps/rocksdb/rocksdb/db/repair_test.cc +390 -0
  231. package/deps/rocksdb/rocksdb/db/snapshot_checker.h +61 -0
  232. package/deps/rocksdb/rocksdb/db/snapshot_impl.cc +26 -0
  233. package/deps/rocksdb/rocksdb/db/snapshot_impl.h +167 -0
  234. package/deps/rocksdb/rocksdb/db/table_cache.cc +704 -0
  235. package/deps/rocksdb/rocksdb/db/table_cache.h +233 -0
  236. package/deps/rocksdb/rocksdb/db/table_properties_collector.cc +75 -0
  237. package/deps/rocksdb/rocksdb/db/table_properties_collector.h +107 -0
  238. package/deps/rocksdb/rocksdb/db/table_properties_collector_test.cc +517 -0
  239. package/deps/rocksdb/rocksdb/db/transaction_log_impl.cc +318 -0
  240. package/deps/rocksdb/rocksdb/db/transaction_log_impl.h +128 -0
  241. package/deps/rocksdb/rocksdb/db/trim_history_scheduler.cc +54 -0
  242. package/deps/rocksdb/rocksdb/db/trim_history_scheduler.h +44 -0
  243. package/deps/rocksdb/rocksdb/db/version_builder.cc +1078 -0
  244. package/deps/rocksdb/rocksdb/db/version_builder.h +69 -0
  245. package/deps/rocksdb/rocksdb/db/version_builder_test.cc +1551 -0
  246. package/deps/rocksdb/rocksdb/db/version_edit.cc +955 -0
  247. package/deps/rocksdb/rocksdb/db/version_edit.h +609 -0
  248. package/deps/rocksdb/rocksdb/db/version_edit_handler.cc +699 -0
  249. package/deps/rocksdb/rocksdb/db/version_edit_handler.h +252 -0
  250. package/deps/rocksdb/rocksdb/db/version_edit_test.cc +597 -0
  251. package/deps/rocksdb/rocksdb/db/version_set.cc +6333 -0
  252. package/deps/rocksdb/rocksdb/db/version_set.h +1485 -0
  253. package/deps/rocksdb/rocksdb/db/version_set_test.cc +3035 -0
  254. package/deps/rocksdb/rocksdb/db/wal_edit.cc +204 -0
  255. package/deps/rocksdb/rocksdb/db/wal_edit.h +166 -0
  256. package/deps/rocksdb/rocksdb/db/wal_edit_test.cc +214 -0
  257. package/deps/rocksdb/rocksdb/db/wal_manager.cc +517 -0
  258. package/deps/rocksdb/rocksdb/db/wal_manager.h +119 -0
  259. package/deps/rocksdb/rocksdb/db/wal_manager_test.cc +340 -0
  260. package/deps/rocksdb/rocksdb/db/write_batch.cc +2174 -0
  261. package/deps/rocksdb/rocksdb/db/write_batch_base.cc +94 -0
  262. package/deps/rocksdb/rocksdb/db/write_batch_internal.h +250 -0
  263. package/deps/rocksdb/rocksdb/db/write_batch_test.cc +907 -0
  264. package/deps/rocksdb/rocksdb/db/write_callback.h +27 -0
  265. package/deps/rocksdb/rocksdb/db/write_callback_test.cc +457 -0
  266. package/deps/rocksdb/rocksdb/db/write_controller.cc +128 -0
  267. package/deps/rocksdb/rocksdb/db/write_controller.h +144 -0
  268. package/deps/rocksdb/rocksdb/db/write_controller_test.cc +135 -0
  269. package/deps/rocksdb/rocksdb/db/write_thread.cc +796 -0
  270. package/deps/rocksdb/rocksdb/db/write_thread.h +433 -0
  271. package/deps/rocksdb/rocksdb/db_stress_tool/CMakeLists.txt +14 -0
  272. package/deps/rocksdb/rocksdb/db_stress_tool/batched_ops_stress.cc +341 -0
  273. package/deps/rocksdb/rocksdb/db_stress_tool/cf_consistency_stress.cc +520 -0
  274. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress.cc +23 -0
  275. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.cc +337 -0
  276. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.h +554 -0
  277. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_compaction_filter.h +79 -0
  278. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_driver.cc +173 -0
  279. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_driver.h +17 -0
  280. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_env_wrapper.h +38 -0
  281. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_gflags.cc +763 -0
  282. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_listener.h +222 -0
  283. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_shared_state.cc +27 -0
  284. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_shared_state.h +428 -0
  285. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_stat.h +218 -0
  286. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_table_properties_collector.h +64 -0
  287. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.cc +2430 -0
  288. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.h +237 -0
  289. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_tool.cc +343 -0
  290. package/deps/rocksdb/rocksdb/db_stress_tool/no_batched_ops_stress.cc +800 -0
  291. package/deps/rocksdb/rocksdb/env/composite_env_wrapper.h +920 -0
  292. package/deps/rocksdb/rocksdb/env/env.cc +733 -0
  293. package/deps/rocksdb/rocksdb/env/env_basic_test.cc +352 -0
  294. package/deps/rocksdb/rocksdb/env/env_chroot.cc +346 -0
  295. package/deps/rocksdb/rocksdb/env/env_chroot.h +22 -0
  296. package/deps/rocksdb/rocksdb/env/env_encryption.cc +1148 -0
  297. package/deps/rocksdb/rocksdb/env/env_encryption_ctr.h +137 -0
  298. package/deps/rocksdb/rocksdb/env/env_hdfs.cc +648 -0
  299. package/deps/rocksdb/rocksdb/env/env_posix.cc +514 -0
  300. package/deps/rocksdb/rocksdb/env/env_test.cc +2230 -0
  301. package/deps/rocksdb/rocksdb/env/file_system.cc +132 -0
  302. package/deps/rocksdb/rocksdb/env/file_system_tracer.cc +448 -0
  303. package/deps/rocksdb/rocksdb/env/file_system_tracer.h +415 -0
  304. package/deps/rocksdb/rocksdb/env/fs_posix.cc +1086 -0
  305. package/deps/rocksdb/rocksdb/env/io_posix.cc +1499 -0
  306. package/deps/rocksdb/rocksdb/env/io_posix.h +402 -0
  307. package/deps/rocksdb/rocksdb/env/io_posix_test.cc +140 -0
  308. package/deps/rocksdb/rocksdb/env/mock_env.cc +1066 -0
  309. package/deps/rocksdb/rocksdb/env/mock_env.h +41 -0
  310. package/deps/rocksdb/rocksdb/env/mock_env_test.cc +85 -0
  311. package/deps/rocksdb/rocksdb/file/delete_scheduler.cc +402 -0
  312. package/deps/rocksdb/rocksdb/file/delete_scheduler.h +150 -0
  313. package/deps/rocksdb/rocksdb/file/delete_scheduler_test.cc +717 -0
  314. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.cc +156 -0
  315. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.h +99 -0
  316. package/deps/rocksdb/rocksdb/file/file_util.cc +268 -0
  317. package/deps/rocksdb/rocksdb/file/file_util.h +96 -0
  318. package/deps/rocksdb/rocksdb/file/filename.cc +473 -0
  319. package/deps/rocksdb/rocksdb/file/filename.h +182 -0
  320. package/deps/rocksdb/rocksdb/file/prefetch_test.cc +188 -0
  321. package/deps/rocksdb/rocksdb/file/random_access_file_reader.cc +315 -0
  322. package/deps/rocksdb/rocksdb/file/random_access_file_reader.h +142 -0
  323. package/deps/rocksdb/rocksdb/file/random_access_file_reader_test.cc +482 -0
  324. package/deps/rocksdb/rocksdb/file/read_write_util.cc +67 -0
  325. package/deps/rocksdb/rocksdb/file/read_write_util.h +34 -0
  326. package/deps/rocksdb/rocksdb/file/readahead_raf.cc +169 -0
  327. package/deps/rocksdb/rocksdb/file/readahead_raf.h +29 -0
  328. package/deps/rocksdb/rocksdb/file/sequence_file_reader.cc +237 -0
  329. package/deps/rocksdb/rocksdb/file/sequence_file_reader.h +63 -0
  330. package/deps/rocksdb/rocksdb/file/sst_file_manager_impl.cc +552 -0
  331. package/deps/rocksdb/rocksdb/file/sst_file_manager_impl.h +203 -0
  332. package/deps/rocksdb/rocksdb/file/writable_file_writer.cc +523 -0
  333. package/deps/rocksdb/rocksdb/file/writable_file_writer.h +251 -0
  334. package/deps/rocksdb/rocksdb/hdfs/env_hdfs.h +386 -0
  335. package/deps/rocksdb/rocksdb/include/rocksdb/advanced_options.h +839 -0
  336. package/deps/rocksdb/rocksdb/include/rocksdb/c.h +2218 -0
  337. package/deps/rocksdb/rocksdb/include/rocksdb/cache.h +294 -0
  338. package/deps/rocksdb/rocksdb/include/rocksdb/cleanable.h +71 -0
  339. package/deps/rocksdb/rocksdb/include/rocksdb/compaction_filter.h +214 -0
  340. package/deps/rocksdb/rocksdb/include/rocksdb/compaction_job_stats.h +98 -0
  341. package/deps/rocksdb/rocksdb/include/rocksdb/comparator.h +137 -0
  342. package/deps/rocksdb/rocksdb/include/rocksdb/compression_type.h +40 -0
  343. package/deps/rocksdb/rocksdb/include/rocksdb/concurrent_task_limiter.h +46 -0
  344. package/deps/rocksdb/rocksdb/include/rocksdb/configurable.h +359 -0
  345. package/deps/rocksdb/rocksdb/include/rocksdb/convenience.h +499 -0
  346. package/deps/rocksdb/rocksdb/include/rocksdb/customizable.h +138 -0
  347. package/deps/rocksdb/rocksdb/include/rocksdb/db.h +1697 -0
  348. package/deps/rocksdb/rocksdb/include/rocksdb/db_bench_tool.h +11 -0
  349. package/deps/rocksdb/rocksdb/include/rocksdb/db_dump_tool.h +45 -0
  350. package/deps/rocksdb/rocksdb/include/rocksdb/db_stress_tool.h +11 -0
  351. package/deps/rocksdb/rocksdb/include/rocksdb/env.h +1671 -0
  352. package/deps/rocksdb/rocksdb/include/rocksdb/env_encryption.h +405 -0
  353. package/deps/rocksdb/rocksdb/include/rocksdb/experimental.h +29 -0
  354. package/deps/rocksdb/rocksdb/include/rocksdb/file_checksum.h +129 -0
  355. package/deps/rocksdb/rocksdb/include/rocksdb/file_system.h +1472 -0
  356. package/deps/rocksdb/rocksdb/include/rocksdb/filter_policy.h +238 -0
  357. package/deps/rocksdb/rocksdb/include/rocksdb/flush_block_policy.h +61 -0
  358. package/deps/rocksdb/rocksdb/include/rocksdb/io_status.h +269 -0
  359. package/deps/rocksdb/rocksdb/include/rocksdb/iostats_context.h +56 -0
  360. package/deps/rocksdb/rocksdb/include/rocksdb/iterator.h +128 -0
  361. package/deps/rocksdb/rocksdb/include/rocksdb/ldb_tool.h +43 -0
  362. package/deps/rocksdb/rocksdb/include/rocksdb/listener.h +556 -0
  363. package/deps/rocksdb/rocksdb/include/rocksdb/memory_allocator.h +77 -0
  364. package/deps/rocksdb/rocksdb/include/rocksdb/memtablerep.h +385 -0
  365. package/deps/rocksdb/rocksdb/include/rocksdb/merge_operator.h +257 -0
  366. package/deps/rocksdb/rocksdb/include/rocksdb/metadata.h +155 -0
  367. package/deps/rocksdb/rocksdb/include/rocksdb/options.h +1702 -0
  368. package/deps/rocksdb/rocksdb/include/rocksdb/perf_context.h +237 -0
  369. package/deps/rocksdb/rocksdb/include/rocksdb/perf_level.h +35 -0
  370. package/deps/rocksdb/rocksdb/include/rocksdb/persistent_cache.h +73 -0
  371. package/deps/rocksdb/rocksdb/include/rocksdb/rate_limiter.h +139 -0
  372. package/deps/rocksdb/rocksdb/include/rocksdb/rocksdb_namespace.h +10 -0
  373. package/deps/rocksdb/rocksdb/include/rocksdb/slice.h +269 -0
  374. package/deps/rocksdb/rocksdb/include/rocksdb/slice_transform.h +103 -0
  375. package/deps/rocksdb/rocksdb/include/rocksdb/snapshot.h +48 -0
  376. package/deps/rocksdb/rocksdb/include/rocksdb/sst_dump_tool.h +19 -0
  377. package/deps/rocksdb/rocksdb/include/rocksdb/sst_file_manager.h +136 -0
  378. package/deps/rocksdb/rocksdb/include/rocksdb/sst_file_reader.h +47 -0
  379. package/deps/rocksdb/rocksdb/include/rocksdb/sst_file_writer.h +145 -0
  380. package/deps/rocksdb/rocksdb/include/rocksdb/sst_partitioner.h +135 -0
  381. package/deps/rocksdb/rocksdb/include/rocksdb/statistics.h +592 -0
  382. package/deps/rocksdb/rocksdb/include/rocksdb/stats_history.h +69 -0
  383. package/deps/rocksdb/rocksdb/include/rocksdb/status.h +608 -0
  384. package/deps/rocksdb/rocksdb/include/rocksdb/table.h +711 -0
  385. package/deps/rocksdb/rocksdb/include/rocksdb/table_properties.h +280 -0
  386. package/deps/rocksdb/rocksdb/include/rocksdb/thread_status.h +188 -0
  387. package/deps/rocksdb/rocksdb/include/rocksdb/threadpool.h +58 -0
  388. package/deps/rocksdb/rocksdb/include/rocksdb/trace_reader_writer.h +48 -0
  389. package/deps/rocksdb/rocksdb/include/rocksdb/transaction_log.h +121 -0
  390. package/deps/rocksdb/rocksdb/include/rocksdb/types.h +74 -0
  391. package/deps/rocksdb/rocksdb/include/rocksdb/universal_compaction.h +86 -0
  392. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/backupable_db.h +535 -0
  393. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/checkpoint.h +61 -0
  394. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/convenience.h +10 -0
  395. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/db_ttl.h +72 -0
  396. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/debug.h +49 -0
  397. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/env_librados.h +175 -0
  398. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/env_mirror.h +180 -0
  399. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/info_log_finder.h +19 -0
  400. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/ldb_cmd.h +288 -0
  401. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/ldb_cmd_execute_result.h +71 -0
  402. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/leveldb_options.h +145 -0
  403. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/lua/rocks_lua_custom_library.h +43 -0
  404. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/lua/rocks_lua_util.h +55 -0
  405. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/memory_util.h +50 -0
  406. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/object_registry.h +205 -0
  407. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/optimistic_transaction_db.h +100 -0
  408. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/option_change_migration.h +19 -0
  409. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/options_type.h +876 -0
  410. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/options_util.h +128 -0
  411. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/sim_cache.h +94 -0
  412. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/stackable_db.h +504 -0
  413. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/table_properties_collectors.h +95 -0
  414. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/transaction.h +626 -0
  415. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/transaction_db.h +432 -0
  416. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/transaction_db_mutex.h +92 -0
  417. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/utility_db.h +34 -0
  418. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/write_batch_with_index.h +279 -0
  419. package/deps/rocksdb/rocksdb/include/rocksdb/version.h +16 -0
  420. package/deps/rocksdb/rocksdb/include/rocksdb/wal_filter.h +102 -0
  421. package/deps/rocksdb/rocksdb/include/rocksdb/write_batch.h +377 -0
  422. package/deps/rocksdb/rocksdb/include/rocksdb/write_batch_base.h +127 -0
  423. package/deps/rocksdb/rocksdb/include/rocksdb/write_buffer_manager.h +106 -0
  424. package/deps/rocksdb/rocksdb/logging/auto_roll_logger.cc +300 -0
  425. package/deps/rocksdb/rocksdb/logging/auto_roll_logger.h +165 -0
  426. package/deps/rocksdb/rocksdb/logging/auto_roll_logger_test.cc +684 -0
  427. package/deps/rocksdb/rocksdb/logging/env_logger.h +165 -0
  428. package/deps/rocksdb/rocksdb/logging/env_logger_test.cc +162 -0
  429. package/deps/rocksdb/rocksdb/logging/event_logger.cc +70 -0
  430. package/deps/rocksdb/rocksdb/logging/event_logger.h +203 -0
  431. package/deps/rocksdb/rocksdb/logging/event_logger_test.cc +43 -0
  432. package/deps/rocksdb/rocksdb/logging/log_buffer.cc +92 -0
  433. package/deps/rocksdb/rocksdb/logging/log_buffer.h +56 -0
  434. package/deps/rocksdb/rocksdb/logging/logging.h +68 -0
  435. package/deps/rocksdb/rocksdb/logging/posix_logger.h +185 -0
  436. package/deps/rocksdb/rocksdb/memory/allocator.h +57 -0
  437. package/deps/rocksdb/rocksdb/memory/arena.cc +233 -0
  438. package/deps/rocksdb/rocksdb/memory/arena.h +141 -0
  439. package/deps/rocksdb/rocksdb/memory/arena_test.cc +204 -0
  440. package/deps/rocksdb/rocksdb/memory/concurrent_arena.cc +47 -0
  441. package/deps/rocksdb/rocksdb/memory/concurrent_arena.h +218 -0
  442. package/deps/rocksdb/rocksdb/memory/jemalloc_nodump_allocator.cc +206 -0
  443. package/deps/rocksdb/rocksdb/memory/jemalloc_nodump_allocator.h +78 -0
  444. package/deps/rocksdb/rocksdb/memory/memkind_kmem_allocator.cc +33 -0
  445. package/deps/rocksdb/rocksdb/memory/memkind_kmem_allocator.h +27 -0
  446. package/deps/rocksdb/rocksdb/memory/memkind_kmem_allocator_test.cc +102 -0
  447. package/deps/rocksdb/rocksdb/memory/memory_allocator.h +38 -0
  448. package/deps/rocksdb/rocksdb/memory/memory_usage.h +25 -0
  449. package/deps/rocksdb/rocksdb/memtable/alloc_tracker.cc +62 -0
  450. package/deps/rocksdb/rocksdb/memtable/hash_linklist_rep.cc +844 -0
  451. package/deps/rocksdb/rocksdb/memtable/hash_linklist_rep.h +49 -0
  452. package/deps/rocksdb/rocksdb/memtable/hash_skiplist_rep.cc +349 -0
  453. package/deps/rocksdb/rocksdb/memtable/hash_skiplist_rep.h +44 -0
  454. package/deps/rocksdb/rocksdb/memtable/inlineskiplist.h +997 -0
  455. package/deps/rocksdb/rocksdb/memtable/inlineskiplist_test.cc +663 -0
  456. package/deps/rocksdb/rocksdb/memtable/memtablerep_bench.cc +677 -0
  457. package/deps/rocksdb/rocksdb/memtable/skiplist.h +496 -0
  458. package/deps/rocksdb/rocksdb/memtable/skiplist_test.cc +388 -0
  459. package/deps/rocksdb/rocksdb/memtable/skiplistrep.cc +280 -0
  460. package/deps/rocksdb/rocksdb/memtable/stl_wrappers.h +33 -0
  461. package/deps/rocksdb/rocksdb/memtable/vectorrep.cc +301 -0
  462. package/deps/rocksdb/rocksdb/memtable/write_buffer_manager.cc +148 -0
  463. package/deps/rocksdb/rocksdb/memtable/write_buffer_manager_test.cc +203 -0
  464. package/deps/rocksdb/rocksdb/monitoring/file_read_sample.h +23 -0
  465. package/deps/rocksdb/rocksdb/monitoring/histogram.cc +287 -0
  466. package/deps/rocksdb/rocksdb/monitoring/histogram.h +149 -0
  467. package/deps/rocksdb/rocksdb/monitoring/histogram_test.cc +231 -0
  468. package/deps/rocksdb/rocksdb/monitoring/histogram_windowing.cc +200 -0
  469. package/deps/rocksdb/rocksdb/monitoring/histogram_windowing.h +84 -0
  470. package/deps/rocksdb/rocksdb/monitoring/in_memory_stats_history.cc +49 -0
  471. package/deps/rocksdb/rocksdb/monitoring/in_memory_stats_history.h +74 -0
  472. package/deps/rocksdb/rocksdb/monitoring/instrumented_mutex.cc +71 -0
  473. package/deps/rocksdb/rocksdb/monitoring/instrumented_mutex.h +98 -0
  474. package/deps/rocksdb/rocksdb/monitoring/iostats_context.cc +62 -0
  475. package/deps/rocksdb/rocksdb/monitoring/iostats_context_imp.h +60 -0
  476. package/deps/rocksdb/rocksdb/monitoring/iostats_context_test.cc +29 -0
  477. package/deps/rocksdb/rocksdb/monitoring/perf_context.cc +566 -0
  478. package/deps/rocksdb/rocksdb/monitoring/perf_context_imp.h +97 -0
  479. package/deps/rocksdb/rocksdb/monitoring/perf_level.cc +28 -0
  480. package/deps/rocksdb/rocksdb/monitoring/perf_level_imp.h +18 -0
  481. package/deps/rocksdb/rocksdb/monitoring/perf_step_timer.h +79 -0
  482. package/deps/rocksdb/rocksdb/monitoring/persistent_stats_history.cc +169 -0
  483. package/deps/rocksdb/rocksdb/monitoring/persistent_stats_history.h +83 -0
  484. package/deps/rocksdb/rocksdb/monitoring/statistics.cc +431 -0
  485. package/deps/rocksdb/rocksdb/monitoring/statistics.h +138 -0
  486. package/deps/rocksdb/rocksdb/monitoring/statistics_test.cc +47 -0
  487. package/deps/rocksdb/rocksdb/monitoring/stats_history_test.cc +652 -0
  488. package/deps/rocksdb/rocksdb/monitoring/thread_status_impl.cc +163 -0
  489. package/deps/rocksdb/rocksdb/monitoring/thread_status_updater.cc +314 -0
  490. package/deps/rocksdb/rocksdb/monitoring/thread_status_updater.h +233 -0
  491. package/deps/rocksdb/rocksdb/monitoring/thread_status_updater_debug.cc +43 -0
  492. package/deps/rocksdb/rocksdb/monitoring/thread_status_util.cc +206 -0
  493. package/deps/rocksdb/rocksdb/monitoring/thread_status_util.h +134 -0
  494. package/deps/rocksdb/rocksdb/monitoring/thread_status_util_debug.cc +32 -0
  495. package/deps/rocksdb/rocksdb/options/cf_options.cc +1026 -0
  496. package/deps/rocksdb/rocksdb/options/cf_options.h +308 -0
  497. package/deps/rocksdb/rocksdb/options/configurable.cc +681 -0
  498. package/deps/rocksdb/rocksdb/options/configurable_helper.h +251 -0
  499. package/deps/rocksdb/rocksdb/options/configurable_test.cc +757 -0
  500. package/deps/rocksdb/rocksdb/options/configurable_test.h +127 -0
  501. package/deps/rocksdb/rocksdb/options/customizable.cc +77 -0
  502. package/deps/rocksdb/rocksdb/options/customizable_helper.h +216 -0
  503. package/deps/rocksdb/rocksdb/options/customizable_test.cc +625 -0
  504. package/deps/rocksdb/rocksdb/options/db_options.cc +835 -0
  505. package/deps/rocksdb/rocksdb/options/db_options.h +126 -0
  506. package/deps/rocksdb/rocksdb/options/options.cc +664 -0
  507. package/deps/rocksdb/rocksdb/options/options_helper.cc +1391 -0
  508. package/deps/rocksdb/rocksdb/options/options_helper.h +118 -0
  509. package/deps/rocksdb/rocksdb/options/options_parser.cc +721 -0
  510. package/deps/rocksdb/rocksdb/options/options_parser.h +151 -0
  511. package/deps/rocksdb/rocksdb/options/options_settable_test.cc +583 -0
  512. package/deps/rocksdb/rocksdb/options/options_test.cc +3794 -0
  513. package/deps/rocksdb/rocksdb/port/jemalloc_helper.h +106 -0
  514. package/deps/rocksdb/rocksdb/port/lang.h +16 -0
  515. package/deps/rocksdb/rocksdb/port/likely.h +18 -0
  516. package/deps/rocksdb/rocksdb/port/malloc.h +17 -0
  517. package/deps/rocksdb/rocksdb/port/port.h +21 -0
  518. package/deps/rocksdb/rocksdb/port/port_dirent.h +44 -0
  519. package/deps/rocksdb/rocksdb/port/port_example.h +101 -0
  520. package/deps/rocksdb/rocksdb/port/port_posix.cc +266 -0
  521. package/deps/rocksdb/rocksdb/port/port_posix.h +223 -0
  522. package/deps/rocksdb/rocksdb/port/stack_trace.cc +179 -0
  523. package/deps/rocksdb/rocksdb/port/stack_trace.h +28 -0
  524. package/deps/rocksdb/rocksdb/port/sys_time.h +47 -0
  525. package/deps/rocksdb/rocksdb/port/util_logger.h +20 -0
  526. package/deps/rocksdb/rocksdb/port/win/env_default.cc +45 -0
  527. package/deps/rocksdb/rocksdb/port/win/env_win.cc +1449 -0
  528. package/deps/rocksdb/rocksdb/port/win/env_win.h +294 -0
  529. package/deps/rocksdb/rocksdb/port/win/io_win.cc +1084 -0
  530. package/deps/rocksdb/rocksdb/port/win/io_win.h +494 -0
  531. package/deps/rocksdb/rocksdb/port/win/port_win.cc +283 -0
  532. package/deps/rocksdb/rocksdb/port/win/port_win.h +411 -0
  533. package/deps/rocksdb/rocksdb/port/win/win_jemalloc.cc +79 -0
  534. package/deps/rocksdb/rocksdb/port/win/win_logger.cc +194 -0
  535. package/deps/rocksdb/rocksdb/port/win/win_logger.h +67 -0
  536. package/deps/rocksdb/rocksdb/port/win/win_thread.cc +183 -0
  537. package/deps/rocksdb/rocksdb/port/win/win_thread.h +122 -0
  538. package/deps/rocksdb/rocksdb/port/win/xpress_win.cc +221 -0
  539. package/deps/rocksdb/rocksdb/port/win/xpress_win.h +26 -0
  540. package/deps/rocksdb/rocksdb/port/xpress.h +17 -0
  541. package/deps/rocksdb/rocksdb/src.mk +631 -0
  542. package/deps/rocksdb/rocksdb/table/adaptive/adaptive_table_factory.cc +126 -0
  543. package/deps/rocksdb/rocksdb/table/adaptive/adaptive_table_factory.h +57 -0
  544. package/deps/rocksdb/rocksdb/table/block_based/binary_search_index_reader.cc +73 -0
  545. package/deps/rocksdb/rocksdb/table/block_based/binary_search_index_reader.h +48 -0
  546. package/deps/rocksdb/rocksdb/table/block_based/block.cc +1049 -0
  547. package/deps/rocksdb/rocksdb/table/block_based/block.h +720 -0
  548. package/deps/rocksdb/rocksdb/table/block_based/block_based_filter_block.cc +348 -0
  549. package/deps/rocksdb/rocksdb/table/block_based/block_based_filter_block.h +119 -0
  550. package/deps/rocksdb/rocksdb/table/block_based/block_based_filter_block_test.cc +434 -0
  551. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.cc +1835 -0
  552. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.h +193 -0
  553. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_factory.cc +839 -0
  554. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_factory.h +95 -0
  555. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.cc +383 -0
  556. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.h +251 -0
  557. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.cc +3563 -0
  558. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +681 -0
  559. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_impl.h +190 -0
  560. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_test.cc +347 -0
  561. package/deps/rocksdb/rocksdb/table/block_based/block_builder.cc +201 -0
  562. package/deps/rocksdb/rocksdb/table/block_based/block_builder.h +78 -0
  563. package/deps/rocksdb/rocksdb/table/block_based/block_prefetcher.cc +66 -0
  564. package/deps/rocksdb/rocksdb/table/block_based/block_prefetcher.h +32 -0
  565. package/deps/rocksdb/rocksdb/table/block_based/block_prefix_index.cc +232 -0
  566. package/deps/rocksdb/rocksdb/table/block_based/block_prefix_index.h +66 -0
  567. package/deps/rocksdb/rocksdb/table/block_based/block_test.cc +623 -0
  568. package/deps/rocksdb/rocksdb/table/block_based/block_type.h +30 -0
  569. package/deps/rocksdb/rocksdb/table/block_based/cachable_entry.h +220 -0
  570. package/deps/rocksdb/rocksdb/table/block_based/data_block_footer.cc +59 -0
  571. package/deps/rocksdb/rocksdb/table/block_based/data_block_footer.h +25 -0
  572. package/deps/rocksdb/rocksdb/table/block_based/data_block_hash_index.cc +93 -0
  573. package/deps/rocksdb/rocksdb/table/block_based/data_block_hash_index.h +136 -0
  574. package/deps/rocksdb/rocksdb/table/block_based/data_block_hash_index_test.cc +717 -0
  575. package/deps/rocksdb/rocksdb/table/block_based/filter_block.h +180 -0
  576. package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.cc +102 -0
  577. package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.h +55 -0
  578. package/deps/rocksdb/rocksdb/table/block_based/filter_policy.cc +1407 -0
  579. package/deps/rocksdb/rocksdb/table/block_based/filter_policy_internal.h +168 -0
  580. package/deps/rocksdb/rocksdb/table/block_based/flush_block_policy.cc +88 -0
  581. package/deps/rocksdb/rocksdb/table/block_based/flush_block_policy.h +41 -0
  582. package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.cc +344 -0
  583. package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.h +139 -0
  584. package/deps/rocksdb/rocksdb/table/block_based/full_filter_block_test.cc +333 -0
  585. package/deps/rocksdb/rocksdb/table/block_based/hash_index_reader.cc +147 -0
  586. package/deps/rocksdb/rocksdb/table/block_based/hash_index_reader.h +49 -0
  587. package/deps/rocksdb/rocksdb/table/block_based/index_builder.cc +248 -0
  588. package/deps/rocksdb/rocksdb/table/block_based/index_builder.h +444 -0
  589. package/deps/rocksdb/rocksdb/table/block_based/index_reader_common.cc +54 -0
  590. package/deps/rocksdb/rocksdb/table/block_based/index_reader_common.h +85 -0
  591. package/deps/rocksdb/rocksdb/table/block_based/mock_block_based_table.h +56 -0
  592. package/deps/rocksdb/rocksdb/table/block_based/parsed_full_filter_block.cc +22 -0
  593. package/deps/rocksdb/rocksdb/table/block_based/parsed_full_filter_block.h +40 -0
  594. package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.cc +521 -0
  595. package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.h +144 -0
  596. package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block_test.cc +424 -0
  597. package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_iterator.cc +163 -0
  598. package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_iterator.h +142 -0
  599. package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_reader.cc +186 -0
  600. package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_reader.h +51 -0
  601. package/deps/rocksdb/rocksdb/table/block_based/reader_common.cc +64 -0
  602. package/deps/rocksdb/rocksdb/table/block_based/reader_common.h +38 -0
  603. package/deps/rocksdb/rocksdb/table/block_based/uncompression_dict_reader.cc +120 -0
  604. package/deps/rocksdb/rocksdb/table/block_based/uncompression_dict_reader.h +59 -0
  605. package/deps/rocksdb/rocksdb/table/block_fetcher.cc +324 -0
  606. package/deps/rocksdb/rocksdb/table/block_fetcher.h +129 -0
  607. package/deps/rocksdb/rocksdb/table/block_fetcher_test.cc +534 -0
  608. package/deps/rocksdb/rocksdb/table/cleanable_test.cc +277 -0
  609. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_builder.cc +543 -0
  610. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_builder.h +136 -0
  611. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_builder_test.cc +663 -0
  612. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_factory.cc +107 -0
  613. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_factory.h +81 -0
  614. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_reader.cc +404 -0
  615. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_reader.h +101 -0
  616. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_reader_test.cc +585 -0
  617. package/deps/rocksdb/rocksdb/table/format.cc +422 -0
  618. package/deps/rocksdb/rocksdb/table/format.h +348 -0
  619. package/deps/rocksdb/rocksdb/table/get_context.cc +408 -0
  620. package/deps/rocksdb/rocksdb/table/get_context.h +212 -0
  621. package/deps/rocksdb/rocksdb/table/internal_iterator.h +205 -0
  622. package/deps/rocksdb/rocksdb/table/iter_heap.h +42 -0
  623. package/deps/rocksdb/rocksdb/table/iterator.cc +210 -0
  624. package/deps/rocksdb/rocksdb/table/iterator_wrapper.h +180 -0
  625. package/deps/rocksdb/rocksdb/table/merger_test.cc +180 -0
  626. package/deps/rocksdb/rocksdb/table/merging_iterator.cc +481 -0
  627. package/deps/rocksdb/rocksdb/table/merging_iterator.h +64 -0
  628. package/deps/rocksdb/rocksdb/table/meta_blocks.cc +541 -0
  629. package/deps/rocksdb/rocksdb/table/meta_blocks.h +154 -0
  630. package/deps/rocksdb/rocksdb/table/mock_table.cc +328 -0
  631. package/deps/rocksdb/rocksdb/table/mock_table.h +89 -0
  632. package/deps/rocksdb/rocksdb/table/multiget_context.h +282 -0
  633. package/deps/rocksdb/rocksdb/table/persistent_cache_helper.cc +116 -0
  634. package/deps/rocksdb/rocksdb/table/persistent_cache_helper.h +44 -0
  635. package/deps/rocksdb/rocksdb/table/persistent_cache_options.h +34 -0
  636. package/deps/rocksdb/rocksdb/table/plain/plain_table_bloom.cc +78 -0
  637. package/deps/rocksdb/rocksdb/table/plain/plain_table_bloom.h +135 -0
  638. package/deps/rocksdb/rocksdb/table/plain/plain_table_builder.cc +332 -0
  639. package/deps/rocksdb/rocksdb/table/plain/plain_table_builder.h +153 -0
  640. package/deps/rocksdb/rocksdb/table/plain/plain_table_factory.cc +263 -0
  641. package/deps/rocksdb/rocksdb/table/plain/plain_table_factory.h +182 -0
  642. package/deps/rocksdb/rocksdb/table/plain/plain_table_index.cc +211 -0
  643. package/deps/rocksdb/rocksdb/table/plain/plain_table_index.h +249 -0
  644. package/deps/rocksdb/rocksdb/table/plain/plain_table_key_coding.cc +506 -0
  645. package/deps/rocksdb/rocksdb/table/plain/plain_table_key_coding.h +201 -0
  646. package/deps/rocksdb/rocksdb/table/plain/plain_table_reader.cc +781 -0
  647. package/deps/rocksdb/rocksdb/table/plain/plain_table_reader.h +247 -0
  648. package/deps/rocksdb/rocksdb/table/scoped_arena_iterator.h +61 -0
  649. package/deps/rocksdb/rocksdb/table/sst_file_dumper.cc +502 -0
  650. package/deps/rocksdb/rocksdb/table/sst_file_dumper.h +96 -0
  651. package/deps/rocksdb/rocksdb/table/sst_file_reader.cc +98 -0
  652. package/deps/rocksdb/rocksdb/table/sst_file_reader_test.cc +228 -0
  653. package/deps/rocksdb/rocksdb/table/sst_file_writer.cc +340 -0
  654. package/deps/rocksdb/rocksdb/table/sst_file_writer_collectors.h +94 -0
  655. package/deps/rocksdb/rocksdb/table/table_builder.h +203 -0
  656. package/deps/rocksdb/rocksdb/table/table_factory.cc +38 -0
  657. package/deps/rocksdb/rocksdb/table/table_properties.cc +300 -0
  658. package/deps/rocksdb/rocksdb/table/table_properties_internal.h +30 -0
  659. package/deps/rocksdb/rocksdb/table/table_reader.h +147 -0
  660. package/deps/rocksdb/rocksdb/table/table_reader_bench.cc +347 -0
  661. package/deps/rocksdb/rocksdb/table/table_reader_caller.h +39 -0
  662. package/deps/rocksdb/rocksdb/table/table_test.cc +4769 -0
  663. package/deps/rocksdb/rocksdb/table/two_level_iterator.cc +215 -0
  664. package/deps/rocksdb/rocksdb/table/two_level_iterator.h +43 -0
  665. package/deps/rocksdb/rocksdb/test_util/mock_time_env.cc +38 -0
  666. package/deps/rocksdb/rocksdb/test_util/mock_time_env.h +74 -0
  667. package/deps/rocksdb/rocksdb/test_util/sync_point.cc +93 -0
  668. package/deps/rocksdb/rocksdb/test_util/sync_point.h +161 -0
  669. package/deps/rocksdb/rocksdb/test_util/sync_point_impl.cc +129 -0
  670. package/deps/rocksdb/rocksdb/test_util/sync_point_impl.h +74 -0
  671. package/deps/rocksdb/rocksdb/test_util/testharness.cc +56 -0
  672. package/deps/rocksdb/rocksdb/test_util/testharness.h +53 -0
  673. package/deps/rocksdb/rocksdb/test_util/testutil.cc +566 -0
  674. package/deps/rocksdb/rocksdb/test_util/testutil.h +887 -0
  675. package/deps/rocksdb/rocksdb/test_util/testutil_test.cc +43 -0
  676. package/deps/rocksdb/rocksdb/test_util/transaction_test_util.cc +388 -0
  677. package/deps/rocksdb/rocksdb/test_util/transaction_test_util.h +132 -0
  678. package/deps/rocksdb/rocksdb/third-party/folly/folly/CPortability.h +27 -0
  679. package/deps/rocksdb/rocksdb/third-party/folly/folly/ConstexprMath.h +45 -0
  680. package/deps/rocksdb/rocksdb/third-party/folly/folly/Indestructible.h +166 -0
  681. package/deps/rocksdb/rocksdb/third-party/folly/folly/Optional.h +570 -0
  682. package/deps/rocksdb/rocksdb/third-party/folly/folly/Portability.h +92 -0
  683. package/deps/rocksdb/rocksdb/third-party/folly/folly/ScopeGuard.h +54 -0
  684. package/deps/rocksdb/rocksdb/third-party/folly/folly/Traits.h +152 -0
  685. package/deps/rocksdb/rocksdb/third-party/folly/folly/Unit.h +59 -0
  686. package/deps/rocksdb/rocksdb/third-party/folly/folly/Utility.h +141 -0
  687. package/deps/rocksdb/rocksdb/third-party/folly/folly/chrono/Hardware.h +33 -0
  688. package/deps/rocksdb/rocksdb/third-party/folly/folly/container/Array.h +74 -0
  689. package/deps/rocksdb/rocksdb/third-party/folly/folly/detail/Futex-inl.h +117 -0
  690. package/deps/rocksdb/rocksdb/third-party/folly/folly/detail/Futex.cpp +263 -0
  691. package/deps/rocksdb/rocksdb/third-party/folly/folly/detail/Futex.h +96 -0
  692. package/deps/rocksdb/rocksdb/third-party/folly/folly/functional/Invoke.h +40 -0
  693. package/deps/rocksdb/rocksdb/third-party/folly/folly/hash/Hash.h +29 -0
  694. package/deps/rocksdb/rocksdb/third-party/folly/folly/lang/Align.h +144 -0
  695. package/deps/rocksdb/rocksdb/third-party/folly/folly/lang/Bits.h +30 -0
  696. package/deps/rocksdb/rocksdb/third-party/folly/folly/lang/Launder.h +51 -0
  697. package/deps/rocksdb/rocksdb/third-party/folly/folly/portability/Asm.h +28 -0
  698. package/deps/rocksdb/rocksdb/third-party/folly/folly/portability/SysSyscall.h +10 -0
  699. package/deps/rocksdb/rocksdb/third-party/folly/folly/portability/SysTypes.h +26 -0
  700. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/AtomicNotification-inl.h +138 -0
  701. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/AtomicNotification.cpp +23 -0
  702. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/AtomicNotification.h +57 -0
  703. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/AtomicUtil-inl.h +260 -0
  704. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/AtomicUtil.h +52 -0
  705. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/Baton.h +328 -0
  706. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/DistributedMutex-inl.h +1703 -0
  707. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/DistributedMutex.cpp +16 -0
  708. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/DistributedMutex.h +304 -0
  709. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/DistributedMutexSpecializations.h +39 -0
  710. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/ParkingLot.cpp +26 -0
  711. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/ParkingLot.h +318 -0
  712. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/WaitOptions.cpp +12 -0
  713. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/WaitOptions.h +57 -0
  714. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/detail/InlineFunctionRef.h +219 -0
  715. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/detail/ProxyLockable-inl.h +207 -0
  716. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/detail/ProxyLockable.h +164 -0
  717. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/detail/Sleeper.h +57 -0
  718. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/detail/Spin.h +77 -0
  719. package/deps/rocksdb/rocksdb/third-party/gcc/ppc-asm.h +390 -0
  720. package/deps/rocksdb/rocksdb/thirdparty.inc +268 -0
  721. package/deps/rocksdb/rocksdb/tools/CMakeLists.txt +30 -0
  722. package/deps/rocksdb/rocksdb/tools/blob_dump.cc +110 -0
  723. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/__init__.py +2 -0
  724. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_pysim.py +2000 -0
  725. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_pysim.sh +156 -0
  726. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_pysim_test.py +734 -0
  727. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer.cc +2307 -0
  728. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer.h +395 -0
  729. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer_plot.py +721 -0
  730. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer_test.cc +719 -0
  731. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer_tool.cc +25 -0
  732. package/deps/rocksdb/rocksdb/tools/db_bench.cc +21 -0
  733. package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +7416 -0
  734. package/deps/rocksdb/rocksdb/tools/db_bench_tool_test.cc +328 -0
  735. package/deps/rocksdb/rocksdb/tools/db_repl_stress.cc +130 -0
  736. package/deps/rocksdb/rocksdb/tools/db_sanity_test.cc +297 -0
  737. package/deps/rocksdb/rocksdb/tools/dump/db_dump_tool.cc +259 -0
  738. package/deps/rocksdb/rocksdb/tools/dump/rocksdb_dump.cc +63 -0
  739. package/deps/rocksdb/rocksdb/tools/dump/rocksdb_undump.cc +62 -0
  740. package/deps/rocksdb/rocksdb/tools/io_tracer_parser.cc +25 -0
  741. package/deps/rocksdb/rocksdb/tools/io_tracer_parser_test.cc +187 -0
  742. package/deps/rocksdb/rocksdb/tools/io_tracer_parser_tool.cc +120 -0
  743. package/deps/rocksdb/rocksdb/tools/io_tracer_parser_tool.h +40 -0
  744. package/deps/rocksdb/rocksdb/tools/ldb.cc +21 -0
  745. package/deps/rocksdb/rocksdb/tools/ldb_cmd.cc +3609 -0
  746. package/deps/rocksdb/rocksdb/tools/ldb_cmd_impl.h +665 -0
  747. package/deps/rocksdb/rocksdb/tools/ldb_cmd_test.cc +746 -0
  748. package/deps/rocksdb/rocksdb/tools/ldb_tool.cc +159 -0
  749. package/deps/rocksdb/rocksdb/tools/reduce_levels_test.cc +221 -0
  750. package/deps/rocksdb/rocksdb/tools/sst_dump.cc +20 -0
  751. package/deps/rocksdb/rocksdb/tools/sst_dump_test.cc +427 -0
  752. package/deps/rocksdb/rocksdb/tools/sst_dump_tool.cc +541 -0
  753. package/deps/rocksdb/rocksdb/tools/trace_analyzer.cc +25 -0
  754. package/deps/rocksdb/rocksdb/tools/trace_analyzer_test.cc +752 -0
  755. package/deps/rocksdb/rocksdb/tools/trace_analyzer_tool.cc +2001 -0
  756. package/deps/rocksdb/rocksdb/tools/trace_analyzer_tool.h +292 -0
  757. package/deps/rocksdb/rocksdb/tools/write_stress.cc +305 -0
  758. package/deps/rocksdb/rocksdb/trace_replay/block_cache_tracer.cc +496 -0
  759. package/deps/rocksdb/rocksdb/trace_replay/block_cache_tracer.h +294 -0
  760. package/deps/rocksdb/rocksdb/trace_replay/block_cache_tracer_test.cc +379 -0
  761. package/deps/rocksdb/rocksdb/trace_replay/io_tracer.cc +229 -0
  762. package/deps/rocksdb/rocksdb/trace_replay/io_tracer.h +174 -0
  763. package/deps/rocksdb/rocksdb/trace_replay/io_tracer_test.cc +215 -0
  764. package/deps/rocksdb/rocksdb/trace_replay/trace_replay.cc +491 -0
  765. package/deps/rocksdb/rocksdb/trace_replay/trace_replay.h +195 -0
  766. package/deps/rocksdb/rocksdb/util/aligned_buffer.h +255 -0
  767. package/deps/rocksdb/rocksdb/util/autovector.h +367 -0
  768. package/deps/rocksdb/rocksdb/util/autovector_test.cc +330 -0
  769. package/deps/rocksdb/rocksdb/util/bloom_impl.h +485 -0
  770. package/deps/rocksdb/rocksdb/util/bloom_test.cc +1191 -0
  771. package/deps/rocksdb/rocksdb/util/build_version.cc.in +5 -0
  772. package/deps/rocksdb/rocksdb/util/build_version.h +15 -0
  773. package/deps/rocksdb/rocksdb/util/cast_util.h +20 -0
  774. package/deps/rocksdb/rocksdb/util/channel.h +67 -0
  775. package/deps/rocksdb/rocksdb/util/coding.cc +89 -0
  776. package/deps/rocksdb/rocksdb/util/coding.h +419 -0
  777. package/deps/rocksdb/rocksdb/util/coding_lean.h +101 -0
  778. package/deps/rocksdb/rocksdb/util/coding_test.cc +217 -0
  779. package/deps/rocksdb/rocksdb/util/compaction_job_stats_impl.cc +92 -0
  780. package/deps/rocksdb/rocksdb/util/comparator.cc +219 -0
  781. package/deps/rocksdb/rocksdb/util/compression.h +1529 -0
  782. package/deps/rocksdb/rocksdb/util/compression_context_cache.cc +108 -0
  783. package/deps/rocksdb/rocksdb/util/compression_context_cache.h +47 -0
  784. package/deps/rocksdb/rocksdb/util/concurrent_task_limiter_impl.cc +67 -0
  785. package/deps/rocksdb/rocksdb/util/concurrent_task_limiter_impl.h +67 -0
  786. package/deps/rocksdb/rocksdb/util/core_local.h +83 -0
  787. package/deps/rocksdb/rocksdb/util/crc32c.cc +1283 -0
  788. package/deps/rocksdb/rocksdb/util/crc32c.h +51 -0
  789. package/deps/rocksdb/rocksdb/util/crc32c_arm64.cc +169 -0
  790. package/deps/rocksdb/rocksdb/util/crc32c_arm64.h +50 -0
  791. package/deps/rocksdb/rocksdb/util/crc32c_ppc.c +94 -0
  792. package/deps/rocksdb/rocksdb/util/crc32c_ppc.h +19 -0
  793. package/deps/rocksdb/rocksdb/util/crc32c_ppc_asm.S +756 -0
  794. package/deps/rocksdb/rocksdb/util/crc32c_ppc_constants.h +900 -0
  795. package/deps/rocksdb/rocksdb/util/crc32c_test.cc +180 -0
  796. package/deps/rocksdb/rocksdb/util/defer.h +52 -0
  797. package/deps/rocksdb/rocksdb/util/defer_test.cc +39 -0
  798. package/deps/rocksdb/rocksdb/util/duplicate_detector.h +68 -0
  799. package/deps/rocksdb/rocksdb/util/dynamic_bloom.cc +70 -0
  800. package/deps/rocksdb/rocksdb/util/dynamic_bloom.h +214 -0
  801. package/deps/rocksdb/rocksdb/util/dynamic_bloom_test.cc +323 -0
  802. package/deps/rocksdb/rocksdb/util/fastrange.h +112 -0
  803. package/deps/rocksdb/rocksdb/util/file_checksum_helper.cc +136 -0
  804. package/deps/rocksdb/rocksdb/util/file_checksum_helper.h +98 -0
  805. package/deps/rocksdb/rocksdb/util/file_reader_writer_test.cc +449 -0
  806. package/deps/rocksdb/rocksdb/util/filelock_test.cc +152 -0
  807. package/deps/rocksdb/rocksdb/util/filter_bench.cc +781 -0
  808. package/deps/rocksdb/rocksdb/util/gflags_compat.h +20 -0
  809. package/deps/rocksdb/rocksdb/util/hash.cc +83 -0
  810. package/deps/rocksdb/rocksdb/util/hash.h +107 -0
  811. package/deps/rocksdb/rocksdb/util/hash_map.h +67 -0
  812. package/deps/rocksdb/rocksdb/util/hash_test.cc +593 -0
  813. package/deps/rocksdb/rocksdb/util/heap.h +166 -0
  814. package/deps/rocksdb/rocksdb/util/heap_test.cc +139 -0
  815. package/deps/rocksdb/rocksdb/util/kv_map.h +33 -0
  816. package/deps/rocksdb/rocksdb/util/log_write_bench.cc +86 -0
  817. package/deps/rocksdb/rocksdb/util/math.h +186 -0
  818. package/deps/rocksdb/rocksdb/util/math128.h +298 -0
  819. package/deps/rocksdb/rocksdb/util/murmurhash.cc +191 -0
  820. package/deps/rocksdb/rocksdb/util/murmurhash.h +42 -0
  821. package/deps/rocksdb/rocksdb/util/mutexlock.h +186 -0
  822. package/deps/rocksdb/rocksdb/util/ppc-opcode.h +27 -0
  823. package/deps/rocksdb/rocksdb/util/random.cc +56 -0
  824. package/deps/rocksdb/rocksdb/util/random.h +186 -0
  825. package/deps/rocksdb/rocksdb/util/random_test.cc +105 -0
  826. package/deps/rocksdb/rocksdb/util/rate_limiter.cc +340 -0
  827. package/deps/rocksdb/rocksdb/util/rate_limiter.h +113 -0
  828. package/deps/rocksdb/rocksdb/util/rate_limiter_test.cc +251 -0
  829. package/deps/rocksdb/rocksdb/util/repeatable_thread.h +151 -0
  830. package/deps/rocksdb/rocksdb/util/repeatable_thread_test.cc +107 -0
  831. package/deps/rocksdb/rocksdb/util/ribbon_alg.h +1201 -0
  832. package/deps/rocksdb/rocksdb/util/ribbon_impl.h +1062 -0
  833. package/deps/rocksdb/rocksdb/util/ribbon_test.cc +931 -0
  834. package/deps/rocksdb/rocksdb/util/set_comparator.h +22 -0
  835. package/deps/rocksdb/rocksdb/util/slice.cc +243 -0
  836. package/deps/rocksdb/rocksdb/util/slice_test.cc +163 -0
  837. package/deps/rocksdb/rocksdb/util/slice_transform_test.cc +153 -0
  838. package/deps/rocksdb/rocksdb/util/status.cc +149 -0
  839. package/deps/rocksdb/rocksdb/util/stderr_logger.h +31 -0
  840. package/deps/rocksdb/rocksdb/util/stop_watch.h +118 -0
  841. package/deps/rocksdb/rocksdb/util/string_util.cc +422 -0
  842. package/deps/rocksdb/rocksdb/util/string_util.h +144 -0
  843. package/deps/rocksdb/rocksdb/util/thread_list_test.cc +354 -0
  844. package/deps/rocksdb/rocksdb/util/thread_local.cc +554 -0
  845. package/deps/rocksdb/rocksdb/util/thread_local.h +101 -0
  846. package/deps/rocksdb/rocksdb/util/thread_local_test.cc +583 -0
  847. package/deps/rocksdb/rocksdb/util/thread_operation.h +121 -0
  848. package/deps/rocksdb/rocksdb/util/threadpool_imp.cc +506 -0
  849. package/deps/rocksdb/rocksdb/util/threadpool_imp.h +112 -0
  850. package/deps/rocksdb/rocksdb/util/timer.h +331 -0
  851. package/deps/rocksdb/rocksdb/util/timer_queue.h +230 -0
  852. package/deps/rocksdb/rocksdb/util/timer_queue_test.cc +72 -0
  853. package/deps/rocksdb/rocksdb/util/timer_test.cc +399 -0
  854. package/deps/rocksdb/rocksdb/util/user_comparator_wrapper.h +80 -0
  855. package/deps/rocksdb/rocksdb/util/vector_iterator.h +101 -0
  856. package/deps/rocksdb/rocksdb/util/work_queue.h +148 -0
  857. package/deps/rocksdb/rocksdb/util/work_queue_test.cc +268 -0
  858. package/deps/rocksdb/rocksdb/util/xxh3p.h +1392 -0
  859. package/deps/rocksdb/rocksdb/util/xxhash.cc +1158 -0
  860. package/deps/rocksdb/rocksdb/util/xxhash.h +598 -0
  861. package/deps/rocksdb/rocksdb/utilities/backupable/backupable_db.cc +2354 -0
  862. package/deps/rocksdb/rocksdb/utilities/backupable/backupable_db_test.cc +2955 -0
  863. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_compaction_filter.cc +488 -0
  864. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_compaction_filter.h +199 -0
  865. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db.cc +112 -0
  866. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db.h +266 -0
  867. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_gc_stats.h +52 -0
  868. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_impl.cc +2167 -0
  869. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_impl.h +500 -0
  870. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_impl_filesnapshot.cc +113 -0
  871. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_iterator.h +147 -0
  872. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_listener.h +66 -0
  873. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_test.cc +2386 -0
  874. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_dump_tool.cc +281 -0
  875. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_dump_tool.h +58 -0
  876. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_file.cc +314 -0
  877. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_file.h +244 -0
  878. package/deps/rocksdb/rocksdb/utilities/cassandra/cassandra_compaction_filter.cc +47 -0
  879. package/deps/rocksdb/rocksdb/utilities/cassandra/cassandra_compaction_filter.h +42 -0
  880. package/deps/rocksdb/rocksdb/utilities/cassandra/cassandra_format_test.cc +375 -0
  881. package/deps/rocksdb/rocksdb/utilities/cassandra/cassandra_functional_test.cc +327 -0
  882. package/deps/rocksdb/rocksdb/utilities/cassandra/cassandra_row_merge_test.cc +114 -0
  883. package/deps/rocksdb/rocksdb/utilities/cassandra/cassandra_serialize_test.cc +187 -0
  884. package/deps/rocksdb/rocksdb/utilities/cassandra/format.cc +390 -0
  885. package/deps/rocksdb/rocksdb/utilities/cassandra/format.h +184 -0
  886. package/deps/rocksdb/rocksdb/utilities/cassandra/merge_operator.cc +67 -0
  887. package/deps/rocksdb/rocksdb/utilities/cassandra/merge_operator.h +44 -0
  888. package/deps/rocksdb/rocksdb/utilities/cassandra/serialize.h +75 -0
  889. package/deps/rocksdb/rocksdb/utilities/cassandra/test_utils.cc +72 -0
  890. package/deps/rocksdb/rocksdb/utilities/cassandra/test_utils.h +43 -0
  891. package/deps/rocksdb/rocksdb/utilities/checkpoint/checkpoint_impl.cc +588 -0
  892. package/deps/rocksdb/rocksdb/utilities/checkpoint/checkpoint_impl.h +82 -0
  893. package/deps/rocksdb/rocksdb/utilities/checkpoint/checkpoint_test.cc +821 -0
  894. package/deps/rocksdb/rocksdb/utilities/compaction_filters/layered_compaction_filter_base.h +37 -0
  895. package/deps/rocksdb/rocksdb/utilities/compaction_filters/remove_emptyvalue_compactionfilter.cc +29 -0
  896. package/deps/rocksdb/rocksdb/utilities/compaction_filters/remove_emptyvalue_compactionfilter.h +27 -0
  897. package/deps/rocksdb/rocksdb/utilities/convenience/info_log_finder.cc +25 -0
  898. package/deps/rocksdb/rocksdb/utilities/debug.cc +82 -0
  899. package/deps/rocksdb/rocksdb/utilities/env_librados.cc +1497 -0
  900. package/deps/rocksdb/rocksdb/utilities/env_librados_test.cc +1146 -0
  901. package/deps/rocksdb/rocksdb/utilities/env_mirror.cc +262 -0
  902. package/deps/rocksdb/rocksdb/utilities/env_mirror_test.cc +223 -0
  903. package/deps/rocksdb/rocksdb/utilities/env_timed.cc +145 -0
  904. package/deps/rocksdb/rocksdb/utilities/env_timed_test.cc +44 -0
  905. package/deps/rocksdb/rocksdb/utilities/fault_injection_env.cc +490 -0
  906. package/deps/rocksdb/rocksdb/utilities/fault_injection_env.h +242 -0
  907. package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.cc +581 -0
  908. package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.h +437 -0
  909. package/deps/rocksdb/rocksdb/utilities/leveldb_options/leveldb_options.cc +56 -0
  910. package/deps/rocksdb/rocksdb/utilities/memory/memory_test.cc +275 -0
  911. package/deps/rocksdb/rocksdb/utilities/memory/memory_util.cc +52 -0
  912. package/deps/rocksdb/rocksdb/utilities/merge_operators/bytesxor.cc +59 -0
  913. package/deps/rocksdb/rocksdb/utilities/merge_operators/bytesxor.h +39 -0
  914. package/deps/rocksdb/rocksdb/utilities/merge_operators/max.cc +77 -0
  915. package/deps/rocksdb/rocksdb/utilities/merge_operators/put.cc +83 -0
  916. package/deps/rocksdb/rocksdb/utilities/merge_operators/sortlist.cc +97 -0
  917. package/deps/rocksdb/rocksdb/utilities/merge_operators/sortlist.h +38 -0
  918. package/deps/rocksdb/rocksdb/utilities/merge_operators/string_append/stringappend.cc +59 -0
  919. package/deps/rocksdb/rocksdb/utilities/merge_operators/string_append/stringappend.h +31 -0
  920. package/deps/rocksdb/rocksdb/utilities/merge_operators/string_append/stringappend2.cc +117 -0
  921. package/deps/rocksdb/rocksdb/utilities/merge_operators/string_append/stringappend2.h +49 -0
  922. package/deps/rocksdb/rocksdb/utilities/merge_operators/string_append/stringappend_test.cc +598 -0
  923. package/deps/rocksdb/rocksdb/utilities/merge_operators/uint64add.cc +69 -0
  924. package/deps/rocksdb/rocksdb/utilities/merge_operators.h +55 -0
  925. package/deps/rocksdb/rocksdb/utilities/object_registry.cc +87 -0
  926. package/deps/rocksdb/rocksdb/utilities/object_registry_test.cc +174 -0
  927. package/deps/rocksdb/rocksdb/utilities/option_change_migration/option_change_migration.cc +168 -0
  928. package/deps/rocksdb/rocksdb/utilities/option_change_migration/option_change_migration_test.cc +431 -0
  929. package/deps/rocksdb/rocksdb/utilities/options/options_util.cc +159 -0
  930. package/deps/rocksdb/rocksdb/utilities/options/options_util_test.cc +655 -0
  931. package/deps/rocksdb/rocksdb/utilities/persistent_cache/block_cache_tier.cc +425 -0
  932. package/deps/rocksdb/rocksdb/utilities/persistent_cache/block_cache_tier.h +156 -0
  933. package/deps/rocksdb/rocksdb/utilities/persistent_cache/block_cache_tier_file.cc +609 -0
  934. package/deps/rocksdb/rocksdb/utilities/persistent_cache/block_cache_tier_file.h +296 -0
  935. package/deps/rocksdb/rocksdb/utilities/persistent_cache/block_cache_tier_file_buffer.h +127 -0
  936. package/deps/rocksdb/rocksdb/utilities/persistent_cache/block_cache_tier_metadata.cc +86 -0
  937. package/deps/rocksdb/rocksdb/utilities/persistent_cache/block_cache_tier_metadata.h +125 -0
  938. package/deps/rocksdb/rocksdb/utilities/persistent_cache/hash_table.h +238 -0
  939. package/deps/rocksdb/rocksdb/utilities/persistent_cache/hash_table_bench.cc +308 -0
  940. package/deps/rocksdb/rocksdb/utilities/persistent_cache/hash_table_evictable.h +168 -0
  941. package/deps/rocksdb/rocksdb/utilities/persistent_cache/hash_table_test.cc +160 -0
  942. package/deps/rocksdb/rocksdb/utilities/persistent_cache/lrulist.h +174 -0
  943. package/deps/rocksdb/rocksdb/utilities/persistent_cache/persistent_cache_bench.cc +360 -0
  944. package/deps/rocksdb/rocksdb/utilities/persistent_cache/persistent_cache_test.cc +456 -0
  945. package/deps/rocksdb/rocksdb/utilities/persistent_cache/persistent_cache_test.h +286 -0
  946. package/deps/rocksdb/rocksdb/utilities/persistent_cache/persistent_cache_tier.cc +167 -0
  947. package/deps/rocksdb/rocksdb/utilities/persistent_cache/persistent_cache_tier.h +339 -0
  948. package/deps/rocksdb/rocksdb/utilities/persistent_cache/persistent_cache_util.h +67 -0
  949. package/deps/rocksdb/rocksdb/utilities/persistent_cache/volatile_tier_impl.cc +140 -0
  950. package/deps/rocksdb/rocksdb/utilities/persistent_cache/volatile_tier_impl.h +142 -0
  951. package/deps/rocksdb/rocksdb/utilities/simulator_cache/cache_simulator.cc +285 -0
  952. package/deps/rocksdb/rocksdb/utilities/simulator_cache/cache_simulator.h +231 -0
  953. package/deps/rocksdb/rocksdb/utilities/simulator_cache/cache_simulator_test.cc +494 -0
  954. package/deps/rocksdb/rocksdb/utilities/simulator_cache/sim_cache.cc +356 -0
  955. package/deps/rocksdb/rocksdb/utilities/simulator_cache/sim_cache_test.cc +224 -0
  956. package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.cc +122 -0
  957. package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.h +72 -0
  958. package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector_test.cc +244 -0
  959. package/deps/rocksdb/rocksdb/utilities/trace/file_trace_reader_writer.cc +125 -0
  960. package/deps/rocksdb/rocksdb/utilities/trace/file_trace_reader_writer.h +48 -0
  961. package/deps/rocksdb/rocksdb/utilities/transactions/lock/lock_manager.cc +29 -0
  962. package/deps/rocksdb/rocksdb/utilities/transactions/lock/lock_manager.h +82 -0
  963. package/deps/rocksdb/rocksdb/utilities/transactions/lock/lock_tracker.h +209 -0
  964. package/deps/rocksdb/rocksdb/utilities/transactions/lock/point/point_lock_manager.cc +720 -0
  965. package/deps/rocksdb/rocksdb/utilities/transactions/lock/point/point_lock_manager.h +223 -0
  966. package/deps/rocksdb/rocksdb/utilities/transactions/lock/point/point_lock_manager_test.cc +181 -0
  967. package/deps/rocksdb/rocksdb/utilities/transactions/lock/point/point_lock_manager_test.h +319 -0
  968. package/deps/rocksdb/rocksdb/utilities/transactions/lock/point/point_lock_tracker.cc +270 -0
  969. package/deps/rocksdb/rocksdb/utilities/transactions/lock/point/point_lock_tracker.h +99 -0
  970. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_lock_manager.h +30 -0
  971. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_locking_test.cc +306 -0
  972. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/COPYING.AGPLv3 +661 -0
  973. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/COPYING.APACHEv2 +174 -0
  974. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/COPYING.GPLv2 +339 -0
  975. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/db.h +76 -0
  976. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/ft/comparator.h +138 -0
  977. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/ft/ft-status.h +102 -0
  978. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/concurrent_tree.cc +139 -0
  979. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/concurrent_tree.h +174 -0
  980. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/keyrange.cc +222 -0
  981. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/keyrange.h +141 -0
  982. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/lock_request.cc +525 -0
  983. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/lock_request.h +253 -0
  984. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/locktree.cc +1007 -0
  985. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/locktree.h +560 -0
  986. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/manager.cc +527 -0
  987. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/range_buffer.cc +265 -0
  988. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/range_buffer.h +178 -0
  989. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/treenode.cc +520 -0
  990. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/treenode.h +302 -0
  991. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/txnid_set.cc +120 -0
  992. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/txnid_set.h +92 -0
  993. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/wfg.cc +213 -0
  994. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/wfg.h +124 -0
  995. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/memory.h +215 -0
  996. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_assert_subst.h +39 -0
  997. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_atomic.h +130 -0
  998. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_external_pthread.h +82 -0
  999. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_instrumentation.h +286 -0
  1000. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_portability.h +87 -0
  1001. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_pthread.h +520 -0
  1002. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_race_tools.h +179 -0
  1003. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h +172 -0
  1004. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/txn_subst.h +27 -0
  1005. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/standalone_port.cc +132 -0
  1006. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/dbt.cc +153 -0
  1007. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/dbt.h +98 -0
  1008. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/growable_array.h +144 -0
  1009. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/memarena.cc +201 -0
  1010. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/memarena.h +141 -0
  1011. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/omt.h +794 -0
  1012. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/omt_impl.h +1295 -0
  1013. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/partitioned_counter.h +165 -0
  1014. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/status.h +76 -0
  1015. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/range_tree_lock_manager.cc +479 -0
  1016. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/range_tree_lock_manager.h +130 -0
  1017. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/range_tree_lock_tracker.cc +156 -0
  1018. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/range_tree_lock_tracker.h +146 -0
  1019. package/deps/rocksdb/rocksdb/utilities/transactions/optimistic_transaction.cc +196 -0
  1020. package/deps/rocksdb/rocksdb/utilities/transactions/optimistic_transaction.h +101 -0
  1021. package/deps/rocksdb/rocksdb/utilities/transactions/optimistic_transaction_db_impl.cc +111 -0
  1022. package/deps/rocksdb/rocksdb/utilities/transactions/optimistic_transaction_db_impl.h +87 -0
  1023. package/deps/rocksdb/rocksdb/utilities/transactions/optimistic_transaction_test.cc +1418 -0
  1024. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction.cc +752 -0
  1025. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction.h +232 -0
  1026. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction_db.cc +628 -0
  1027. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction_db.h +228 -0
  1028. package/deps/rocksdb/rocksdb/utilities/transactions/snapshot_checker.cc +49 -0
  1029. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_base.cc +678 -0
  1030. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_base.h +373 -0
  1031. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_db_mutex_impl.cc +135 -0
  1032. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_db_mutex_impl.h +26 -0
  1033. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.cc +6350 -0
  1034. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.h +522 -0
  1035. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_util.cc +188 -0
  1036. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_util.h +80 -0
  1037. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_transaction_test.cc +3531 -0
  1038. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn.cc +483 -0
  1039. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn.h +119 -0
  1040. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn_db.cc +999 -0
  1041. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn_db.h +1109 -0
  1042. package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_transaction_test.cc +786 -0
  1043. package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_txn.cc +1039 -0
  1044. package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_txn.h +341 -0
  1045. package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_txn_db.cc +470 -0
  1046. package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_txn_db.h +108 -0
  1047. package/deps/rocksdb/rocksdb/utilities/ttl/db_ttl_impl.cc +332 -0
  1048. package/deps/rocksdb/rocksdb/utilities/ttl/db_ttl_impl.h +353 -0
  1049. package/deps/rocksdb/rocksdb/utilities/ttl/ttl_test.cc +703 -0
  1050. package/deps/rocksdb/rocksdb/utilities/util_merge_operators_test.cc +99 -0
  1051. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc +617 -0
  1052. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc +345 -0
  1053. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h +569 -0
  1054. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_test.cc +1867 -0
  1055. package/deps/rocksdb/rocksdb.gyp +475 -0
  1056. package/deps/snappy/freebsd/config.h +135 -0
  1057. package/deps/snappy/freebsd/snappy-stubs-public.h +100 -0
  1058. package/deps/snappy/linux/config.h +135 -0
  1059. package/deps/snappy/linux/snappy-stubs-public.h +100 -0
  1060. package/deps/snappy/mac/config.h +137 -0
  1061. package/deps/snappy/mac/snappy-stubs-public.h +100 -0
  1062. package/deps/snappy/openbsd/config.h +135 -0
  1063. package/deps/snappy/openbsd/snappy-stubs-public.h +100 -0
  1064. package/deps/snappy/snappy-1.1.7/COPYING +54 -0
  1065. package/deps/snappy/snappy-1.1.7/cmake/SnappyConfig.cmake +1 -0
  1066. package/deps/snappy/snappy-1.1.7/cmake/config.h.in +62 -0
  1067. package/deps/snappy/snappy-1.1.7/snappy-c.cc +90 -0
  1068. package/deps/snappy/snappy-1.1.7/snappy-c.h +138 -0
  1069. package/deps/snappy/snappy-1.1.7/snappy-internal.h +224 -0
  1070. package/deps/snappy/snappy-1.1.7/snappy-sinksource.cc +104 -0
  1071. package/deps/snappy/snappy-1.1.7/snappy-sinksource.h +182 -0
  1072. package/deps/snappy/snappy-1.1.7/snappy-stubs-internal.cc +42 -0
  1073. package/deps/snappy/snappy-1.1.7/snappy-stubs-internal.h +561 -0
  1074. package/deps/snappy/snappy-1.1.7/snappy-stubs-public.h.in +94 -0
  1075. package/deps/snappy/snappy-1.1.7/snappy-test.cc +612 -0
  1076. package/deps/snappy/snappy-1.1.7/snappy-test.h +573 -0
  1077. package/deps/snappy/snappy-1.1.7/snappy.cc +1515 -0
  1078. package/deps/snappy/snappy-1.1.7/snappy.h +203 -0
  1079. package/deps/snappy/snappy-1.1.7/snappy_unittest.cc +1410 -0
  1080. package/deps/snappy/snappy.gyp +90 -0
  1081. package/deps/snappy/solaris/config.h +135 -0
  1082. package/deps/snappy/solaris/snappy-stubs-public.h +100 -0
  1083. package/deps/snappy/win32/config.h +29 -0
  1084. package/deps/snappy/win32/snappy-stubs-public.h +100 -0
  1085. package/iterator.js +55 -0
  1086. package/leveldown.js +113 -0
  1087. package/package-lock.json +23687 -0
  1088. package/package.json +70 -0
@@ -0,0 +1,1806 @@
1
+ // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2
+ // This source code is licensed under both the GPLv2 (found in the
3
+ // COPYING file in the root directory) and Apache 2.0 License
4
+ // (found in the LICENSE.Apache file in the root directory).
5
+ //
6
+ // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
7
+ // Use of this source code is governed by a BSD-style license that can be
8
+ // found in the LICENSE file. See the AUTHORS file for names of contributors.
9
+ #include <cinttypes>
10
+
11
+ #include "db/builder.h"
12
+ #include "db/db_impl/db_impl.h"
13
+ #include "db/error_handler.h"
14
+ #include "db/periodic_work_scheduler.h"
15
+ #include "env/composite_env_wrapper.h"
16
+ #include "file/read_write_util.h"
17
+ #include "file/sst_file_manager_impl.h"
18
+ #include "file/writable_file_writer.h"
19
+ #include "monitoring/persistent_stats_history.h"
20
+ #include "options/options_helper.h"
21
+ #include "rocksdb/table.h"
22
+ #include "rocksdb/wal_filter.h"
23
+ #include "test_util/sync_point.h"
24
+ #include "util/rate_limiter.h"
25
+
26
+ namespace ROCKSDB_NAMESPACE {
27
+ Options SanitizeOptions(const std::string& dbname, const Options& src) {
28
+ auto db_options = SanitizeOptions(dbname, DBOptions(src));
29
+ ImmutableDBOptions immutable_db_options(db_options);
30
+ auto cf_options =
31
+ SanitizeOptions(immutable_db_options, ColumnFamilyOptions(src));
32
+ return Options(db_options, cf_options);
33
+ }
34
+
35
+ DBOptions SanitizeOptions(const std::string& dbname, const DBOptions& src) {
36
+ DBOptions result(src);
37
+
38
+ if (result.env == nullptr) {
39
+ result.env = Env::Default();
40
+ }
41
+
42
+ // result.max_open_files means an "infinite" open files.
43
+ if (result.max_open_files != -1) {
44
+ int max_max_open_files = port::GetMaxOpenFiles();
45
+ if (max_max_open_files == -1) {
46
+ max_max_open_files = 0x400000;
47
+ }
48
+ ClipToRange(&result.max_open_files, 20, max_max_open_files);
49
+ TEST_SYNC_POINT_CALLBACK("SanitizeOptions::AfterChangeMaxOpenFiles",
50
+ &result.max_open_files);
51
+ }
52
+
53
+ if (result.info_log == nullptr) {
54
+ Status s = CreateLoggerFromOptions(dbname, result, &result.info_log);
55
+ if (!s.ok()) {
56
+ // No place suitable for logging
57
+ result.info_log = nullptr;
58
+ }
59
+ }
60
+
61
+ if (!result.write_buffer_manager) {
62
+ result.write_buffer_manager.reset(
63
+ new WriteBufferManager(result.db_write_buffer_size));
64
+ }
65
+ auto bg_job_limits = DBImpl::GetBGJobLimits(
66
+ result.max_background_flushes, result.max_background_compactions,
67
+ result.max_background_jobs, true /* parallelize_compactions */);
68
+ result.env->IncBackgroundThreadsIfNeeded(bg_job_limits.max_compactions,
69
+ Env::Priority::LOW);
70
+ result.env->IncBackgroundThreadsIfNeeded(bg_job_limits.max_flushes,
71
+ Env::Priority::HIGH);
72
+
73
+ if (result.rate_limiter.get() != nullptr) {
74
+ if (result.bytes_per_sync == 0) {
75
+ result.bytes_per_sync = 1024 * 1024;
76
+ }
77
+ }
78
+
79
+ if (result.delayed_write_rate == 0) {
80
+ if (result.rate_limiter.get() != nullptr) {
81
+ result.delayed_write_rate = result.rate_limiter->GetBytesPerSecond();
82
+ }
83
+ if (result.delayed_write_rate == 0) {
84
+ result.delayed_write_rate = 16 * 1024 * 1024;
85
+ }
86
+ }
87
+
88
+ if (result.WAL_ttl_seconds > 0 || result.WAL_size_limit_MB > 0) {
89
+ result.recycle_log_file_num = false;
90
+ }
91
+
92
+ if (result.recycle_log_file_num &&
93
+ (result.wal_recovery_mode ==
94
+ WALRecoveryMode::kTolerateCorruptedTailRecords ||
95
+ result.wal_recovery_mode == WALRecoveryMode::kPointInTimeRecovery ||
96
+ result.wal_recovery_mode == WALRecoveryMode::kAbsoluteConsistency)) {
97
+ // - kTolerateCorruptedTailRecords is inconsistent with recycle log file
98
+ // feature. WAL recycling expects recovery success upon encountering a
99
+ // corrupt record at the point where new data ends and recycled data
100
+ // remains at the tail. However, `kTolerateCorruptedTailRecords` must fail
101
+ // upon encountering any such corrupt record, as it cannot differentiate
102
+ // between this and a real corruption, which would cause committed updates
103
+ // to be truncated -- a violation of the recovery guarantee.
104
+ // - kPointInTimeRecovery and kAbsoluteConsistency are incompatible with
105
+ // recycle log file feature temporarily due to a bug found introducing a
106
+ // hole in the recovered data
107
+ // (https://github.com/facebook/rocksdb/pull/7252#issuecomment-673766236).
108
+ // Besides this bug, we believe the features are fundamentally compatible.
109
+ result.recycle_log_file_num = 0;
110
+ }
111
+
112
+ if (result.wal_dir.empty()) {
113
+ // Use dbname as default
114
+ result.wal_dir = dbname;
115
+ }
116
+ if (result.wal_dir.back() == '/') {
117
+ result.wal_dir = result.wal_dir.substr(0, result.wal_dir.size() - 1);
118
+ }
119
+
120
+ if (result.db_paths.size() == 0) {
121
+ result.db_paths.emplace_back(dbname, std::numeric_limits<uint64_t>::max());
122
+ }
123
+
124
+ if (result.use_direct_reads && result.compaction_readahead_size == 0) {
125
+ TEST_SYNC_POINT_CALLBACK("SanitizeOptions:direct_io", nullptr);
126
+ result.compaction_readahead_size = 1024 * 1024 * 2;
127
+ }
128
+
129
+ if (result.compaction_readahead_size > 0 || result.use_direct_reads) {
130
+ result.new_table_reader_for_compaction_inputs = true;
131
+ }
132
+
133
+ // Force flush on DB open if 2PC is enabled, since with 2PC we have no
134
+ // guarantee that consecutive log files have consecutive sequence id, which
135
+ // make recovery complicated.
136
+ if (result.allow_2pc) {
137
+ result.avoid_flush_during_recovery = false;
138
+ }
139
+
140
+ #ifndef ROCKSDB_LITE
141
+ ImmutableDBOptions immutable_db_options(result);
142
+ if (!IsWalDirSameAsDBPath(&immutable_db_options)) {
143
+ // Either the WAL dir and db_paths[0]/db_name are not the same, or we
144
+ // cannot tell for sure. In either case, assume they're different and
145
+ // explicitly cleanup the trash log files (bypass DeleteScheduler)
146
+ // Do this first so even if we end up calling
147
+ // DeleteScheduler::CleanupDirectory on the same dir later, it will be
148
+ // safe
149
+ std::vector<std::string> filenames;
150
+ Status s = result.env->GetChildren(result.wal_dir, &filenames);
151
+ s.PermitUncheckedError(); //**TODO: What to do on error?
152
+ for (std::string& filename : filenames) {
153
+ if (filename.find(".log.trash", filename.length() -
154
+ std::string(".log.trash").length()) !=
155
+ std::string::npos) {
156
+ std::string trash_file = result.wal_dir + "/" + filename;
157
+ result.env->DeleteFile(trash_file).PermitUncheckedError();
158
+ }
159
+ }
160
+ }
161
+ // When the DB is stopped, it's possible that there are some .trash files that
162
+ // were not deleted yet, when we open the DB we will find these .trash files
163
+ // and schedule them to be deleted (or delete immediately if SstFileManager
164
+ // was not used)
165
+ auto sfm = static_cast<SstFileManagerImpl*>(result.sst_file_manager.get());
166
+ for (size_t i = 0; i < result.db_paths.size(); i++) {
167
+ DeleteScheduler::CleanupDirectory(result.env, sfm, result.db_paths[i].path)
168
+ .PermitUncheckedError();
169
+ }
170
+
171
+ // Create a default SstFileManager for purposes of tracking compaction size
172
+ // and facilitating recovery from out of space errors.
173
+ if (result.sst_file_manager.get() == nullptr) {
174
+ std::shared_ptr<SstFileManager> sst_file_manager(
175
+ NewSstFileManager(result.env, result.info_log));
176
+ result.sst_file_manager = sst_file_manager;
177
+ }
178
+ #endif
179
+
180
+ if (!result.paranoid_checks) {
181
+ result.skip_checking_sst_file_sizes_on_db_open = true;
182
+ ROCKS_LOG_INFO(result.info_log,
183
+ "file size check will be skipped during open.");
184
+ }
185
+
186
+ return result;
187
+ }
188
+
189
+ namespace {
190
+ Status ValidateOptionsByTable(
191
+ const DBOptions& db_opts,
192
+ const std::vector<ColumnFamilyDescriptor>& column_families) {
193
+ Status s;
194
+ for (auto cf : column_families) {
195
+ s = ValidateOptions(db_opts, cf.options);
196
+ if (!s.ok()) {
197
+ return s;
198
+ }
199
+ }
200
+ return Status::OK();
201
+ }
202
+ } // namespace
203
+
204
+ Status DBImpl::ValidateOptions(
205
+ const DBOptions& db_options,
206
+ const std::vector<ColumnFamilyDescriptor>& column_families) {
207
+ Status s;
208
+ for (auto& cfd : column_families) {
209
+ s = ColumnFamilyData::ValidateOptions(db_options, cfd.options);
210
+ if (!s.ok()) {
211
+ return s;
212
+ }
213
+ }
214
+ s = ValidateOptions(db_options);
215
+ return s;
216
+ }
217
+
218
+ Status DBImpl::ValidateOptions(const DBOptions& db_options) {
219
+ if (db_options.db_paths.size() > 4) {
220
+ return Status::NotSupported(
221
+ "More than four DB paths are not supported yet. ");
222
+ }
223
+
224
+ if (db_options.allow_mmap_reads && db_options.use_direct_reads) {
225
+ // Protect against assert in PosixMMapReadableFile constructor
226
+ return Status::NotSupported(
227
+ "If memory mapped reads (allow_mmap_reads) are enabled "
228
+ "then direct I/O reads (use_direct_reads) must be disabled. ");
229
+ }
230
+
231
+ if (db_options.allow_mmap_writes &&
232
+ db_options.use_direct_io_for_flush_and_compaction) {
233
+ return Status::NotSupported(
234
+ "If memory mapped writes (allow_mmap_writes) are enabled "
235
+ "then direct I/O writes (use_direct_io_for_flush_and_compaction) must "
236
+ "be disabled. ");
237
+ }
238
+
239
+ if (db_options.keep_log_file_num == 0) {
240
+ return Status::InvalidArgument("keep_log_file_num must be greater than 0");
241
+ }
242
+
243
+ if (db_options.unordered_write &&
244
+ !db_options.allow_concurrent_memtable_write) {
245
+ return Status::InvalidArgument(
246
+ "unordered_write is incompatible with !allow_concurrent_memtable_write");
247
+ }
248
+
249
+ if (db_options.unordered_write && db_options.enable_pipelined_write) {
250
+ return Status::InvalidArgument(
251
+ "unordered_write is incompatible with enable_pipelined_write");
252
+ }
253
+
254
+ if (db_options.atomic_flush && db_options.enable_pipelined_write) {
255
+ return Status::InvalidArgument(
256
+ "atomic_flush is incompatible with enable_pipelined_write");
257
+ }
258
+
259
+ // TODO remove this restriction
260
+ if (db_options.atomic_flush && db_options.best_efforts_recovery) {
261
+ return Status::InvalidArgument(
262
+ "atomic_flush is currently incompatible with best-efforts recovery");
263
+ }
264
+
265
+ return Status::OK();
266
+ }
267
+
268
+ Status DBImpl::NewDB(std::vector<std::string>* new_filenames) {
269
+ VersionEdit new_db;
270
+ Status s = SetIdentityFile(env_, dbname_);
271
+ if (!s.ok()) {
272
+ return s;
273
+ }
274
+ if (immutable_db_options_.write_dbid_to_manifest) {
275
+ std::string temp_db_id;
276
+ GetDbIdentityFromIdentityFile(&temp_db_id);
277
+ new_db.SetDBId(temp_db_id);
278
+ }
279
+ new_db.SetLogNumber(0);
280
+ new_db.SetNextFile(2);
281
+ new_db.SetLastSequence(0);
282
+
283
+ ROCKS_LOG_INFO(immutable_db_options_.info_log, "Creating manifest 1 \n");
284
+ const std::string manifest = DescriptorFileName(dbname_, 1);
285
+ {
286
+ std::unique_ptr<FSWritableFile> file;
287
+ FileOptions file_options = fs_->OptimizeForManifestWrite(file_options_);
288
+ s = NewWritableFile(fs_.get(), manifest, &file, file_options);
289
+ if (!s.ok()) {
290
+ return s;
291
+ }
292
+ file->SetPreallocationBlockSize(
293
+ immutable_db_options_.manifest_preallocation_size);
294
+ std::unique_ptr<WritableFileWriter> file_writer(new WritableFileWriter(
295
+ std::move(file), manifest, file_options, env_, io_tracer_,
296
+ nullptr /* stats */, immutable_db_options_.listeners));
297
+ log::Writer log(std::move(file_writer), 0, false);
298
+ std::string record;
299
+ new_db.EncodeTo(&record);
300
+ s = log.AddRecord(record);
301
+ if (s.ok()) {
302
+ s = SyncManifest(env_, &immutable_db_options_, log.file());
303
+ }
304
+ }
305
+ if (s.ok()) {
306
+ // Make "CURRENT" file that points to the new manifest file.
307
+ s = SetCurrentFile(fs_.get(), dbname_, 1, directories_.GetDbDir());
308
+ if (new_filenames) {
309
+ new_filenames->emplace_back(
310
+ manifest.substr(manifest.find_last_of("/\\") + 1));
311
+ }
312
+ } else {
313
+ fs_->DeleteFile(manifest, IOOptions(), nullptr);
314
+ }
315
+ return s;
316
+ }
317
+
318
+ IOStatus DBImpl::CreateAndNewDirectory(
319
+ FileSystem* fs, const std::string& dirname,
320
+ std::unique_ptr<FSDirectory>* directory) {
321
+ // We call CreateDirIfMissing() as the directory may already exist (if we
322
+ // are reopening a DB), when this happens we don't want creating the
323
+ // directory to cause an error. However, we need to check if creating the
324
+ // directory fails or else we may get an obscure message about the lock
325
+ // file not existing. One real-world example of this occurring is if
326
+ // env->CreateDirIfMissing() doesn't create intermediate directories, e.g.
327
+ // when dbname_ is "dir/db" but when "dir" doesn't exist.
328
+ IOStatus io_s = fs->CreateDirIfMissing(dirname, IOOptions(), nullptr);
329
+ if (!io_s.ok()) {
330
+ return io_s;
331
+ }
332
+ return fs->NewDirectory(dirname, IOOptions(), directory, nullptr);
333
+ }
334
+
335
+ IOStatus Directories::SetDirectories(FileSystem* fs, const std::string& dbname,
336
+ const std::string& wal_dir,
337
+ const std::vector<DbPath>& data_paths) {
338
+ IOStatus io_s = DBImpl::CreateAndNewDirectory(fs, dbname, &db_dir_);
339
+ if (!io_s.ok()) {
340
+ return io_s;
341
+ }
342
+ if (!wal_dir.empty() && dbname != wal_dir) {
343
+ io_s = DBImpl::CreateAndNewDirectory(fs, wal_dir, &wal_dir_);
344
+ if (!io_s.ok()) {
345
+ return io_s;
346
+ }
347
+ }
348
+
349
+ data_dirs_.clear();
350
+ for (auto& p : data_paths) {
351
+ const std::string db_path = p.path;
352
+ if (db_path == dbname) {
353
+ data_dirs_.emplace_back(nullptr);
354
+ } else {
355
+ std::unique_ptr<FSDirectory> path_directory;
356
+ io_s = DBImpl::CreateAndNewDirectory(fs, db_path, &path_directory);
357
+ if (!io_s.ok()) {
358
+ return io_s;
359
+ }
360
+ data_dirs_.emplace_back(path_directory.release());
361
+ }
362
+ }
363
+ assert(data_dirs_.size() == data_paths.size());
364
+ return IOStatus::OK();
365
+ }
366
+
367
+ Status DBImpl::Recover(
368
+ const std::vector<ColumnFamilyDescriptor>& column_families, bool read_only,
369
+ bool error_if_wal_file_exists, bool error_if_data_exists_in_wals,
370
+ uint64_t* recovered_seq) {
371
+ mutex_.AssertHeld();
372
+
373
+ bool is_new_db = false;
374
+ assert(db_lock_ == nullptr);
375
+ std::vector<std::string> files_in_dbname;
376
+ if (!read_only) {
377
+ Status s = directories_.SetDirectories(fs_.get(), dbname_,
378
+ immutable_db_options_.wal_dir,
379
+ immutable_db_options_.db_paths);
380
+ if (!s.ok()) {
381
+ return s;
382
+ }
383
+
384
+ s = env_->LockFile(LockFileName(dbname_), &db_lock_);
385
+ if (!s.ok()) {
386
+ return s;
387
+ }
388
+
389
+ std::string current_fname = CurrentFileName(dbname_);
390
+ // Path to any MANIFEST file in the db dir. It does not matter which one.
391
+ // Since best-efforts recovery ignores CURRENT file, existence of a
392
+ // MANIFEST indicates the recovery to recover existing db. If no MANIFEST
393
+ // can be found, a new db will be created.
394
+ std::string manifest_path;
395
+ if (!immutable_db_options_.best_efforts_recovery) {
396
+ s = env_->FileExists(current_fname);
397
+ } else {
398
+ s = Status::NotFound();
399
+ Status io_s = env_->GetChildren(dbname_, &files_in_dbname);
400
+ if (!io_s.ok()) {
401
+ s = io_s;
402
+ files_in_dbname.clear();
403
+ }
404
+ for (const std::string& file : files_in_dbname) {
405
+ uint64_t number = 0;
406
+ FileType type = kWalFile; // initialize
407
+ if (ParseFileName(file, &number, &type) && type == kDescriptorFile) {
408
+ // Found MANIFEST (descriptor log), thus best-efforts recovery does
409
+ // not have to treat the db as empty.
410
+ s = Status::OK();
411
+ manifest_path = dbname_ + "/" + file;
412
+ break;
413
+ }
414
+ }
415
+ }
416
+ if (s.IsNotFound()) {
417
+ if (immutable_db_options_.create_if_missing) {
418
+ s = NewDB(&files_in_dbname);
419
+ is_new_db = true;
420
+ if (!s.ok()) {
421
+ return s;
422
+ }
423
+ } else {
424
+ return Status::InvalidArgument(
425
+ current_fname, "does not exist (create_if_missing is false)");
426
+ }
427
+ } else if (s.ok()) {
428
+ if (immutable_db_options_.error_if_exists) {
429
+ return Status::InvalidArgument(dbname_,
430
+ "exists (error_if_exists is true)");
431
+ }
432
+ } else {
433
+ // Unexpected error reading file
434
+ assert(s.IsIOError());
435
+ return s;
436
+ }
437
+ // Verify compatibility of file_options_ and filesystem
438
+ {
439
+ std::unique_ptr<FSRandomAccessFile> idfile;
440
+ FileOptions customized_fs(file_options_);
441
+ customized_fs.use_direct_reads |=
442
+ immutable_db_options_.use_direct_io_for_flush_and_compaction;
443
+ const std::string& fname =
444
+ manifest_path.empty() ? current_fname : manifest_path;
445
+ s = fs_->NewRandomAccessFile(fname, customized_fs, &idfile, nullptr);
446
+ if (!s.ok()) {
447
+ std::string error_str = s.ToString();
448
+ // Check if unsupported Direct I/O is the root cause
449
+ customized_fs.use_direct_reads = false;
450
+ s = fs_->NewRandomAccessFile(fname, customized_fs, &idfile, nullptr);
451
+ if (s.ok()) {
452
+ return Status::InvalidArgument(
453
+ "Direct I/O is not supported by the specified DB.");
454
+ } else {
455
+ return Status::InvalidArgument(
456
+ "Found options incompatible with filesystem", error_str.c_str());
457
+ }
458
+ }
459
+ }
460
+ } else if (immutable_db_options_.best_efforts_recovery) {
461
+ assert(files_in_dbname.empty());
462
+ Status s = env_->GetChildren(dbname_, &files_in_dbname);
463
+ if (s.IsNotFound()) {
464
+ return Status::InvalidArgument(dbname_,
465
+ "does not exist (open for read only)");
466
+ } else if (s.IsIOError()) {
467
+ return s;
468
+ }
469
+ assert(s.ok());
470
+ }
471
+ assert(db_id_.empty());
472
+ Status s;
473
+ bool missing_table_file = false;
474
+ if (!immutable_db_options_.best_efforts_recovery) {
475
+ s = versions_->Recover(column_families, read_only, &db_id_);
476
+ } else {
477
+ assert(!files_in_dbname.empty());
478
+ s = versions_->TryRecover(column_families, read_only, files_in_dbname,
479
+ &db_id_, &missing_table_file);
480
+ if (s.ok()) {
481
+ // TryRecover may delete previous column_family_set_.
482
+ column_family_memtables_.reset(
483
+ new ColumnFamilyMemTablesImpl(versions_->GetColumnFamilySet()));
484
+ }
485
+ }
486
+ if (!s.ok()) {
487
+ return s;
488
+ }
489
+ s = SetDBId();
490
+ if (s.ok() && !read_only) {
491
+ s = DeleteUnreferencedSstFiles();
492
+ }
493
+
494
+ if (immutable_db_options_.paranoid_checks && s.ok()) {
495
+ s = CheckConsistency();
496
+ }
497
+ if (s.ok() && !read_only) {
498
+ std::map<std::string, std::shared_ptr<FSDirectory>> created_dirs;
499
+ for (auto cfd : *versions_->GetColumnFamilySet()) {
500
+ s = cfd->AddDirectories(&created_dirs);
501
+ if (!s.ok()) {
502
+ return s;
503
+ }
504
+ }
505
+ }
506
+ // DB mutex is already held
507
+ if (s.ok() && immutable_db_options_.persist_stats_to_disk) {
508
+ s = InitPersistStatsColumnFamily();
509
+ }
510
+
511
+ std::vector<std::string> files_in_wal_dir;
512
+ if (s.ok()) {
513
+ // Initial max_total_in_memory_state_ before recovery wals. Log recovery
514
+ // may check this value to decide whether to flush.
515
+ max_total_in_memory_state_ = 0;
516
+ for (auto cfd : *versions_->GetColumnFamilySet()) {
517
+ auto* mutable_cf_options = cfd->GetLatestMutableCFOptions();
518
+ max_total_in_memory_state_ += mutable_cf_options->write_buffer_size *
519
+ mutable_cf_options->max_write_buffer_number;
520
+ }
521
+
522
+ SequenceNumber next_sequence(kMaxSequenceNumber);
523
+ default_cf_handle_ = new ColumnFamilyHandleImpl(
524
+ versions_->GetColumnFamilySet()->GetDefault(), this, &mutex_);
525
+ default_cf_internal_stats_ = default_cf_handle_->cfd()->internal_stats();
526
+ // TODO(Zhongyi): handle single_column_family_mode_ when
527
+ // persistent_stats is enabled
528
+ single_column_family_mode_ =
529
+ versions_->GetColumnFamilySet()->NumberOfColumnFamilies() == 1;
530
+
531
+ // Recover from all newer log files than the ones named in the
532
+ // descriptor (new log files may have been added by the previous
533
+ // incarnation without registering them in the descriptor).
534
+ //
535
+ // Note that prev_log_number() is no longer used, but we pay
536
+ // attention to it in case we are recovering a database
537
+ // produced by an older version of rocksdb.
538
+ if (!immutable_db_options_.best_efforts_recovery) {
539
+ s = env_->GetChildren(immutable_db_options_.wal_dir, &files_in_wal_dir);
540
+ }
541
+ if (s.IsNotFound()) {
542
+ return Status::InvalidArgument("wal_dir not found",
543
+ immutable_db_options_.wal_dir);
544
+ } else if (!s.ok()) {
545
+ return s;
546
+ }
547
+
548
+ std::unordered_map<uint64_t, std::string> wal_files;
549
+ for (const auto& file : files_in_wal_dir) {
550
+ uint64_t number;
551
+ FileType type;
552
+ if (ParseFileName(file, &number, &type) && type == kWalFile) {
553
+ if (is_new_db) {
554
+ return Status::Corruption(
555
+ "While creating a new Db, wal_dir contains "
556
+ "existing log file: ",
557
+ file);
558
+ } else {
559
+ wal_files[number] =
560
+ LogFileName(immutable_db_options_.wal_dir, number);
561
+ }
562
+ }
563
+ }
564
+
565
+ if (immutable_db_options_.track_and_verify_wals_in_manifest) {
566
+ if (!immutable_db_options_.best_efforts_recovery) {
567
+ // Verify WALs in MANIFEST.
568
+ s = versions_->GetWalSet().CheckWals(env_, wal_files);
569
+ } // else since best effort recovery does not recover from WALs, no need
570
+ // to check WALs.
571
+ } else if (!versions_->GetWalSet().GetWals().empty()) {
572
+ // Tracking is disabled, clear previously tracked WALs from MANIFEST,
573
+ // otherwise, in the future, if WAL tracking is enabled again,
574
+ // since the WALs deleted when WAL tracking is disabled are not persisted
575
+ // into MANIFEST, WAL check may fail.
576
+ VersionEdit edit;
577
+ WalNumber max_wal_number =
578
+ versions_->GetWalSet().GetWals().rbegin()->first;
579
+ edit.DeleteWalsBefore(max_wal_number + 1);
580
+ s = versions_->LogAndApplyToDefaultColumnFamily(&edit, &mutex_);
581
+ }
582
+ if (!s.ok()) {
583
+ return s;
584
+ }
585
+
586
+ if (!wal_files.empty()) {
587
+ if (error_if_wal_file_exists) {
588
+ return Status::Corruption(
589
+ "The db was opened in readonly mode with error_if_wal_file_exists"
590
+ "flag but a WAL file already exists");
591
+ } else if (error_if_data_exists_in_wals) {
592
+ for (auto& wal_file : wal_files) {
593
+ uint64_t bytes;
594
+ s = env_->GetFileSize(wal_file.second, &bytes);
595
+ if (s.ok()) {
596
+ if (bytes > 0) {
597
+ return Status::Corruption(
598
+ "error_if_data_exists_in_wals is set but there are data "
599
+ " in WAL files.");
600
+ }
601
+ }
602
+ }
603
+ }
604
+ }
605
+
606
+ if (!wal_files.empty()) {
607
+ // Recover in the order in which the wals were generated
608
+ std::vector<uint64_t> wals;
609
+ wals.reserve(wal_files.size());
610
+ for (const auto& wal_file : wal_files) {
611
+ wals.push_back(wal_file.first);
612
+ }
613
+ std::sort(wals.begin(), wals.end());
614
+
615
+ bool corrupted_wal_found = false;
616
+ s = RecoverLogFiles(wals, &next_sequence, read_only,
617
+ &corrupted_wal_found);
618
+ if (corrupted_wal_found && recovered_seq != nullptr) {
619
+ *recovered_seq = next_sequence;
620
+ }
621
+ if (!s.ok()) {
622
+ // Clear memtables if recovery failed
623
+ for (auto cfd : *versions_->GetColumnFamilySet()) {
624
+ cfd->CreateNewMemtable(*cfd->GetLatestMutableCFOptions(),
625
+ kMaxSequenceNumber);
626
+ }
627
+ }
628
+ }
629
+ }
630
+
631
+ if (read_only) {
632
+ // If we are opening as read-only, we need to update options_file_number_
633
+ // to reflect the most recent OPTIONS file. It does not matter for regular
634
+ // read-write db instance because options_file_number_ will later be
635
+ // updated to versions_->NewFileNumber() in RenameTempFileToOptionsFile.
636
+ std::vector<std::string> filenames;
637
+ if (s.ok()) {
638
+ const std::string normalized_dbname = NormalizePath(dbname_);
639
+ const std::string normalized_wal_dir =
640
+ NormalizePath(immutable_db_options_.wal_dir);
641
+ if (immutable_db_options_.best_efforts_recovery) {
642
+ filenames = std::move(files_in_dbname);
643
+ } else if (normalized_dbname == normalized_wal_dir) {
644
+ filenames = std::move(files_in_wal_dir);
645
+ } else {
646
+ s = env_->GetChildren(GetName(), &filenames);
647
+ }
648
+ }
649
+ if (s.ok()) {
650
+ uint64_t number = 0;
651
+ uint64_t options_file_number = 0;
652
+ FileType type;
653
+ for (const auto& fname : filenames) {
654
+ if (ParseFileName(fname, &number, &type) && type == kOptionsFile) {
655
+ options_file_number = std::max(number, options_file_number);
656
+ }
657
+ }
658
+ versions_->options_file_number_ = options_file_number;
659
+ }
660
+ }
661
+ return s;
662
+ }
663
+
664
+ Status DBImpl::PersistentStatsProcessFormatVersion() {
665
+ mutex_.AssertHeld();
666
+ Status s;
667
+ // persist version when stats CF doesn't exist
668
+ bool should_persist_format_version = !persistent_stats_cfd_exists_;
669
+ mutex_.Unlock();
670
+ if (persistent_stats_cfd_exists_) {
671
+ // Check persistent stats format version compatibility. Drop and recreate
672
+ // persistent stats CF if format version is incompatible
673
+ uint64_t format_version_recovered = 0;
674
+ Status s_format = DecodePersistentStatsVersionNumber(
675
+ this, StatsVersionKeyType::kFormatVersion, &format_version_recovered);
676
+ uint64_t compatible_version_recovered = 0;
677
+ Status s_compatible = DecodePersistentStatsVersionNumber(
678
+ this, StatsVersionKeyType::kCompatibleVersion,
679
+ &compatible_version_recovered);
680
+ // abort reading from existing stats CF if any of following is true:
681
+ // 1. failed to read format version or compatible version from disk
682
+ // 2. sst's format version is greater than current format version, meaning
683
+ // this sst is encoded with a newer RocksDB release, and current compatible
684
+ // version is below the sst's compatible version
685
+ if (!s_format.ok() || !s_compatible.ok() ||
686
+ (kStatsCFCurrentFormatVersion < format_version_recovered &&
687
+ kStatsCFCompatibleFormatVersion < compatible_version_recovered)) {
688
+ if (!s_format.ok() || !s_compatible.ok()) {
689
+ ROCKS_LOG_WARN(
690
+ immutable_db_options_.info_log,
691
+ "Recreating persistent stats column family since reading "
692
+ "persistent stats version key failed. Format key: %s, compatible "
693
+ "key: %s",
694
+ s_format.ToString().c_str(), s_compatible.ToString().c_str());
695
+ } else {
696
+ ROCKS_LOG_WARN(
697
+ immutable_db_options_.info_log,
698
+ "Recreating persistent stats column family due to corrupted or "
699
+ "incompatible format version. Recovered format: %" PRIu64
700
+ "; recovered format compatible since: %" PRIu64 "\n",
701
+ format_version_recovered, compatible_version_recovered);
702
+ }
703
+ s = DropColumnFamily(persist_stats_cf_handle_);
704
+ if (s.ok()) {
705
+ s = DestroyColumnFamilyHandle(persist_stats_cf_handle_);
706
+ }
707
+ ColumnFamilyHandle* handle = nullptr;
708
+ if (s.ok()) {
709
+ ColumnFamilyOptions cfo;
710
+ OptimizeForPersistentStats(&cfo);
711
+ s = CreateColumnFamily(cfo, kPersistentStatsColumnFamilyName, &handle);
712
+ }
713
+ if (s.ok()) {
714
+ persist_stats_cf_handle_ = static_cast<ColumnFamilyHandleImpl*>(handle);
715
+ // should also persist version here because old stats CF is discarded
716
+ should_persist_format_version = true;
717
+ }
718
+ }
719
+ }
720
+ if (should_persist_format_version) {
721
+ // Persistent stats CF being created for the first time, need to write
722
+ // format version key
723
+ WriteBatch batch;
724
+ if (s.ok()) {
725
+ s = batch.Put(persist_stats_cf_handle_, kFormatVersionKeyString,
726
+ ToString(kStatsCFCurrentFormatVersion));
727
+ }
728
+ if (s.ok()) {
729
+ s = batch.Put(persist_stats_cf_handle_, kCompatibleVersionKeyString,
730
+ ToString(kStatsCFCompatibleFormatVersion));
731
+ }
732
+ if (s.ok()) {
733
+ WriteOptions wo;
734
+ wo.low_pri = true;
735
+ wo.no_slowdown = true;
736
+ wo.sync = false;
737
+ s = Write(wo, &batch);
738
+ }
739
+ }
740
+ mutex_.Lock();
741
+ return s;
742
+ }
743
+
744
+ Status DBImpl::InitPersistStatsColumnFamily() {
745
+ mutex_.AssertHeld();
746
+ assert(!persist_stats_cf_handle_);
747
+ ColumnFamilyData* persistent_stats_cfd =
748
+ versions_->GetColumnFamilySet()->GetColumnFamily(
749
+ kPersistentStatsColumnFamilyName);
750
+ persistent_stats_cfd_exists_ = persistent_stats_cfd != nullptr;
751
+
752
+ Status s;
753
+ if (persistent_stats_cfd != nullptr) {
754
+ // We are recovering from a DB which already contains persistent stats CF,
755
+ // the CF is already created in VersionSet::ApplyOneVersionEdit, but
756
+ // column family handle was not. Need to explicitly create handle here.
757
+ persist_stats_cf_handle_ =
758
+ new ColumnFamilyHandleImpl(persistent_stats_cfd, this, &mutex_);
759
+ } else {
760
+ mutex_.Unlock();
761
+ ColumnFamilyHandle* handle = nullptr;
762
+ ColumnFamilyOptions cfo;
763
+ OptimizeForPersistentStats(&cfo);
764
+ s = CreateColumnFamily(cfo, kPersistentStatsColumnFamilyName, &handle);
765
+ persist_stats_cf_handle_ = static_cast<ColumnFamilyHandleImpl*>(handle);
766
+ mutex_.Lock();
767
+ }
768
+ return s;
769
+ }
770
+
771
+ // REQUIRES: wal_numbers are sorted in ascending order
772
+ Status DBImpl::RecoverLogFiles(const std::vector<uint64_t>& wal_numbers,
773
+ SequenceNumber* next_sequence, bool read_only,
774
+ bool* corrupted_wal_found) {
775
+ struct LogReporter : public log::Reader::Reporter {
776
+ Env* env;
777
+ Logger* info_log;
778
+ const char* fname;
779
+ Status* status; // nullptr if immutable_db_options_.paranoid_checks==false
780
+ void Corruption(size_t bytes, const Status& s) override {
781
+ ROCKS_LOG_WARN(info_log, "%s%s: dropping %d bytes; %s",
782
+ (status == nullptr ? "(ignoring error) " : ""), fname,
783
+ static_cast<int>(bytes), s.ToString().c_str());
784
+ if (status != nullptr && status->ok()) {
785
+ *status = s;
786
+ }
787
+ }
788
+ };
789
+
790
+ mutex_.AssertHeld();
791
+ Status status;
792
+ std::unordered_map<int, VersionEdit> version_edits;
793
+ // no need to refcount because iteration is under mutex
794
+ for (auto cfd : *versions_->GetColumnFamilySet()) {
795
+ VersionEdit edit;
796
+ edit.SetColumnFamily(cfd->GetID());
797
+ version_edits.insert({cfd->GetID(), edit});
798
+ }
799
+ int job_id = next_job_id_.fetch_add(1);
800
+ {
801
+ auto stream = event_logger_.Log();
802
+ stream << "job" << job_id << "event"
803
+ << "recovery_started";
804
+ stream << "wal_files";
805
+ stream.StartArray();
806
+ for (auto wal_number : wal_numbers) {
807
+ stream << wal_number;
808
+ }
809
+ stream.EndArray();
810
+ }
811
+
812
+ #ifndef ROCKSDB_LITE
813
+ if (immutable_db_options_.wal_filter != nullptr) {
814
+ std::map<std::string, uint32_t> cf_name_id_map;
815
+ std::map<uint32_t, uint64_t> cf_lognumber_map;
816
+ for (auto cfd : *versions_->GetColumnFamilySet()) {
817
+ cf_name_id_map.insert(std::make_pair(cfd->GetName(), cfd->GetID()));
818
+ cf_lognumber_map.insert(
819
+ std::make_pair(cfd->GetID(), cfd->GetLogNumber()));
820
+ }
821
+
822
+ immutable_db_options_.wal_filter->ColumnFamilyLogNumberMap(cf_lognumber_map,
823
+ cf_name_id_map);
824
+ }
825
+ #endif
826
+
827
+ bool stop_replay_by_wal_filter = false;
828
+ bool stop_replay_for_corruption = false;
829
+ bool flushed = false;
830
+ uint64_t corrupted_wal_number = kMaxSequenceNumber;
831
+ uint64_t min_wal_number = MinLogNumberToKeep();
832
+ for (auto wal_number : wal_numbers) {
833
+ if (wal_number < min_wal_number) {
834
+ ROCKS_LOG_INFO(immutable_db_options_.info_log,
835
+ "Skipping log #%" PRIu64
836
+ " since it is older than min log to keep #%" PRIu64,
837
+ wal_number, min_wal_number);
838
+ continue;
839
+ }
840
+ // The previous incarnation may not have written any MANIFEST
841
+ // records after allocating this log number. So we manually
842
+ // update the file number allocation counter in VersionSet.
843
+ versions_->MarkFileNumberUsed(wal_number);
844
+ // Open the log file
845
+ std::string fname = LogFileName(immutable_db_options_.wal_dir, wal_number);
846
+
847
+ ROCKS_LOG_INFO(immutable_db_options_.info_log,
848
+ "Recovering log #%" PRIu64 " mode %d", wal_number,
849
+ static_cast<int>(immutable_db_options_.wal_recovery_mode));
850
+ auto logFileDropped = [this, &fname]() {
851
+ uint64_t bytes;
852
+ if (env_->GetFileSize(fname, &bytes).ok()) {
853
+ auto info_log = immutable_db_options_.info_log.get();
854
+ ROCKS_LOG_WARN(info_log, "%s: dropping %d bytes", fname.c_str(),
855
+ static_cast<int>(bytes));
856
+ }
857
+ };
858
+ if (stop_replay_by_wal_filter) {
859
+ logFileDropped();
860
+ continue;
861
+ }
862
+
863
+ std::unique_ptr<SequentialFileReader> file_reader;
864
+ {
865
+ std::unique_ptr<FSSequentialFile> file;
866
+ status = fs_->NewSequentialFile(fname,
867
+ fs_->OptimizeForLogRead(file_options_),
868
+ &file, nullptr);
869
+ if (!status.ok()) {
870
+ MaybeIgnoreError(&status);
871
+ if (!status.ok()) {
872
+ return status;
873
+ } else {
874
+ // Fail with one log file, but that's ok.
875
+ // Try next one.
876
+ continue;
877
+ }
878
+ }
879
+ file_reader.reset(new SequentialFileReader(
880
+ std::move(file), fname, immutable_db_options_.log_readahead_size,
881
+ io_tracer_));
882
+ }
883
+
884
+ // Create the log reader.
885
+ LogReporter reporter;
886
+ reporter.env = env_;
887
+ reporter.info_log = immutable_db_options_.info_log.get();
888
+ reporter.fname = fname.c_str();
889
+ if (!immutable_db_options_.paranoid_checks ||
890
+ immutable_db_options_.wal_recovery_mode ==
891
+ WALRecoveryMode::kSkipAnyCorruptedRecords) {
892
+ reporter.status = nullptr;
893
+ } else {
894
+ reporter.status = &status;
895
+ }
896
+ // We intentially make log::Reader do checksumming even if
897
+ // paranoid_checks==false so that corruptions cause entire commits
898
+ // to be skipped instead of propagating bad information (like overly
899
+ // large sequence numbers).
900
+ log::Reader reader(immutable_db_options_.info_log, std::move(file_reader),
901
+ &reporter, true /*checksum*/, wal_number);
902
+
903
+ // Determine if we should tolerate incomplete records at the tail end of the
904
+ // Read all the records and add to a memtable
905
+ std::string scratch;
906
+ Slice record;
907
+ WriteBatch batch;
908
+
909
+ TEST_SYNC_POINT_CALLBACK("DBImpl::RecoverLogFiles:BeforeReadWal",
910
+ /*arg=*/nullptr);
911
+ while (!stop_replay_by_wal_filter &&
912
+ reader.ReadRecord(&record, &scratch,
913
+ immutable_db_options_.wal_recovery_mode) &&
914
+ status.ok()) {
915
+ if (record.size() < WriteBatchInternal::kHeader) {
916
+ reporter.Corruption(record.size(),
917
+ Status::Corruption("log record too small"));
918
+ continue;
919
+ }
920
+
921
+ status = WriteBatchInternal::SetContents(&batch, record);
922
+ if (!status.ok()) {
923
+ return status;
924
+ }
925
+ SequenceNumber sequence = WriteBatchInternal::Sequence(&batch);
926
+
927
+ if (immutable_db_options_.wal_recovery_mode ==
928
+ WALRecoveryMode::kPointInTimeRecovery) {
929
+ // In point-in-time recovery mode, if sequence id of log files are
930
+ // consecutive, we continue recovery despite corruption. This could
931
+ // happen when we open and write to a corrupted DB, where sequence id
932
+ // will start from the last sequence id we recovered.
933
+ if (sequence == *next_sequence) {
934
+ stop_replay_for_corruption = false;
935
+ }
936
+ if (stop_replay_for_corruption) {
937
+ logFileDropped();
938
+ break;
939
+ }
940
+ }
941
+
942
+ #ifndef ROCKSDB_LITE
943
+ if (immutable_db_options_.wal_filter != nullptr) {
944
+ WriteBatch new_batch;
945
+ bool batch_changed = false;
946
+
947
+ WalFilter::WalProcessingOption wal_processing_option =
948
+ immutable_db_options_.wal_filter->LogRecordFound(
949
+ wal_number, fname, batch, &new_batch, &batch_changed);
950
+
951
+ switch (wal_processing_option) {
952
+ case WalFilter::WalProcessingOption::kContinueProcessing:
953
+ // do nothing, proceeed normally
954
+ break;
955
+ case WalFilter::WalProcessingOption::kIgnoreCurrentRecord:
956
+ // skip current record
957
+ continue;
958
+ case WalFilter::WalProcessingOption::kStopReplay:
959
+ // skip current record and stop replay
960
+ stop_replay_by_wal_filter = true;
961
+ continue;
962
+ case WalFilter::WalProcessingOption::kCorruptedRecord: {
963
+ status =
964
+ Status::Corruption("Corruption reported by Wal Filter ",
965
+ immutable_db_options_.wal_filter->Name());
966
+ MaybeIgnoreError(&status);
967
+ if (!status.ok()) {
968
+ reporter.Corruption(record.size(), status);
969
+ continue;
970
+ }
971
+ break;
972
+ }
973
+ default: {
974
+ assert(false); // unhandled case
975
+ status = Status::NotSupported(
976
+ "Unknown WalProcessingOption returned"
977
+ " by Wal Filter ",
978
+ immutable_db_options_.wal_filter->Name());
979
+ MaybeIgnoreError(&status);
980
+ if (!status.ok()) {
981
+ return status;
982
+ } else {
983
+ // Ignore the error with current record processing.
984
+ continue;
985
+ }
986
+ }
987
+ }
988
+
989
+ if (batch_changed) {
990
+ // Make sure that the count in the new batch is
991
+ // within the orignal count.
992
+ int new_count = WriteBatchInternal::Count(&new_batch);
993
+ int original_count = WriteBatchInternal::Count(&batch);
994
+ if (new_count > original_count) {
995
+ ROCKS_LOG_FATAL(
996
+ immutable_db_options_.info_log,
997
+ "Recovering log #%" PRIu64
998
+ " mode %d log filter %s returned "
999
+ "more records (%d) than original (%d) which is not allowed. "
1000
+ "Aborting recovery.",
1001
+ wal_number,
1002
+ static_cast<int>(immutable_db_options_.wal_recovery_mode),
1003
+ immutable_db_options_.wal_filter->Name(), new_count,
1004
+ original_count);
1005
+ status = Status::NotSupported(
1006
+ "More than original # of records "
1007
+ "returned by Wal Filter ",
1008
+ immutable_db_options_.wal_filter->Name());
1009
+ return status;
1010
+ }
1011
+ // Set the same sequence number in the new_batch
1012
+ // as the original batch.
1013
+ WriteBatchInternal::SetSequence(&new_batch,
1014
+ WriteBatchInternal::Sequence(&batch));
1015
+ batch = new_batch;
1016
+ }
1017
+ }
1018
+ #endif // ROCKSDB_LITE
1019
+
1020
+ // If column family was not found, it might mean that the WAL write
1021
+ // batch references to the column family that was dropped after the
1022
+ // insert. We don't want to fail the whole write batch in that case --
1023
+ // we just ignore the update.
1024
+ // That's why we set ignore missing column families to true
1025
+ bool has_valid_writes = false;
1026
+ status = WriteBatchInternal::InsertInto(
1027
+ &batch, column_family_memtables_.get(), &flush_scheduler_,
1028
+ &trim_history_scheduler_, true, wal_number, this,
1029
+ false /* concurrent_memtable_writes */, next_sequence,
1030
+ &has_valid_writes, seq_per_batch_, batch_per_txn_);
1031
+ MaybeIgnoreError(&status);
1032
+ if (!status.ok()) {
1033
+ // We are treating this as a failure while reading since we read valid
1034
+ // blocks that do not form coherent data
1035
+ reporter.Corruption(record.size(), status);
1036
+ continue;
1037
+ }
1038
+
1039
+ if (has_valid_writes && !read_only) {
1040
+ // we can do this because this is called before client has access to the
1041
+ // DB and there is only a single thread operating on DB
1042
+ ColumnFamilyData* cfd;
1043
+
1044
+ while ((cfd = flush_scheduler_.TakeNextColumnFamily()) != nullptr) {
1045
+ cfd->UnrefAndTryDelete();
1046
+ // If this asserts, it means that InsertInto failed in
1047
+ // filtering updates to already-flushed column families
1048
+ assert(cfd->GetLogNumber() <= wal_number);
1049
+ auto iter = version_edits.find(cfd->GetID());
1050
+ assert(iter != version_edits.end());
1051
+ VersionEdit* edit = &iter->second;
1052
+ status = WriteLevel0TableForRecovery(job_id, cfd, cfd->mem(), edit);
1053
+ if (!status.ok()) {
1054
+ // Reflect errors immediately so that conditions like full
1055
+ // file-systems cause the DB::Open() to fail.
1056
+ return status;
1057
+ }
1058
+ flushed = true;
1059
+
1060
+ cfd->CreateNewMemtable(*cfd->GetLatestMutableCFOptions(),
1061
+ *next_sequence);
1062
+ }
1063
+ }
1064
+ }
1065
+
1066
+ if (!status.ok()) {
1067
+ if (status.IsNotSupported()) {
1068
+ // We should not treat NotSupported as corruption. It is rather a clear
1069
+ // sign that we are processing a WAL that is produced by an incompatible
1070
+ // version of the code.
1071
+ return status;
1072
+ }
1073
+ if (immutable_db_options_.wal_recovery_mode ==
1074
+ WALRecoveryMode::kSkipAnyCorruptedRecords) {
1075
+ // We should ignore all errors unconditionally
1076
+ status = Status::OK();
1077
+ } else if (immutable_db_options_.wal_recovery_mode ==
1078
+ WALRecoveryMode::kPointInTimeRecovery) {
1079
+ if (status.IsIOError()) {
1080
+ ROCKS_LOG_ERROR(immutable_db_options_.info_log,
1081
+ "IOError during point-in-time reading log #%" PRIu64
1082
+ " seq #%" PRIu64
1083
+ ". %s. This likely mean loss of synced WAL, "
1084
+ "thus recovery fails.",
1085
+ wal_number, *next_sequence,
1086
+ status.ToString().c_str());
1087
+ return status;
1088
+ }
1089
+ // We should ignore the error but not continue replaying
1090
+ status = Status::OK();
1091
+ stop_replay_for_corruption = true;
1092
+ corrupted_wal_number = wal_number;
1093
+ if (corrupted_wal_found != nullptr) {
1094
+ *corrupted_wal_found = true;
1095
+ }
1096
+ ROCKS_LOG_INFO(immutable_db_options_.info_log,
1097
+ "Point in time recovered to log #%" PRIu64
1098
+ " seq #%" PRIu64,
1099
+ wal_number, *next_sequence);
1100
+ } else {
1101
+ assert(immutable_db_options_.wal_recovery_mode ==
1102
+ WALRecoveryMode::kTolerateCorruptedTailRecords ||
1103
+ immutable_db_options_.wal_recovery_mode ==
1104
+ WALRecoveryMode::kAbsoluteConsistency);
1105
+ return status;
1106
+ }
1107
+ }
1108
+
1109
+ flush_scheduler_.Clear();
1110
+ trim_history_scheduler_.Clear();
1111
+ auto last_sequence = *next_sequence - 1;
1112
+ if ((*next_sequence != kMaxSequenceNumber) &&
1113
+ (versions_->LastSequence() <= last_sequence)) {
1114
+ versions_->SetLastAllocatedSequence(last_sequence);
1115
+ versions_->SetLastPublishedSequence(last_sequence);
1116
+ versions_->SetLastSequence(last_sequence);
1117
+ }
1118
+ }
1119
+ // Compare the corrupted log number to all columnfamily's current log number.
1120
+ // Abort Open() if any column family's log number is greater than
1121
+ // the corrupted log number, which means CF contains data beyond the point of
1122
+ // corruption. This could during PIT recovery when the WAL is corrupted and
1123
+ // some (but not all) CFs are flushed
1124
+ // Exclude the PIT case where no log is dropped after the corruption point.
1125
+ // This is to cover the case for empty wals after corrupted log, in which we
1126
+ // don't reset stop_replay_for_corruption.
1127
+ if (stop_replay_for_corruption == true &&
1128
+ (immutable_db_options_.wal_recovery_mode ==
1129
+ WALRecoveryMode::kPointInTimeRecovery ||
1130
+ immutable_db_options_.wal_recovery_mode ==
1131
+ WALRecoveryMode::kTolerateCorruptedTailRecords)) {
1132
+ for (auto cfd : *versions_->GetColumnFamilySet()) {
1133
+ if (cfd->GetLogNumber() > corrupted_wal_number) {
1134
+ ROCKS_LOG_ERROR(immutable_db_options_.info_log,
1135
+ "Column family inconsistency: SST file contains data"
1136
+ " beyond the point of corruption.");
1137
+ return Status::Corruption("SST file is ahead of WALs");
1138
+ }
1139
+ }
1140
+ }
1141
+
1142
+ // True if there's any data in the WALs; if not, we can skip re-processing
1143
+ // them later
1144
+ bool data_seen = false;
1145
+ if (!read_only) {
1146
+ // no need to refcount since client still doesn't have access
1147
+ // to the DB and can not drop column families while we iterate
1148
+ const WalNumber max_wal_number = wal_numbers.back();
1149
+ for (auto cfd : *versions_->GetColumnFamilySet()) {
1150
+ auto iter = version_edits.find(cfd->GetID());
1151
+ assert(iter != version_edits.end());
1152
+ VersionEdit* edit = &iter->second;
1153
+
1154
+ if (cfd->GetLogNumber() > max_wal_number) {
1155
+ // Column family cfd has already flushed the data
1156
+ // from all wals. Memtable has to be empty because
1157
+ // we filter the updates based on wal_number
1158
+ // (in WriteBatch::InsertInto)
1159
+ assert(cfd->mem()->GetFirstSequenceNumber() == 0);
1160
+ assert(edit->NumEntries() == 0);
1161
+ continue;
1162
+ }
1163
+
1164
+ TEST_SYNC_POINT_CALLBACK(
1165
+ "DBImpl::RecoverLogFiles:BeforeFlushFinalMemtable", /*arg=*/nullptr);
1166
+
1167
+ // flush the final memtable (if non-empty)
1168
+ if (cfd->mem()->GetFirstSequenceNumber() != 0) {
1169
+ // If flush happened in the middle of recovery (e.g. due to memtable
1170
+ // being full), we flush at the end. Otherwise we'll need to record
1171
+ // where we were on last flush, which make the logic complicated.
1172
+ if (flushed || !immutable_db_options_.avoid_flush_during_recovery) {
1173
+ status = WriteLevel0TableForRecovery(job_id, cfd, cfd->mem(), edit);
1174
+ if (!status.ok()) {
1175
+ // Recovery failed
1176
+ break;
1177
+ }
1178
+ flushed = true;
1179
+
1180
+ cfd->CreateNewMemtable(*cfd->GetLatestMutableCFOptions(),
1181
+ versions_->LastSequence());
1182
+ }
1183
+ data_seen = true;
1184
+ }
1185
+
1186
+ // Update the log number info in the version edit corresponding to this
1187
+ // column family. Note that the version edits will be written to MANIFEST
1188
+ // together later.
1189
+ // writing wal_number in the manifest means that any log file
1190
+ // with number strongly less than (wal_number + 1) is already
1191
+ // recovered and should be ignored on next reincarnation.
1192
+ // Since we already recovered max_wal_number, we want all wals
1193
+ // with numbers `<= max_wal_number` (includes this one) to be ignored
1194
+ if (flushed || cfd->mem()->GetFirstSequenceNumber() == 0) {
1195
+ edit->SetLogNumber(max_wal_number + 1);
1196
+ }
1197
+ }
1198
+ if (status.ok()) {
1199
+ // we must mark the next log number as used, even though it's
1200
+ // not actually used. that is because VersionSet assumes
1201
+ // VersionSet::next_file_number_ always to be strictly greater than any
1202
+ // log number
1203
+ versions_->MarkFileNumberUsed(max_wal_number + 1);
1204
+
1205
+ autovector<ColumnFamilyData*> cfds;
1206
+ autovector<const MutableCFOptions*> cf_opts;
1207
+ autovector<autovector<VersionEdit*>> edit_lists;
1208
+ for (auto* cfd : *versions_->GetColumnFamilySet()) {
1209
+ cfds.push_back(cfd);
1210
+ cf_opts.push_back(cfd->GetLatestMutableCFOptions());
1211
+ auto iter = version_edits.find(cfd->GetID());
1212
+ assert(iter != version_edits.end());
1213
+ edit_lists.push_back({&iter->second});
1214
+ }
1215
+
1216
+ std::unique_ptr<VersionEdit> wal_deletion;
1217
+ if (immutable_db_options_.track_and_verify_wals_in_manifest) {
1218
+ wal_deletion.reset(new VersionEdit);
1219
+ wal_deletion->DeleteWalsBefore(max_wal_number + 1);
1220
+ edit_lists.back().push_back(wal_deletion.get());
1221
+ }
1222
+
1223
+ // write MANIFEST with update
1224
+ status = versions_->LogAndApply(cfds, cf_opts, edit_lists, &mutex_,
1225
+ directories_.GetDbDir(),
1226
+ /*new_descriptor_log=*/true);
1227
+ }
1228
+ }
1229
+
1230
+ if (status.ok() && data_seen && !flushed) {
1231
+ status = RestoreAliveLogFiles(wal_numbers);
1232
+ }
1233
+
1234
+ event_logger_.Log() << "job" << job_id << "event"
1235
+ << "recovery_finished";
1236
+
1237
+ return status;
1238
+ }
1239
+
1240
+ Status DBImpl::RestoreAliveLogFiles(const std::vector<uint64_t>& wal_numbers) {
1241
+ if (wal_numbers.empty()) {
1242
+ return Status::OK();
1243
+ }
1244
+ Status s;
1245
+ mutex_.AssertHeld();
1246
+ assert(immutable_db_options_.avoid_flush_during_recovery);
1247
+ if (two_write_queues_) {
1248
+ log_write_mutex_.Lock();
1249
+ }
1250
+ // Mark these as alive so they'll be considered for deletion later by
1251
+ // FindObsoleteFiles()
1252
+ total_log_size_ = 0;
1253
+ log_empty_ = false;
1254
+ for (auto wal_number : wal_numbers) {
1255
+ LogFileNumberSize log(wal_number);
1256
+ std::string fname = LogFileName(immutable_db_options_.wal_dir, wal_number);
1257
+ // This gets the appear size of the wals, not including preallocated space.
1258
+ s = env_->GetFileSize(fname, &log.size);
1259
+ if (!s.ok()) {
1260
+ break;
1261
+ }
1262
+ total_log_size_ += log.size;
1263
+ alive_log_files_.push_back(log);
1264
+ // We preallocate space for wals, but then after a crash and restart, those
1265
+ // preallocated space are not needed anymore. It is likely only the last
1266
+ // log has such preallocated space, so we only truncate for the last log.
1267
+ if (wal_number == wal_numbers.back()) {
1268
+ std::unique_ptr<FSWritableFile> last_log;
1269
+ Status truncate_status = fs_->ReopenWritableFile(
1270
+ fname,
1271
+ fs_->OptimizeForLogWrite(
1272
+ file_options_,
1273
+ BuildDBOptions(immutable_db_options_, mutable_db_options_)),
1274
+ &last_log, nullptr);
1275
+ if (truncate_status.ok()) {
1276
+ truncate_status = last_log->Truncate(log.size, IOOptions(), nullptr);
1277
+ }
1278
+ if (truncate_status.ok()) {
1279
+ truncate_status = last_log->Close(IOOptions(), nullptr);
1280
+ }
1281
+ // Not a critical error if fail to truncate.
1282
+ if (!truncate_status.ok()) {
1283
+ ROCKS_LOG_WARN(immutable_db_options_.info_log,
1284
+ "Failed to truncate log #%" PRIu64 ": %s", wal_number,
1285
+ truncate_status.ToString().c_str());
1286
+ }
1287
+ }
1288
+ }
1289
+ if (two_write_queues_) {
1290
+ log_write_mutex_.Unlock();
1291
+ }
1292
+ return s;
1293
+ }
1294
+
1295
+ Status DBImpl::WriteLevel0TableForRecovery(int job_id, ColumnFamilyData* cfd,
1296
+ MemTable* mem, VersionEdit* edit) {
1297
+ mutex_.AssertHeld();
1298
+ const uint64_t start_micros = env_->NowMicros();
1299
+
1300
+ FileMetaData meta;
1301
+ std::vector<BlobFileAddition> blob_file_additions;
1302
+
1303
+ std::unique_ptr<std::list<uint64_t>::iterator> pending_outputs_inserted_elem(
1304
+ new std::list<uint64_t>::iterator(
1305
+ CaptureCurrentFileNumberInPendingOutputs()));
1306
+ meta.fd = FileDescriptor(versions_->NewFileNumber(), 0, 0);
1307
+ ReadOptions ro;
1308
+ ro.total_order_seek = true;
1309
+ Arena arena;
1310
+ Status s;
1311
+ TableProperties table_properties;
1312
+ {
1313
+ ScopedArenaIterator iter(mem->NewIterator(ro, &arena));
1314
+ ROCKS_LOG_DEBUG(immutable_db_options_.info_log,
1315
+ "[%s] [WriteLevel0TableForRecovery]"
1316
+ " Level-0 table #%" PRIu64 ": started",
1317
+ cfd->GetName().c_str(), meta.fd.GetNumber());
1318
+
1319
+ // Get the latest mutable cf options while the mutex is still locked
1320
+ const MutableCFOptions mutable_cf_options =
1321
+ *cfd->GetLatestMutableCFOptions();
1322
+ bool paranoid_file_checks =
1323
+ cfd->GetLatestMutableCFOptions()->paranoid_file_checks;
1324
+
1325
+ int64_t _current_time = 0;
1326
+ env_->GetCurrentTime(&_current_time)
1327
+ .PermitUncheckedError(); // ignore error
1328
+ const uint64_t current_time = static_cast<uint64_t>(_current_time);
1329
+ meta.oldest_ancester_time = current_time;
1330
+
1331
+ {
1332
+ auto write_hint = cfd->CalculateSSTWriteHint(0);
1333
+ mutex_.Unlock();
1334
+
1335
+ SequenceNumber earliest_write_conflict_snapshot;
1336
+ std::vector<SequenceNumber> snapshot_seqs =
1337
+ snapshots_.GetAll(&earliest_write_conflict_snapshot);
1338
+ auto snapshot_checker = snapshot_checker_.get();
1339
+ if (use_custom_gc_ && snapshot_checker == nullptr) {
1340
+ snapshot_checker = DisableGCSnapshotChecker::Instance();
1341
+ }
1342
+ std::vector<std::unique_ptr<FragmentedRangeTombstoneIterator>>
1343
+ range_del_iters;
1344
+ auto range_del_iter =
1345
+ mem->NewRangeTombstoneIterator(ro, kMaxSequenceNumber);
1346
+ if (range_del_iter != nullptr) {
1347
+ range_del_iters.emplace_back(range_del_iter);
1348
+ }
1349
+
1350
+ IOStatus io_s;
1351
+ s = BuildTable(
1352
+ dbname_, versions_.get(), immutable_db_options_, *cfd->ioptions(),
1353
+ mutable_cf_options, file_options_for_compaction_, cfd->table_cache(),
1354
+ iter.get(), std::move(range_del_iters), &meta, &blob_file_additions,
1355
+ cfd->internal_comparator(), cfd->int_tbl_prop_collector_factories(),
1356
+ cfd->GetID(), cfd->GetName(), snapshot_seqs,
1357
+ earliest_write_conflict_snapshot, snapshot_checker,
1358
+ GetCompressionFlush(*cfd->ioptions(), mutable_cf_options),
1359
+ mutable_cf_options.sample_for_compression,
1360
+ mutable_cf_options.compression_opts, paranoid_file_checks,
1361
+ cfd->internal_stats(), TableFileCreationReason::kRecovery, &io_s,
1362
+ io_tracer_, &event_logger_, job_id, Env::IO_HIGH,
1363
+ nullptr /* table_properties */, -1 /* level */, current_time,
1364
+ 0 /* oldest_key_time */, write_hint, 0 /* file_creation_time */,
1365
+ db_id_, db_session_id_);
1366
+ LogFlush(immutable_db_options_.info_log);
1367
+ ROCKS_LOG_DEBUG(immutable_db_options_.info_log,
1368
+ "[%s] [WriteLevel0TableForRecovery]"
1369
+ " Level-0 table #%" PRIu64 ": %" PRIu64 " bytes %s",
1370
+ cfd->GetName().c_str(), meta.fd.GetNumber(),
1371
+ meta.fd.GetFileSize(), s.ToString().c_str());
1372
+ mutex_.Lock();
1373
+
1374
+ io_s.PermitUncheckedError(); // TODO(AR) is this correct, or should we
1375
+ // return io_s if not ok()?
1376
+ }
1377
+ }
1378
+ ReleaseFileNumberFromPendingOutputs(pending_outputs_inserted_elem);
1379
+
1380
+ // Note that if file_size is zero, the file has been deleted and
1381
+ // should not be added to the manifest.
1382
+ const bool has_output = meta.fd.GetFileSize() > 0;
1383
+
1384
+ constexpr int level = 0;
1385
+
1386
+ if (s.ok() && has_output) {
1387
+ edit->AddFile(level, meta.fd.GetNumber(), meta.fd.GetPathId(),
1388
+ meta.fd.GetFileSize(), meta.smallest, meta.largest,
1389
+ meta.fd.smallest_seqno, meta.fd.largest_seqno,
1390
+ meta.marked_for_compaction, meta.oldest_blob_file_number,
1391
+ meta.oldest_ancester_time, meta.file_creation_time,
1392
+ meta.file_checksum, meta.file_checksum_func_name);
1393
+
1394
+ edit->SetBlobFileAdditions(std::move(blob_file_additions));
1395
+ }
1396
+
1397
+ InternalStats::CompactionStats stats(CompactionReason::kFlush, 1);
1398
+ stats.micros = env_->NowMicros() - start_micros;
1399
+
1400
+ if (has_output) {
1401
+ stats.bytes_written = meta.fd.GetFileSize();
1402
+ stats.num_output_files = 1;
1403
+ }
1404
+
1405
+ const auto& blobs = edit->GetBlobFileAdditions();
1406
+ for (const auto& blob : blobs) {
1407
+ stats.bytes_written += blob.GetTotalBlobBytes();
1408
+ }
1409
+
1410
+ stats.num_output_files += static_cast<int>(blobs.size());
1411
+
1412
+ cfd->internal_stats()->AddCompactionStats(level, Env::Priority::USER, stats);
1413
+ cfd->internal_stats()->AddCFStats(InternalStats::BYTES_FLUSHED,
1414
+ stats.bytes_written);
1415
+ RecordTick(stats_, COMPACT_WRITE_BYTES, meta.fd.GetFileSize());
1416
+ return s;
1417
+ }
1418
+
1419
+ Status DB::Open(const Options& options, const std::string& dbname, DB** dbptr) {
1420
+ DBOptions db_options(options);
1421
+ ColumnFamilyOptions cf_options(options);
1422
+ std::vector<ColumnFamilyDescriptor> column_families;
1423
+ column_families.push_back(
1424
+ ColumnFamilyDescriptor(kDefaultColumnFamilyName, cf_options));
1425
+ if (db_options.persist_stats_to_disk) {
1426
+ column_families.push_back(
1427
+ ColumnFamilyDescriptor(kPersistentStatsColumnFamilyName, cf_options));
1428
+ }
1429
+ std::vector<ColumnFamilyHandle*> handles;
1430
+ Status s = DB::Open(db_options, dbname, column_families, &handles, dbptr);
1431
+ if (s.ok()) {
1432
+ if (db_options.persist_stats_to_disk) {
1433
+ assert(handles.size() == 2);
1434
+ } else {
1435
+ assert(handles.size() == 1);
1436
+ }
1437
+ // i can delete the handle since DBImpl is always holding a reference to
1438
+ // default column family
1439
+ if (db_options.persist_stats_to_disk && handles[1] != nullptr) {
1440
+ delete handles[1];
1441
+ }
1442
+ delete handles[0];
1443
+ }
1444
+ return s;
1445
+ }
1446
+
1447
+ Status DB::Open(const DBOptions& db_options, const std::string& dbname,
1448
+ const std::vector<ColumnFamilyDescriptor>& column_families,
1449
+ std::vector<ColumnFamilyHandle*>* handles, DB** dbptr) {
1450
+ const bool kSeqPerBatch = true;
1451
+ const bool kBatchPerTxn = true;
1452
+ return DBImpl::Open(db_options, dbname, column_families, handles, dbptr,
1453
+ !kSeqPerBatch, kBatchPerTxn);
1454
+ }
1455
+
1456
+ IOStatus DBImpl::CreateWAL(uint64_t log_file_num, uint64_t recycle_log_number,
1457
+ size_t preallocate_block_size,
1458
+ log::Writer** new_log) {
1459
+ IOStatus io_s;
1460
+ std::unique_ptr<FSWritableFile> lfile;
1461
+
1462
+ DBOptions db_options =
1463
+ BuildDBOptions(immutable_db_options_, mutable_db_options_);
1464
+ FileOptions opt_file_options =
1465
+ fs_->OptimizeForLogWrite(file_options_, db_options);
1466
+ std::string log_fname =
1467
+ LogFileName(immutable_db_options_.wal_dir, log_file_num);
1468
+
1469
+ if (recycle_log_number) {
1470
+ ROCKS_LOG_INFO(immutable_db_options_.info_log,
1471
+ "reusing log %" PRIu64 " from recycle list\n",
1472
+ recycle_log_number);
1473
+ std::string old_log_fname =
1474
+ LogFileName(immutable_db_options_.wal_dir, recycle_log_number);
1475
+ TEST_SYNC_POINT("DBImpl::CreateWAL:BeforeReuseWritableFile1");
1476
+ TEST_SYNC_POINT("DBImpl::CreateWAL:BeforeReuseWritableFile2");
1477
+ io_s = fs_->ReuseWritableFile(log_fname, old_log_fname, opt_file_options,
1478
+ &lfile, /*dbg=*/nullptr);
1479
+ } else {
1480
+ io_s = NewWritableFile(fs_.get(), log_fname, &lfile, opt_file_options);
1481
+ }
1482
+
1483
+ if (io_s.ok()) {
1484
+ lfile->SetWriteLifeTimeHint(CalculateWALWriteHint());
1485
+ lfile->SetPreallocationBlockSize(preallocate_block_size);
1486
+
1487
+ const auto& listeners = immutable_db_options_.listeners;
1488
+ std::unique_ptr<WritableFileWriter> file_writer(new WritableFileWriter(
1489
+ std::move(lfile), log_fname, opt_file_options, env_, io_tracer_,
1490
+ nullptr /* stats */, listeners));
1491
+ *new_log = new log::Writer(std::move(file_writer), log_file_num,
1492
+ immutable_db_options_.recycle_log_file_num > 0,
1493
+ immutable_db_options_.manual_wal_flush);
1494
+ }
1495
+ return io_s;
1496
+ }
1497
+
1498
+ Status DBImpl::Open(const DBOptions& db_options, const std::string& dbname,
1499
+ const std::vector<ColumnFamilyDescriptor>& column_families,
1500
+ std::vector<ColumnFamilyHandle*>* handles, DB** dbptr,
1501
+ const bool seq_per_batch, const bool batch_per_txn) {
1502
+ Status s = ValidateOptionsByTable(db_options, column_families);
1503
+ if (!s.ok()) {
1504
+ return s;
1505
+ }
1506
+
1507
+ s = ValidateOptions(db_options, column_families);
1508
+ if (!s.ok()) {
1509
+ return s;
1510
+ }
1511
+
1512
+ *dbptr = nullptr;
1513
+ handles->clear();
1514
+
1515
+ size_t max_write_buffer_size = 0;
1516
+ for (auto cf : column_families) {
1517
+ max_write_buffer_size =
1518
+ std::max(max_write_buffer_size, cf.options.write_buffer_size);
1519
+ }
1520
+
1521
+ DBImpl* impl = new DBImpl(db_options, dbname, seq_per_batch, batch_per_txn);
1522
+ s = impl->env_->CreateDirIfMissing(impl->immutable_db_options_.wal_dir);
1523
+ if (s.ok()) {
1524
+ std::vector<std::string> paths;
1525
+ for (auto& db_path : impl->immutable_db_options_.db_paths) {
1526
+ paths.emplace_back(db_path.path);
1527
+ }
1528
+ for (auto& cf : column_families) {
1529
+ for (auto& cf_path : cf.options.cf_paths) {
1530
+ paths.emplace_back(cf_path.path);
1531
+ }
1532
+ }
1533
+ for (auto& path : paths) {
1534
+ s = impl->env_->CreateDirIfMissing(path);
1535
+ if (!s.ok()) {
1536
+ break;
1537
+ }
1538
+ }
1539
+
1540
+ // For recovery from NoSpace() error, we can only handle
1541
+ // the case where the database is stored in a single path
1542
+ if (paths.size() <= 1) {
1543
+ impl->error_handler_.EnableAutoRecovery();
1544
+ }
1545
+ }
1546
+ if (s.ok()) {
1547
+ s = impl->CreateArchivalDirectory();
1548
+ }
1549
+ if (!s.ok()) {
1550
+ delete impl;
1551
+ return s;
1552
+ }
1553
+
1554
+ impl->wal_in_db_path_ = IsWalDirSameAsDBPath(&impl->immutable_db_options_);
1555
+
1556
+ impl->mutex_.Lock();
1557
+ // Handles create_if_missing, error_if_exists
1558
+ uint64_t recovered_seq(kMaxSequenceNumber);
1559
+ s = impl->Recover(column_families, false, false, false, &recovered_seq);
1560
+ if (s.ok()) {
1561
+ uint64_t new_log_number = impl->versions_->NewFileNumber();
1562
+ log::Writer* new_log = nullptr;
1563
+ const size_t preallocate_block_size =
1564
+ impl->GetWalPreallocateBlockSize(max_write_buffer_size);
1565
+ s = impl->CreateWAL(new_log_number, 0 /*recycle_log_number*/,
1566
+ preallocate_block_size, &new_log);
1567
+ if (s.ok()) {
1568
+ InstrumentedMutexLock wl(&impl->log_write_mutex_);
1569
+ impl->logfile_number_ = new_log_number;
1570
+ assert(new_log != nullptr);
1571
+ assert(impl->logs_.empty());
1572
+ impl->logs_.emplace_back(new_log_number, new_log);
1573
+ }
1574
+
1575
+ if (s.ok()) {
1576
+ // set column family handles
1577
+ for (auto cf : column_families) {
1578
+ auto cfd =
1579
+ impl->versions_->GetColumnFamilySet()->GetColumnFamily(cf.name);
1580
+ if (cfd != nullptr) {
1581
+ handles->push_back(
1582
+ new ColumnFamilyHandleImpl(cfd, impl, &impl->mutex_));
1583
+ impl->NewThreadStatusCfInfo(cfd);
1584
+ } else {
1585
+ if (db_options.create_missing_column_families) {
1586
+ // missing column family, create it
1587
+ ColumnFamilyHandle* handle;
1588
+ impl->mutex_.Unlock();
1589
+ s = impl->CreateColumnFamily(cf.options, cf.name, &handle);
1590
+ impl->mutex_.Lock();
1591
+ if (s.ok()) {
1592
+ handles->push_back(handle);
1593
+ } else {
1594
+ break;
1595
+ }
1596
+ } else {
1597
+ s = Status::InvalidArgument("Column family not found", cf.name);
1598
+ break;
1599
+ }
1600
+ }
1601
+ }
1602
+ }
1603
+ if (s.ok()) {
1604
+ SuperVersionContext sv_context(/* create_superversion */ true);
1605
+ for (auto cfd : *impl->versions_->GetColumnFamilySet()) {
1606
+ impl->InstallSuperVersionAndScheduleWork(
1607
+ cfd, &sv_context, *cfd->GetLatestMutableCFOptions());
1608
+ }
1609
+ sv_context.Clean();
1610
+ if (impl->two_write_queues_) {
1611
+ impl->log_write_mutex_.Lock();
1612
+ }
1613
+ impl->alive_log_files_.push_back(
1614
+ DBImpl::LogFileNumberSize(impl->logfile_number_));
1615
+ if (impl->two_write_queues_) {
1616
+ impl->log_write_mutex_.Unlock();
1617
+ }
1618
+
1619
+ impl->DeleteObsoleteFiles();
1620
+ s = impl->directories_.GetDbDir()->Fsync(IOOptions(), nullptr);
1621
+ }
1622
+ if (s.ok()) {
1623
+ // In WritePrepared there could be gap in sequence numbers. This breaks
1624
+ // the trick we use in kPointInTimeRecovery which assumes the first seq in
1625
+ // the log right after the corrupted log is one larger than the last seq
1626
+ // we read from the wals. To let this trick keep working, we add a dummy
1627
+ // entry with the expected sequence to the first log right after recovery.
1628
+ // In non-WritePrepared case also the new log after recovery could be
1629
+ // empty, and thus missing the consecutive seq hint to distinguish
1630
+ // middle-log corruption to corrupted-log-remained-after-recovery. This
1631
+ // case also will be addressed by a dummy write.
1632
+ if (recovered_seq != kMaxSequenceNumber) {
1633
+ WriteBatch empty_batch;
1634
+ WriteBatchInternal::SetSequence(&empty_batch, recovered_seq);
1635
+ WriteOptions write_options;
1636
+ uint64_t log_used, log_size;
1637
+ log::Writer* log_writer = impl->logs_.back().writer;
1638
+ s = impl->WriteToWAL(empty_batch, log_writer, &log_used, &log_size);
1639
+ if (s.ok()) {
1640
+ // Need to fsync, otherwise it might get lost after a power reset.
1641
+ s = impl->FlushWAL(false);
1642
+ if (s.ok()) {
1643
+ s = log_writer->file()->Sync(impl->immutable_db_options_.use_fsync);
1644
+ }
1645
+ }
1646
+ }
1647
+ }
1648
+ }
1649
+ if (s.ok() && impl->immutable_db_options_.persist_stats_to_disk) {
1650
+ // try to read format version
1651
+ s = impl->PersistentStatsProcessFormatVersion();
1652
+ }
1653
+
1654
+ if (s.ok()) {
1655
+ for (auto cfd : *impl->versions_->GetColumnFamilySet()) {
1656
+ if (cfd->ioptions()->compaction_style == kCompactionStyleFIFO) {
1657
+ auto* vstorage = cfd->current()->storage_info();
1658
+ for (int i = 1; i < vstorage->num_levels(); ++i) {
1659
+ int num_files = vstorage->NumLevelFiles(i);
1660
+ if (num_files > 0) {
1661
+ s = Status::InvalidArgument(
1662
+ "Not all files are at level 0. Cannot "
1663
+ "open with FIFO compaction style.");
1664
+ break;
1665
+ }
1666
+ }
1667
+ }
1668
+ if (!cfd->mem()->IsSnapshotSupported()) {
1669
+ impl->is_snapshot_supported_ = false;
1670
+ }
1671
+ if (cfd->ioptions()->merge_operator != nullptr &&
1672
+ !cfd->mem()->IsMergeOperatorSupported()) {
1673
+ s = Status::InvalidArgument(
1674
+ "The memtable of column family %s does not support merge operator "
1675
+ "its options.merge_operator is non-null",
1676
+ cfd->GetName().c_str());
1677
+ }
1678
+ if (!s.ok()) {
1679
+ break;
1680
+ }
1681
+ }
1682
+ }
1683
+ TEST_SYNC_POINT("DBImpl::Open:Opened");
1684
+ Status persist_options_status;
1685
+ if (s.ok()) {
1686
+ // Persist RocksDB Options before scheduling the compaction.
1687
+ // The WriteOptionsFile() will release and lock the mutex internally.
1688
+ persist_options_status = impl->WriteOptionsFile(
1689
+ false /*need_mutex_lock*/, false /*need_enter_write_thread*/);
1690
+
1691
+ *dbptr = impl;
1692
+ impl->opened_successfully_ = true;
1693
+ impl->MaybeScheduleFlushOrCompaction();
1694
+ } else {
1695
+ persist_options_status.PermitUncheckedError();
1696
+ }
1697
+ impl->mutex_.Unlock();
1698
+
1699
+ #ifndef ROCKSDB_LITE
1700
+ auto sfm = static_cast<SstFileManagerImpl*>(
1701
+ impl->immutable_db_options_.sst_file_manager.get());
1702
+ if (s.ok() && sfm) {
1703
+ // Set Statistics ptr for SstFileManager to dump the stats of
1704
+ // DeleteScheduler.
1705
+ sfm->SetStatisticsPtr(impl->immutable_db_options_.statistics);
1706
+ ROCKS_LOG_INFO(impl->immutable_db_options_.info_log,
1707
+ "SstFileManager instance %p", sfm);
1708
+
1709
+ // Notify SstFileManager about all sst files that already exist in
1710
+ // db_paths[0] and cf_paths[0] when the DB is opened.
1711
+
1712
+ // SstFileManagerImpl needs to know sizes of the files. For files whose size
1713
+ // we already know (sst files that appear in manifest - typically that's the
1714
+ // vast majority of all files), we'll pass the size to SstFileManager.
1715
+ // For all other files SstFileManager will query the size from filesystem.
1716
+
1717
+ std::vector<LiveFileMetaData> metadata;
1718
+
1719
+ impl->mutex_.Lock();
1720
+ impl->versions_->GetLiveFilesMetaData(&metadata);
1721
+ impl->mutex_.Unlock();
1722
+
1723
+ std::unordered_map<std::string, uint64_t> known_file_sizes;
1724
+ for (const auto& md : metadata) {
1725
+ std::string name = md.name;
1726
+ if (!name.empty() && name[0] == '/') {
1727
+ name = name.substr(1);
1728
+ }
1729
+ known_file_sizes[name] = md.size;
1730
+ }
1731
+
1732
+ std::vector<std::string> paths;
1733
+ paths.emplace_back(impl->immutable_db_options_.db_paths[0].path);
1734
+ for (auto& cf : column_families) {
1735
+ if (!cf.options.cf_paths.empty()) {
1736
+ paths.emplace_back(cf.options.cf_paths[0].path);
1737
+ }
1738
+ }
1739
+ // Remove duplicate paths.
1740
+ std::sort(paths.begin(), paths.end());
1741
+ paths.erase(std::unique(paths.begin(), paths.end()), paths.end());
1742
+ for (auto& path : paths) {
1743
+ std::vector<std::string> existing_files;
1744
+ impl->immutable_db_options_.env->GetChildren(path, &existing_files)
1745
+ .PermitUncheckedError(); //**TODO: What do to on error?
1746
+ for (auto& file_name : existing_files) {
1747
+ uint64_t file_number;
1748
+ FileType file_type;
1749
+ std::string file_path = path + "/" + file_name;
1750
+ if (ParseFileName(file_name, &file_number, &file_type) &&
1751
+ file_type == kTableFile) {
1752
+ // TODO: Check for errors from OnAddFile?
1753
+ if (known_file_sizes.count(file_name)) {
1754
+ // We're assuming that each sst file name exists in at most one of
1755
+ // the paths.
1756
+ sfm->OnAddFile(file_path, known_file_sizes.at(file_name),
1757
+ /* compaction */ false)
1758
+ .PermitUncheckedError();
1759
+ } else {
1760
+ sfm->OnAddFile(file_path).PermitUncheckedError();
1761
+ }
1762
+ }
1763
+ }
1764
+ }
1765
+
1766
+ // Reserve some disk buffer space. This is a heuristic - when we run out
1767
+ // of disk space, this ensures that there is atleast write_buffer_size
1768
+ // amount of free space before we resume DB writes. In low disk space
1769
+ // conditions, we want to avoid a lot of small L0 files due to frequent
1770
+ // WAL write failures and resultant forced flushes
1771
+ sfm->ReserveDiskBuffer(max_write_buffer_size,
1772
+ impl->immutable_db_options_.db_paths[0].path);
1773
+ }
1774
+
1775
+ #endif // !ROCKSDB_LITE
1776
+
1777
+ if (s.ok()) {
1778
+ ROCKS_LOG_HEADER(impl->immutable_db_options_.info_log, "DB pointer %p",
1779
+ impl);
1780
+ LogFlush(impl->immutable_db_options_.info_log);
1781
+ assert(impl->TEST_WALBufferIsEmpty());
1782
+ // If the assert above fails then we need to FlushWAL before returning
1783
+ // control back to the user.
1784
+ if (!persist_options_status.ok()) {
1785
+ s = Status::IOError(
1786
+ "DB::Open() failed --- Unable to persist Options file",
1787
+ persist_options_status.ToString());
1788
+ }
1789
+ } else {
1790
+ ROCKS_LOG_WARN(impl->immutable_db_options_.info_log,
1791
+ "Persisting Option File error: %s",
1792
+ persist_options_status.ToString().c_str());
1793
+ }
1794
+ if (s.ok()) {
1795
+ impl->StartPeriodicWorkScheduler();
1796
+ } else {
1797
+ for (auto* h : *handles) {
1798
+ delete h;
1799
+ }
1800
+ handles->clear();
1801
+ delete impl;
1802
+ *dbptr = nullptr;
1803
+ }
1804
+ return s;
1805
+ }
1806
+ } // namespace ROCKSDB_NAMESPACE