rocksdb-native 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/binding.c +92 -10
  2. package/index.js +9 -0
  3. package/lib/batch.js +11 -1
  4. package/lib/iterator.js +3 -1
  5. package/lib/snapshot.js +21 -0
  6. package/package.json +1 -1
  7. package/prebuilds/darwin-arm64/rocksdb-native.bare +0 -0
  8. package/prebuilds/darwin-arm64/rocksdb-native.node +0 -0
  9. package/prebuilds/darwin-x64/rocksdb-native.bare +0 -0
  10. package/prebuilds/darwin-x64/rocksdb-native.node +0 -0
  11. package/prebuilds/linux-arm64/rocksdb-native.bare +0 -0
  12. package/prebuilds/linux-arm64/rocksdb-native.node +0 -0
  13. package/prebuilds/linux-x64/rocksdb-native.bare +0 -0
  14. package/prebuilds/linux-x64/rocksdb-native.node +0 -0
  15. package/prebuilds/win32-x64/rocksdb-native.bare +0 -0
  16. package/prebuilds/win32-x64/rocksdb-native.node +0 -0
  17. package/vendor/librocksdb/include/rocksdb.h +38 -4
  18. package/vendor/librocksdb/src/rocksdb.cc +114 -14
  19. package/vendor/librocksdb/vendor/rocksdb/CMakeLists.txt +21 -4
  20. package/vendor/librocksdb/vendor/rocksdb/cache/secondary_cache_adapter.cc +6 -3
  21. package/vendor/librocksdb/vendor/rocksdb/db/arena_wrapped_db_iter.cc +4 -4
  22. package/vendor/librocksdb/vendor/rocksdb/db/arena_wrapped_db_iter.h +4 -2
  23. package/vendor/librocksdb/vendor/rocksdb/db/attribute_group_iterator_impl.cc +20 -0
  24. package/vendor/librocksdb/vendor/rocksdb/db/attribute_group_iterator_impl.h +83 -0
  25. package/vendor/librocksdb/vendor/rocksdb/db/builder.cc +9 -5
  26. package/vendor/librocksdb/vendor/rocksdb/db/builder.h +1 -1
  27. package/vendor/librocksdb/vendor/rocksdb/db/c.cc +231 -6
  28. package/vendor/librocksdb/vendor/rocksdb/db/c_test.c +202 -2
  29. package/vendor/librocksdb/vendor/rocksdb/db/coalescing_iterator.cc +47 -0
  30. package/vendor/librocksdb/vendor/rocksdb/db/coalescing_iterator.h +79 -0
  31. package/vendor/librocksdb/vendor/rocksdb/db/column_family.cc +28 -0
  32. package/vendor/librocksdb/vendor/rocksdb/db/column_family.h +17 -0
  33. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction.cc +8 -1
  34. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction.h +11 -9
  35. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_iterator.cc +50 -23
  36. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_iterator.h +13 -0
  37. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_job.cc +22 -25
  38. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_job.h +2 -0
  39. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_outputs.cc +8 -1
  40. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_outputs.h +1 -0
  41. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker.cc +40 -17
  42. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker.h +20 -14
  43. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker_level.cc +11 -6
  44. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker_universal.cc +77 -24
  45. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_service_job.cc +2 -0
  46. package/vendor/librocksdb/vendor/rocksdb/db/convenience.cc +3 -0
  47. package/vendor/librocksdb/vendor/rocksdb/db/db_filesnapshot.cc +125 -31
  48. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl.cc +457 -231
  49. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl.h +172 -73
  50. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_compaction_flush.cc +152 -133
  51. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_debug.cc +5 -0
  52. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_files.cc +58 -52
  53. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_follower.cc +348 -0
  54. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_follower.h +54 -0
  55. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_open.cc +136 -117
  56. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_secondary.cc +4 -3
  57. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_secondary.h +7 -6
  58. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_write.cc +134 -80
  59. package/vendor/librocksdb/vendor/rocksdb/db/db_iter.cc +11 -0
  60. package/vendor/librocksdb/vendor/rocksdb/db/db_test2.cc +1 -1
  61. package/vendor/librocksdb/vendor/rocksdb/db/db_test_util.cc +11 -1
  62. package/vendor/librocksdb/vendor/rocksdb/db/db_test_util.h +11 -7
  63. package/vendor/librocksdb/vendor/rocksdb/db/dbformat.cc +19 -4
  64. package/vendor/librocksdb/vendor/rocksdb/db/dbformat.h +3 -2
  65. package/vendor/librocksdb/vendor/rocksdb/db/error_handler.cc +34 -39
  66. package/vendor/librocksdb/vendor/rocksdb/db/error_handler.h +3 -4
  67. package/vendor/librocksdb/vendor/rocksdb/db/event_helpers.cc +6 -3
  68. package/vendor/librocksdb/vendor/rocksdb/db/experimental.cc +3 -2
  69. package/vendor/librocksdb/vendor/rocksdb/db/external_sst_file_ingestion_job.cc +76 -18
  70. package/vendor/librocksdb/vendor/rocksdb/db/external_sst_file_ingestion_job.h +11 -0
  71. package/vendor/librocksdb/vendor/rocksdb/db/flush_job.cc +37 -5
  72. package/vendor/librocksdb/vendor/rocksdb/db/flush_job.h +14 -0
  73. package/vendor/librocksdb/vendor/rocksdb/db/import_column_family_job.cc +49 -45
  74. package/vendor/librocksdb/vendor/rocksdb/db/internal_stats.cc +60 -1
  75. package/vendor/librocksdb/vendor/rocksdb/db/internal_stats.h +20 -1
  76. package/vendor/librocksdb/vendor/rocksdb/db/log_reader.cc +15 -6
  77. package/vendor/librocksdb/vendor/rocksdb/db/log_writer.cc +59 -10
  78. package/vendor/librocksdb/vendor/rocksdb/db/log_writer.h +8 -0
  79. package/vendor/librocksdb/vendor/rocksdb/db/memtable.cc +24 -40
  80. package/vendor/librocksdb/vendor/rocksdb/db/memtable.h +10 -10
  81. package/vendor/librocksdb/vendor/rocksdb/db/memtable_list.cc +9 -8
  82. package/vendor/librocksdb/vendor/rocksdb/db/multi_cf_iterator_impl.h +296 -0
  83. package/vendor/librocksdb/vendor/rocksdb/db/range_tombstone_fragmenter.h +8 -10
  84. package/vendor/librocksdb/vendor/rocksdb/db/repair.cc +4 -3
  85. package/vendor/librocksdb/vendor/rocksdb/db/seqno_to_time_mapping.cc +30 -0
  86. package/vendor/librocksdb/vendor/rocksdb/db/seqno_to_time_mapping.h +9 -0
  87. package/vendor/librocksdb/vendor/rocksdb/db/table_cache.cc +17 -2
  88. package/vendor/librocksdb/vendor/rocksdb/db/table_cache.h +9 -1
  89. package/vendor/librocksdb/vendor/rocksdb/db/table_properties_collector.h +9 -2
  90. package/vendor/librocksdb/vendor/rocksdb/db/transaction_log_impl.cc +3 -3
  91. package/vendor/librocksdb/vendor/rocksdb/db/transaction_log_impl.h +7 -7
  92. package/vendor/librocksdb/vendor/rocksdb/db/version_edit.cc +0 -1
  93. package/vendor/librocksdb/vendor/rocksdb/db/version_edit_handler.cc +39 -5
  94. package/vendor/librocksdb/vendor/rocksdb/db/version_edit_handler.h +24 -15
  95. package/vendor/librocksdb/vendor/rocksdb/db/version_set.cc +117 -64
  96. package/vendor/librocksdb/vendor/rocksdb/db/version_set.h +27 -10
  97. package/vendor/librocksdb/vendor/rocksdb/db/wal_manager.cc +37 -29
  98. package/vendor/librocksdb/vendor/rocksdb/db/wal_manager.h +6 -5
  99. package/vendor/librocksdb/vendor/rocksdb/db/wide/wide_columns.cc +2 -3
  100. package/vendor/librocksdb/vendor/rocksdb/db/wide/wide_columns_helper.cc +6 -0
  101. package/vendor/librocksdb/vendor/rocksdb/db/write_batch.cc +89 -31
  102. package/vendor/librocksdb/vendor/rocksdb/db/write_thread.cc +53 -5
  103. package/vendor/librocksdb/vendor/rocksdb/db/write_thread.h +36 -4
  104. package/vendor/librocksdb/vendor/rocksdb/env/composite_env_wrapper.h +21 -0
  105. package/vendor/librocksdb/vendor/rocksdb/env/env.cc +15 -0
  106. package/vendor/librocksdb/vendor/rocksdb/env/fs_on_demand.cc +331 -0
  107. package/vendor/librocksdb/vendor/rocksdb/env/fs_on_demand.h +139 -0
  108. package/vendor/librocksdb/vendor/rocksdb/env/io_posix.cc +8 -6
  109. package/vendor/librocksdb/vendor/rocksdb/env/io_posix.h +1 -1
  110. package/vendor/librocksdb/vendor/rocksdb/file/delete_scheduler.cc +130 -27
  111. package/vendor/librocksdb/vendor/rocksdb/file/delete_scheduler.h +61 -8
  112. package/vendor/librocksdb/vendor/rocksdb/file/file_util.cc +25 -4
  113. package/vendor/librocksdb/vendor/rocksdb/file/file_util.h +15 -0
  114. package/vendor/librocksdb/vendor/rocksdb/file/sequence_file_reader.cc +1 -0
  115. package/vendor/librocksdb/vendor/rocksdb/file/sequence_file_reader.h +9 -4
  116. package/vendor/librocksdb/vendor/rocksdb/file/sst_file_manager_impl.cc +18 -0
  117. package/vendor/librocksdb/vendor/rocksdb/file/sst_file_manager_impl.h +31 -4
  118. package/vendor/librocksdb/vendor/rocksdb/file/writable_file_writer.cc +40 -38
  119. package/vendor/librocksdb/vendor/rocksdb/file/writable_file_writer.h +48 -15
  120. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/advanced_options.h +12 -3
  121. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/attribute_groups.h +114 -0
  122. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/c.h +90 -0
  123. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/cache.h +5 -0
  124. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/comparator.h +27 -0
  125. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/db.h +71 -12
  126. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/env.h +9 -0
  127. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/experimental.h +5 -0
  128. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/file_system.h +14 -0
  129. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/iterator.h +9 -71
  130. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/iterator_base.h +90 -0
  131. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/listener.h +21 -0
  132. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/options.h +125 -12
  133. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/perf_context.h +1 -1
  134. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/sst_file_reader.h +11 -1
  135. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/table.h +6 -6
  136. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/table_properties.h +19 -0
  137. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/transaction_log.h +12 -6
  138. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/types.h +12 -0
  139. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/universal_compaction.h +31 -0
  140. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/user_write_callback.h +29 -0
  141. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/cache_dump_load.h +4 -0
  142. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/checkpoint.h +4 -2
  143. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/customizable_util.h +0 -1
  144. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/env_mirror.h +1 -1
  145. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/ldb_cmd.h +24 -7
  146. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/option_change_migration.h +4 -4
  147. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/stackable_db.h +24 -5
  148. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/table_properties_collectors.h +46 -0
  149. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/transaction.h +42 -17
  150. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/transaction_db.h +5 -0
  151. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/types_util.h +36 -0
  152. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/write_batch_with_index.h +71 -3
  153. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/version.h +2 -2
  154. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/wide_columns.h +87 -72
  155. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/write_batch_base.h +1 -1
  156. package/vendor/librocksdb/vendor/rocksdb/memory/memory_allocator.cc +1 -0
  157. package/vendor/librocksdb/vendor/rocksdb/options/cf_options.cc +13 -2
  158. package/vendor/librocksdb/vendor/rocksdb/options/cf_options.h +6 -2
  159. package/vendor/librocksdb/vendor/rocksdb/options/db_options.cc +27 -1
  160. package/vendor/librocksdb/vendor/rocksdb/options/db_options.h +10 -3
  161. package/vendor/librocksdb/vendor/rocksdb/options/options.cc +3 -0
  162. package/vendor/librocksdb/vendor/rocksdb/options/options_helper.cc +1 -0
  163. package/vendor/librocksdb/vendor/rocksdb/port/jemalloc_helper.h +2 -2
  164. package/vendor/librocksdb/vendor/rocksdb/port/stack_trace.cc +1 -0
  165. package/vendor/librocksdb/vendor/rocksdb/port/win/port_win.cc +3 -2
  166. package/vendor/librocksdb/vendor/rocksdb/table/block_based/binary_search_index_reader.cc +1 -2
  167. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_builder.cc +47 -31
  168. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_factory.cc +15 -0
  169. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_iterator.cc +37 -18
  170. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_iterator.h +10 -3
  171. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader.cc +102 -41
  172. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader.h +15 -7
  173. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader_impl.h +1 -3
  174. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +5 -6
  175. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_cache.h +31 -0
  176. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_prefetcher.cc +6 -0
  177. package/vendor/librocksdb/vendor/rocksdb/table/block_based/cachable_entry.h +10 -5
  178. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_block.h +34 -28
  179. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_block_reader_common.cc +17 -11
  180. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_block_reader_common.h +5 -2
  181. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_policy.cc +12 -3
  182. package/vendor/librocksdb/vendor/rocksdb/table/block_based/full_filter_block.cc +37 -30
  183. package/vendor/librocksdb/vendor/rocksdb/table/block_based/full_filter_block.h +11 -13
  184. package/vendor/librocksdb/vendor/rocksdb/table/block_based/hash_index_reader.cc +1 -2
  185. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_builder.cc +62 -53
  186. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_builder.h +60 -38
  187. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_reader_common.cc +14 -9
  188. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_reader_common.h +4 -1
  189. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_filter_block.cc +135 -94
  190. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_filter_block.h +52 -46
  191. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_index_reader.cc +51 -13
  192. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_index_reader.h +2 -0
  193. package/vendor/librocksdb/vendor/rocksdb/table/block_based/uncompression_dict_reader.cc +3 -11
  194. package/vendor/librocksdb/vendor/rocksdb/table/block_based/uncompression_dict_reader.h +2 -3
  195. package/vendor/librocksdb/vendor/rocksdb/table/block_fetcher.cc +8 -10
  196. package/vendor/librocksdb/vendor/rocksdb/table/block_fetcher.h +2 -1
  197. package/vendor/librocksdb/vendor/rocksdb/table/compaction_merging_iterator.cc +9 -10
  198. package/vendor/librocksdb/vendor/rocksdb/table/compaction_merging_iterator.h +3 -2
  199. package/vendor/librocksdb/vendor/rocksdb/table/format.cc +1 -2
  200. package/vendor/librocksdb/vendor/rocksdb/table/iterator.cc +4 -0
  201. package/vendor/librocksdb/vendor/rocksdb/table/merging_iterator.cc +18 -13
  202. package/vendor/librocksdb/vendor/rocksdb/table/merging_iterator.h +5 -3
  203. package/vendor/librocksdb/vendor/rocksdb/table/meta_blocks.cc +18 -4
  204. package/vendor/librocksdb/vendor/rocksdb/table/meta_blocks.h +4 -0
  205. package/vendor/librocksdb/vendor/rocksdb/table/plain/plain_table_builder.cc +2 -2
  206. package/vendor/librocksdb/vendor/rocksdb/table/sst_file_dumper.cc +6 -6
  207. package/vendor/librocksdb/vendor/rocksdb/table/sst_file_reader.cc +24 -2
  208. package/vendor/librocksdb/vendor/rocksdb/table/sst_file_writer_collectors.h +3 -1
  209. package/vendor/librocksdb/vendor/rocksdb/table/table_builder.h +8 -7
  210. package/vendor/librocksdb/vendor/rocksdb/table/table_iterator.h +69 -0
  211. package/vendor/librocksdb/vendor/rocksdb/table/table_reader.h +9 -0
  212. package/vendor/librocksdb/vendor/rocksdb/test_util/testutil.cc +25 -0
  213. package/vendor/librocksdb/vendor/rocksdb/test_util/testutil.h +12 -0
  214. package/vendor/librocksdb/vendor/rocksdb/tools/db_bench_tool.cc +32 -0
  215. package/vendor/librocksdb/vendor/rocksdb/tools/ldb_cmd.cc +618 -124
  216. package/vendor/librocksdb/vendor/rocksdb/tools/ldb_cmd_impl.h +19 -1
  217. package/vendor/librocksdb/vendor/rocksdb/tools/ldb_tool.cc +9 -0
  218. package/vendor/librocksdb/vendor/rocksdb/util/aligned_storage.h +24 -0
  219. package/vendor/librocksdb/vendor/rocksdb/util/autovector.h +4 -0
  220. package/vendor/librocksdb/vendor/rocksdb/util/comparator.cc +12 -0
  221. package/vendor/librocksdb/vendor/rocksdb/util/filter_bench.cc +1 -1
  222. package/vendor/librocksdb/vendor/rocksdb/util/random.cc +2 -1
  223. package/vendor/librocksdb/vendor/rocksdb/util/stderr_logger.cc +3 -4
  224. package/vendor/librocksdb/vendor/rocksdb/util/stderr_logger.h +1 -1
  225. package/vendor/librocksdb/vendor/rocksdb/util/udt_util.cc +33 -0
  226. package/vendor/librocksdb/vendor/rocksdb/util/udt_util.h +7 -0
  227. package/vendor/librocksdb/vendor/rocksdb/util/write_batch_util.h +5 -0
  228. package/vendor/librocksdb/vendor/rocksdb/util/xxhash.h +36 -29
  229. package/vendor/librocksdb/vendor/rocksdb/utilities/blob_db/blob_db_impl.h +3 -0
  230. package/vendor/librocksdb/vendor/rocksdb/utilities/blob_db/blob_db_impl_filesnapshot.cc +20 -0
  231. package/vendor/librocksdb/vendor/rocksdb/utilities/cache_dump_load_impl.cc +29 -9
  232. package/vendor/librocksdb/vendor/rocksdb/utilities/cache_dump_load_impl.h +14 -3
  233. package/vendor/librocksdb/vendor/rocksdb/utilities/debug.cc +16 -4
  234. package/vendor/librocksdb/vendor/rocksdb/utilities/fault_injection_fs.cc +677 -248
  235. package/vendor/librocksdb/vendor/rocksdb/utilities/fault_injection_fs.h +325 -158
  236. package/vendor/librocksdb/vendor/rocksdb/utilities/option_change_migration/option_change_migration.cc +1 -8
  237. package/vendor/librocksdb/vendor/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.cc +144 -0
  238. package/vendor/librocksdb/vendor/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.h +45 -0
  239. package/vendor/librocksdb/vendor/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.cc +12 -0
  240. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h +1 -1
  241. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/growable_array.h +3 -3
  242. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction.cc +116 -20
  243. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction.h +33 -1
  244. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction_db.cc +78 -13
  245. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction_db.h +33 -1
  246. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_base.cc +106 -7
  247. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_base.h +68 -10
  248. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_test.h +7 -3
  249. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_util.cc +8 -5
  250. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_util.h +7 -4
  251. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_prepared_txn.cc +18 -12
  252. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_prepared_txn_db.cc +4 -4
  253. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_prepared_txn_db.h +17 -0
  254. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_unprepared_txn.cc +11 -9
  255. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_unprepared_txn_db.cc +2 -1
  256. package/vendor/librocksdb/vendor/rocksdb/utilities/types_util.cc +88 -0
  257. package/vendor/librocksdb/vendor/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc +313 -14
  258. package/vendor/librocksdb/vendor/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc +7 -0
  259. package/vendor/librocksdb/vendor/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h +1 -1
  260. package/vendor/librocksdb/vendor/rocksdb/db/multi_cf_iterator.cc +0 -102
  261. package/vendor/librocksdb/vendor/rocksdb/db/multi_cf_iterator.h +0 -159
@@ -160,14 +160,7 @@ Status OptionChangeMigration(std::string dbname, const Options& old_opts,
160
160
  return MigrateToLevelBase(dbname, old_opts, new_opts);
161
161
  } else if (new_opts.compaction_style ==
162
162
  CompactionStyle::kCompactionStyleFIFO) {
163
- uint64_t l0_file_size = 0;
164
- if (new_opts.compaction_options_fifo.max_table_files_size > 0) {
165
- // Create at least 8 files when max_table_files_size hits, so that the DB
166
- // doesn't just disappear. This in fact violates the FIFO condition, but
167
- // otherwise, the migrated DB is unlikley to be usable.
168
- l0_file_size = new_opts.compaction_options_fifo.max_table_files_size / 8;
169
- }
170
- return CompactToLevel(old_opts, dbname, 0, l0_file_size, true);
163
+ return CompactToLevel(old_opts, dbname, 0, 0 /* l0_file_size */, true);
171
164
  } else {
172
165
  return Status::NotSupported(
173
166
  "Do not how to migrate to this compaction style");
@@ -0,0 +1,144 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ //
3
+ // This source code is licensed under both the GPLv2 (found in the
4
+ // COPYING file in the root directory) and Apache 2.0 License
5
+ // (found in the LICENSE.Apache file in the root directory).
6
+
7
+ #include "utilities/table_properties_collectors/compact_for_tiering_collector.h"
8
+
9
+ #include <sstream>
10
+
11
+ #include "db/seqno_to_time_mapping.h"
12
+ #include "rocksdb/status.h"
13
+ #include "rocksdb/types.h"
14
+ #include "rocksdb/utilities/customizable_util.h"
15
+ #include "rocksdb/utilities/object_registry.h"
16
+ #include "rocksdb/utilities/options_type.h"
17
+ #include "rocksdb/utilities/table_properties_collectors.h"
18
+ #include "util/string_util.h"
19
+
20
+ namespace ROCKSDB_NAMESPACE {
21
+ const std::string
22
+ CompactForTieringCollector::kNumEligibleLastLevelEntriesPropertyName =
23
+ "rocksdb.eligible.last.level.entries";
24
+
25
+ CompactForTieringCollector::CompactForTieringCollector(
26
+ SequenceNumber last_level_inclusive_max_seqno_threshold,
27
+ double compaction_trigger_ratio)
28
+ : last_level_inclusive_max_seqno_threshold_(
29
+ last_level_inclusive_max_seqno_threshold),
30
+ compaction_trigger_ratio_(compaction_trigger_ratio) {
31
+ assert(last_level_inclusive_max_seqno_threshold_ != kMaxSequenceNumber);
32
+ }
33
+
34
+ Status CompactForTieringCollector::AddUserKey(const Slice& /*key*/,
35
+ const Slice& value,
36
+ EntryType type,
37
+ SequenceNumber seq,
38
+ uint64_t /*file_size*/) {
39
+ SequenceNumber seq_for_check = seq;
40
+ if (type == kEntryTimedPut) {
41
+ seq_for_check = ParsePackedValueForSeqno(value);
42
+ }
43
+ if (seq_for_check < last_level_inclusive_max_seqno_threshold_) {
44
+ last_level_eligible_entries_counter_++;
45
+ }
46
+ total_entries_counter_ += 1;
47
+ return Status::OK();
48
+ }
49
+
50
+ Status CompactForTieringCollector::Finish(UserCollectedProperties* properties) {
51
+ assert(!finish_called_);
52
+ assert(compaction_trigger_ratio_ > 0);
53
+ if (last_level_eligible_entries_counter_ >=
54
+ compaction_trigger_ratio_ * total_entries_counter_) {
55
+ assert(compaction_trigger_ratio_ <= 1);
56
+ need_compaction_ = true;
57
+ }
58
+ if (last_level_eligible_entries_counter_ > 0) {
59
+ *properties = UserCollectedProperties{
60
+ {kNumEligibleLastLevelEntriesPropertyName,
61
+ std::to_string(last_level_eligible_entries_counter_)},
62
+ };
63
+ }
64
+ finish_called_ = true;
65
+ return Status::OK();
66
+ }
67
+
68
+ UserCollectedProperties CompactForTieringCollector::GetReadableProperties()
69
+ const {
70
+ return UserCollectedProperties{
71
+ {kNumEligibleLastLevelEntriesPropertyName,
72
+ std::to_string(last_level_eligible_entries_counter_)},
73
+ };
74
+ }
75
+
76
+ bool CompactForTieringCollector::NeedCompact() const {
77
+ return need_compaction_;
78
+ }
79
+
80
+ void CompactForTieringCollector::Reset() {
81
+ last_level_eligible_entries_counter_ = 0;
82
+ total_entries_counter_ = 0;
83
+ finish_called_ = false;
84
+ need_compaction_ = false;
85
+ }
86
+
87
+ TablePropertiesCollector*
88
+ CompactForTieringCollectorFactory::CreateTablePropertiesCollector(
89
+ TablePropertiesCollectorFactory::Context context) {
90
+ double compaction_trigger_ratio = GetCompactionTriggerRatio();
91
+ if (compaction_trigger_ratio <= 0 ||
92
+ context.level_at_creation == context.num_levels - 1 ||
93
+ context.last_level_inclusive_max_seqno_threshold == kMaxSequenceNumber) {
94
+ return nullptr;
95
+ }
96
+ return new CompactForTieringCollector(
97
+ context.last_level_inclusive_max_seqno_threshold,
98
+ compaction_trigger_ratio);
99
+ }
100
+
101
+ static std::unordered_map<std::string, OptionTypeInfo>
102
+ on_compact_for_tiering_type_info = {
103
+ {"compaction_trigger_ratio",
104
+ {0, OptionType::kUnknown, OptionVerificationType::kNormal,
105
+ OptionTypeFlags::kCompareNever | OptionTypeFlags::kMutable,
106
+ [](const ConfigOptions&, const std::string&, const std::string& value,
107
+ void* addr) {
108
+ auto* factory =
109
+ static_cast<CompactForTieringCollectorFactory*>(addr);
110
+ factory->SetCompactionTriggerRatio(ParseDouble(value));
111
+ return Status::OK();
112
+ },
113
+ [](const ConfigOptions&, const std::string&, const void* addr,
114
+ std::string* value) {
115
+ const auto* factory =
116
+ static_cast<const CompactForTieringCollectorFactory*>(addr);
117
+ *value = std::to_string(factory->GetCompactionTriggerRatio());
118
+ return Status::OK();
119
+ },
120
+ nullptr}},
121
+
122
+ };
123
+
124
+ CompactForTieringCollectorFactory::CompactForTieringCollectorFactory(
125
+ double compaction_trigger_ratio)
126
+ : compaction_trigger_ratio_(compaction_trigger_ratio) {
127
+ RegisterOptions("", this, &on_compact_for_tiering_type_info);
128
+ }
129
+
130
+ std::string CompactForTieringCollectorFactory::ToString() const {
131
+ std::ostringstream cfg;
132
+ cfg << Name()
133
+ << ", compaction trigger ratio:" << compaction_trigger_ratio_.load()
134
+ << std::endl;
135
+ return cfg.str();
136
+ }
137
+
138
+ std::shared_ptr<CompactForTieringCollectorFactory>
139
+ NewCompactForTieringCollectorFactory(double compaction_trigger_ratio) {
140
+ return std::make_shared<CompactForTieringCollectorFactory>(
141
+ compaction_trigger_ratio);
142
+ }
143
+
144
+ } // namespace ROCKSDB_NAMESPACE
@@ -0,0 +1,45 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ //
3
+ // This source code is licensed under both the GPLv2 (found in the
4
+ // COPYING file in the root directory) and Apache 2.0 License
5
+ // (found in the LICENSE.Apache file in the root directory).
6
+
7
+ #pragma once
8
+
9
+ #include "rocksdb/utilities/table_properties_collectors.h"
10
+
11
+ namespace ROCKSDB_NAMESPACE {
12
+
13
+ // A user property collector that marks a SST file as need-compaction when for
14
+ // the tiering use case. See documentation for
15
+ // `CompactForTieringCollectorFactory`.
16
+ class CompactForTieringCollector : public TablePropertiesCollector {
17
+ public:
18
+ static const std::string kNumEligibleLastLevelEntriesPropertyName;
19
+
20
+ CompactForTieringCollector(
21
+ SequenceNumber last_level_inclusive_max_seqno_threshold_,
22
+ double compaction_trigger_ratio);
23
+
24
+ Status AddUserKey(const Slice& key, const Slice& value, EntryType type,
25
+ SequenceNumber seq, uint64_t file_size) override;
26
+
27
+ Status Finish(UserCollectedProperties* properties) override;
28
+
29
+ UserCollectedProperties GetReadableProperties() const override;
30
+
31
+ const char* Name() const override { return "CompactForTieringCollector"; }
32
+
33
+ bool NeedCompact() const override;
34
+
35
+ private:
36
+ void Reset();
37
+
38
+ SequenceNumber last_level_inclusive_max_seqno_threshold_;
39
+ double compaction_trigger_ratio_;
40
+ size_t last_level_eligible_entries_counter_ = 0;
41
+ size_t total_entries_counter_ = 0;
42
+ bool finish_called_ = false;
43
+ bool need_compaction_ = false;
44
+ };
45
+ } // namespace ROCKSDB_NAMESPACE
@@ -188,6 +188,7 @@ NewCompactOnDeletionCollectorFactory(size_t sliding_window_size,
188
188
  new CompactOnDeletionCollectorFactory(sliding_window_size,
189
189
  deletion_trigger, deletion_ratio));
190
190
  }
191
+
191
192
  namespace {
192
193
  static int RegisterTablePropertiesCollectorFactories(
193
194
  ObjectLibrary& library, const std::string& /*arg*/) {
@@ -202,6 +203,17 @@ static int RegisterTablePropertiesCollectorFactories(
202
203
  guard->reset(new CompactOnDeletionCollectorFactory(0, 0, 0));
203
204
  return guard->get();
204
205
  });
206
+ library.AddFactory<TablePropertiesCollectorFactory>(
207
+ CompactForTieringCollectorFactory::kClassName(),
208
+ [](const std::string& /*uri*/,
209
+ std::unique_ptr<TablePropertiesCollectorFactory>* guard,
210
+ std::string* /* errmsg */) {
211
+ // By default, create a `CompactForTieringCollectorFactory` that is
212
+ // disabled. Users will need to call corresponding setters to enable
213
+ // the factory.
214
+ guard->reset(new CompactForTieringCollectorFactory(0));
215
+ return guard->get();
216
+ });
205
217
  return 1;
206
218
  }
207
219
  } // namespace
@@ -165,7 +165,7 @@ static inline tokutime_t toku_time_now(void) {
165
165
 
166
166
  static inline uint64_t toku_current_time_microsec(void) {
167
167
  struct timeval t;
168
- gettimeofday(&t, NULL);
168
+ gettimeofday(&t, nullptr);
169
169
  return t.tv_sec * (1UL * 1000 * 1000) + t.tv_usec;
170
170
  }
171
171
 
@@ -78,7 +78,7 @@ class GrowableArray {
78
78
  void init(void)
79
79
  // Effect: Initialize the array to contain no elements.
80
80
  {
81
- m_array = NULL;
81
+ m_array = nullptr;
82
82
  m_size = 0;
83
83
  m_size_limit = 0;
84
84
  }
@@ -87,7 +87,7 @@ class GrowableArray {
87
87
  // Effect: Deinitialize the array (freeing any memory it uses, for example).
88
88
  {
89
89
  toku_free(m_array);
90
- m_array = NULL;
90
+ m_array = nullptr;
91
91
  m_size = 0;
92
92
  m_size_limit = 0;
93
93
  }
@@ -113,7 +113,7 @@ class GrowableArray {
113
113
  // constant.
114
114
  {
115
115
  if (m_size >= m_size_limit) {
116
- if (m_array == NULL) {
116
+ if (m_array == nullptr) {
117
117
  m_size_limit = 1;
118
118
  } else {
119
119
  m_size_limit *= 2;
@@ -3,7 +3,6 @@
3
3
  // COPYING file in the root directory) and Apache 2.0 License
4
4
  // (found in the LICENSE.Apache file in the root directory).
5
5
 
6
-
7
6
  #include "utilities/transactions/pessimistic_transaction.h"
8
7
 
9
8
  #include <map>
@@ -190,12 +189,9 @@ inline Status WriteCommittedTxn::GetForUpdateImpl(
190
189
  }
191
190
  }
192
191
 
193
- if (!do_validate && kMaxTxnTimestamp != read_timestamp_) {
194
- return Status::InvalidArgument(
195
- "If do_validate is false then GetForUpdate with read_timestamp is not "
196
- "defined.");
197
- } else if (do_validate && kMaxTxnTimestamp == read_timestamp_) {
198
- return Status::InvalidArgument("read_timestamp must be set for validation");
192
+ Status s = SanityCheckReadTimestamp(do_validate);
193
+ if (!s.ok()) {
194
+ return s;
199
195
  }
200
196
 
201
197
  if (!read_options.timestamp) {
@@ -218,6 +214,94 @@ inline Status WriteCommittedTxn::GetForUpdateImpl(
218
214
  value, exclusive, do_validate);
219
215
  }
220
216
 
217
+ Status WriteCommittedTxn::GetEntityForUpdate(const ReadOptions& read_options,
218
+ ColumnFamilyHandle* column_family,
219
+ const Slice& key,
220
+ PinnableWideColumns* columns,
221
+ bool exclusive, bool do_validate) {
222
+ if (!column_family) {
223
+ return Status::InvalidArgument(
224
+ "Cannot call GetEntityForUpdate without a column family handle");
225
+ }
226
+
227
+ const Comparator* const ucmp = column_family->GetComparator();
228
+ assert(ucmp);
229
+ const size_t ts_sz = ucmp->timestamp_size();
230
+
231
+ if (ts_sz == 0) {
232
+ return TransactionBaseImpl::GetEntityForUpdate(
233
+ read_options, column_family, key, columns, exclusive, do_validate);
234
+ }
235
+
236
+ assert(ts_sz > 0);
237
+ Status s = SanityCheckReadTimestamp(do_validate);
238
+ if (!s.ok()) {
239
+ return s;
240
+ }
241
+
242
+ std::string ts_buf;
243
+ PutFixed64(&ts_buf, read_timestamp_);
244
+ Slice ts(ts_buf);
245
+
246
+ if (!read_options.timestamp) {
247
+ ReadOptions read_options_copy = read_options;
248
+ read_options_copy.timestamp = &ts;
249
+
250
+ return TransactionBaseImpl::GetEntityForUpdate(
251
+ read_options_copy, column_family, key, columns, exclusive, do_validate);
252
+ }
253
+
254
+ assert(read_options.timestamp);
255
+ if (*read_options.timestamp != ts) {
256
+ return Status::InvalidArgument("Must read from the same read timestamp");
257
+ }
258
+
259
+ return TransactionBaseImpl::GetEntityForUpdate(
260
+ read_options, column_family, key, columns, exclusive, do_validate);
261
+ }
262
+
263
+ Status WriteCommittedTxn::SanityCheckReadTimestamp(bool do_validate) {
264
+ bool enable_udt_validation =
265
+ txn_db_impl_->GetTxnDBOptions().enable_udt_validation;
266
+ if (!enable_udt_validation) {
267
+ if (kMaxTxnTimestamp != read_timestamp_) {
268
+ return Status::InvalidArgument(
269
+ "read_timestamp is set but timestamp validation is disabled for the "
270
+ "DB");
271
+ }
272
+ } else {
273
+ if (!do_validate) {
274
+ if (kMaxTxnTimestamp != read_timestamp_) {
275
+ return Status::InvalidArgument(
276
+ "If do_validate is false then GetForUpdate with read_timestamp is "
277
+ "not "
278
+ "defined.");
279
+ }
280
+ } else {
281
+ if (kMaxTxnTimestamp == read_timestamp_) {
282
+ return Status::InvalidArgument(
283
+ "read_timestamp must be set for validation");
284
+ }
285
+ }
286
+ }
287
+ return Status::OK();
288
+ }
289
+
290
+ Status WriteCommittedTxn::PutEntityImpl(ColumnFamilyHandle* column_family,
291
+ const Slice& key,
292
+ const WideColumns& columns,
293
+ bool do_validate, bool assume_tracked) {
294
+ return Operate(column_family, key, do_validate, assume_tracked,
295
+ [column_family, &key, &columns, this]() {
296
+ Status s = GetBatchForWrite()->PutEntity(column_family, key,
297
+ columns);
298
+ if (s.ok()) {
299
+ ++num_put_entities_;
300
+ }
301
+ return s;
302
+ });
303
+ }
304
+
221
305
  Status WriteCommittedTxn::Put(ColumnFamilyHandle* column_family,
222
306
  const Slice& key, const Slice& value,
223
307
  const bool assume_tracked) {
@@ -428,7 +512,8 @@ Status WriteCommittedTxn::SetReadTimestampForValidation(TxnTimestamp ts) {
428
512
  }
429
513
 
430
514
  Status WriteCommittedTxn::SetCommitTimestamp(TxnTimestamp ts) {
431
- if (read_timestamp_ < kMaxTxnTimestamp && ts <= read_timestamp_) {
515
+ if (txn_db_impl_->GetTxnDBOptions().enable_udt_validation &&
516
+ read_timestamp_ < kMaxTxnTimestamp && ts <= read_timestamp_) {
432
517
  return Status::InvalidArgument(
433
518
  "Cannot commit at timestamp smaller than or equal to read timestamp");
434
519
  }
@@ -570,9 +655,9 @@ Status WriteCommittedTxn::PrepareInternal() {
570
655
  SequenceNumber* const KIgnoreSeqUsed = nullptr;
571
656
  const size_t kNoBatchCount = 0;
572
657
  s = db_impl_->WriteImpl(write_options, GetWriteBatch()->GetWriteBatch(),
573
- kNoWriteCallback, &log_number_, kRefNoLog,
574
- kDisableMemtable, KIgnoreSeqUsed, kNoBatchCount,
575
- &mark_log_callback);
658
+ kNoWriteCallback, /*user_write_cb=*/nullptr,
659
+ &log_number_, kRefNoLog, kDisableMemtable,
660
+ KIgnoreSeqUsed, kNoBatchCount, &mark_log_callback);
576
661
  return s;
577
662
  }
578
663
 
@@ -705,11 +790,11 @@ Status WriteCommittedTxn::CommitWithoutPrepareInternal() {
705
790
  post_mem_cb = &snapshot_creation_cb;
706
791
  }
707
792
  }
708
- auto s = db_impl_->WriteImpl(write_options_, wb,
709
- /*callback*/ nullptr, /*log_used*/ nullptr,
710
- /*log_ref*/ 0, /*disable_memtable*/ false,
711
- &seq_used, /*batch_cnt=*/0,
712
- /*pre_release_callback=*/nullptr, post_mem_cb);
793
+ auto s = db_impl_->WriteImpl(
794
+ write_options_, wb,
795
+ /*callback*/ nullptr, /*user_write_cb=*/nullptr, /*log_used*/ nullptr,
796
+ /*log_ref*/ 0, /*disable_memtable*/ false, &seq_used, /*batch_cnt=*/0,
797
+ /*pre_release_callback=*/nullptr, post_mem_cb);
713
798
  assert(!s.ok() || seq_used != kMaxSequenceNumber);
714
799
  if (s.ok()) {
715
800
  SetId(seq_used);
@@ -720,6 +805,7 @@ Status WriteCommittedTxn::CommitWithoutPrepareInternal() {
720
805
  Status WriteCommittedTxn::CommitBatchInternal(WriteBatch* batch, size_t) {
721
806
  uint64_t seq_used = kMaxSequenceNumber;
722
807
  auto s = db_impl_->WriteImpl(write_options_, batch, /*callback*/ nullptr,
808
+ /*user_write_cb=*/nullptr,
723
809
  /*log_used*/ nullptr, /*log_ref*/ 0,
724
810
  /*disable_memtable*/ false, &seq_used);
725
811
  assert(!s.ok() || seq_used != kMaxSequenceNumber);
@@ -793,6 +879,7 @@ Status WriteCommittedTxn::CommitInternal() {
793
879
  }
794
880
  }
795
881
  s = db_impl_->WriteImpl(write_options_, working_batch, /*callback*/ nullptr,
882
+ /*user_write_cb=*/nullptr,
796
883
  /*log_used*/ nullptr, /*log_ref*/ log_number_,
797
884
  /*disable_memtable*/ false, &seq_used,
798
885
  /*batch_cnt=*/0, /*pre_release_callback=*/nullptr,
@@ -896,6 +983,11 @@ Status PessimisticTransaction::LockBatch(WriteBatch* batch,
896
983
  RecordKey(column_family_id, key);
897
984
  return Status::OK();
898
985
  }
986
+ Status PutEntityCF(uint32_t column_family_id, const Slice& key,
987
+ const Slice& /* unused */) override {
988
+ RecordKey(column_family_id, key);
989
+ return Status::OK();
990
+ }
899
991
  Status MergeCF(uint32_t column_family_id, const Slice& key,
900
992
  const Slice& /* unused */) override {
901
993
  RecordKey(column_family_id, key);
@@ -1132,7 +1224,10 @@ Status PessimisticTransaction::ValidateSnapshot(
1132
1224
 
1133
1225
  return TransactionUtil::CheckKeyForConflicts(
1134
1226
  db_impl_, cfh, key.ToString(), snap_seq, ts_sz == 0 ? nullptr : &ts_buf,
1135
- false /* cache_only */);
1227
+ false /* cache_only */,
1228
+ /* snap_checker */ nullptr,
1229
+ /* min_uncommitted */ kMaxSequenceNumber,
1230
+ txn_db_impl_->GetTxnDBOptions().enable_udt_validation);
1136
1231
  }
1137
1232
 
1138
1233
  bool PessimisticTransaction::TryStealingLocks() {
@@ -1152,14 +1247,15 @@ Status PessimisticTransaction::SetName(const TransactionName& name) {
1152
1247
  if (txn_state_ == STARTED) {
1153
1248
  if (name_.length()) {
1154
1249
  s = Status::InvalidArgument("Transaction has already been named.");
1155
- } else if (txn_db_impl_->GetTransactionByName(name) != nullptr) {
1156
- s = Status::InvalidArgument("Transaction name must be unique.");
1157
1250
  } else if (name.length() < 1 || name.length() > 512) {
1158
1251
  s = Status::InvalidArgument(
1159
1252
  "Transaction name length must be between 1 and 512 chars.");
1160
1253
  } else {
1161
1254
  name_ = name;
1162
- txn_db_impl_->RegisterTransaction(this);
1255
+ s = txn_db_impl_->RegisterTransaction(this);
1256
+ if (!s.ok()) {
1257
+ name_.clear();
1258
+ }
1163
1259
  }
1164
1260
  } else {
1165
1261
  s = Status::InvalidArgument("Transaction is beyond state for naming.");
@@ -5,7 +5,6 @@
5
5
 
6
6
  #pragma once
7
7
 
8
-
9
8
  #include <algorithm>
10
9
  #include <atomic>
11
10
  #include <mutex>
@@ -235,6 +234,11 @@ class WriteCommittedTxn : public PessimisticTransaction {
235
234
  PinnableSlice* pinnable_val, bool exclusive,
236
235
  const bool do_validate) override;
237
236
 
237
+ Status GetEntityForUpdate(const ReadOptions& read_options,
238
+ ColumnFamilyHandle* column_family, const Slice& key,
239
+ PinnableWideColumns* columns, bool exclusive,
240
+ bool do_validate) override;
241
+
238
242
  using TransactionBaseImpl::Put;
239
243
  // `key` does NOT include timestamp even when it's enabled.
240
244
  Status Put(ColumnFamilyHandle* column_family, const Slice& key,
@@ -249,6 +253,25 @@ class WriteCommittedTxn : public PessimisticTransaction {
249
253
  Status PutUntracked(ColumnFamilyHandle* column_family, const SliceParts& key,
250
254
  const SliceParts& value) override;
251
255
 
256
+ // `key` does NOT include timestamp even when it's enabled.
257
+ Status PutEntity(ColumnFamilyHandle* column_family, const Slice& key,
258
+ const WideColumns& columns,
259
+ bool assume_tracked = false) override {
260
+ const bool do_validate = !assume_tracked;
261
+
262
+ return PutEntityImpl(column_family, key, columns, do_validate,
263
+ assume_tracked);
264
+ }
265
+
266
+ Status PutEntityUntracked(ColumnFamilyHandle* column_family, const Slice& key,
267
+ const WideColumns& columns) override {
268
+ constexpr bool do_validate = false;
269
+ constexpr bool assume_tracked = false;
270
+
271
+ return PutEntityImpl(column_family, key, columns, do_validate,
272
+ assume_tracked);
273
+ }
274
+
252
275
  using TransactionBaseImpl::Delete;
253
276
  // `key` does NOT include timestamp even when it's enabled.
254
277
  Status Delete(ColumnFamilyHandle* column_family, const Slice& key,
@@ -288,6 +311,10 @@ class WriteCommittedTxn : public PessimisticTransaction {
288
311
  TValue* value, bool exclusive,
289
312
  const bool do_validate);
290
313
 
314
+ Status PutEntityImpl(ColumnFamilyHandle* column_family, const Slice& key,
315
+ const WideColumns& columns, bool do_validate,
316
+ bool assume_tracked);
317
+
291
318
  template <typename TKey, typename TOperation>
292
319
  Status Operate(ColumnFamilyHandle* column_family, const TKey& key,
293
320
  const bool do_validate, const bool assume_tracked,
@@ -303,6 +330,11 @@ class WriteCommittedTxn : public PessimisticTransaction {
303
330
 
304
331
  Status RollbackInternal() override;
305
332
 
333
+ // Checks if the combination of `do_validate`, the read timestamp set in
334
+ // `read_timestamp_` and the `enable_udt_validation` flag in
335
+ // TransactionDBOptions make sense together.
336
+ Status SanityCheckReadTimestamp(bool do_validate);
337
+
306
338
  // Column families that enable timestamps and whose data are written when
307
339
  // indexing_enabled_ is false. If a key is written when indexing_enabled_ is
308
340
  // true, then the corresponding column family is not added to cfs_with_ts