tigerbeetle 0.0.40 → 0.17.8

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 (293) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +0 -25
  3. data/README.md +670 -80
  4. data/docs/migration.md +201 -0
  5. data/sig/tigerbeetle.rbs +271 -0
  6. data/src/ext/tigerbeetle/extconf.rb +47 -0
  7. data/src/ext/tigerbeetle/lib/aarch64-linux-gnu.2.27/libtb_client.so +0 -0
  8. data/src/ext/tigerbeetle/lib/aarch64-linux-musl/libtb_client.so +0 -0
  9. data/src/ext/tigerbeetle/lib/aarch64-macos/libtb_client.dylib +0 -0
  10. data/src/ext/tigerbeetle/lib/x86_64-linux-gnu.2.27/libtb_client.so +0 -0
  11. data/src/ext/tigerbeetle/lib/x86_64-linux-musl/libtb_client.so +0 -0
  12. data/src/ext/tigerbeetle/lib/x86_64-macos/libtb_client.dylib +0 -0
  13. data/src/ext/tigerbeetle/lib/x86_64-windows/tb_client.dll +0 -0
  14. data/src/ext/tigerbeetle/rb_tb_gen.h +458 -0
  15. data/{ext/tb_client/tigerbeetle/src/clients/rust/assets → src/ext/tigerbeetle}/tb_client.h +18 -16
  16. data/src/ext/tigerbeetle/tigerbeetle.c +310 -0
  17. data/src/tigerbeetle/bindings.rb +347 -0
  18. data/src/tigerbeetle/client.rb +129 -0
  19. data/src/tigerbeetle/completion_dispatcher.rb +108 -0
  20. data/src/tigerbeetle/id.rb +40 -0
  21. data/src/tigerbeetle/tb.rb +3 -0
  22. data/src/tigerbeetle/version.rb +3 -0
  23. data/src/tigerbeetle.rb +39 -0
  24. metadata +33 -350
  25. data/CHANGELOG.md +0 -162
  26. data/ext/tb_client/extconf.rb +0 -41
  27. data/ext/tb_client/tigerbeetle/LICENSE +0 -177
  28. data/ext/tb_client/tigerbeetle/build.zig +0 -2296
  29. data/ext/tb_client/tigerbeetle/src/aof.zig +0 -1000
  30. data/ext/tb_client/tigerbeetle/src/build/fetch.zig +0 -112
  31. data/ext/tb_client/tigerbeetle/src/build_multiversion.zig +0 -808
  32. data/ext/tb_client/tigerbeetle/src/cdc/amqp/protocol.zig +0 -1283
  33. data/ext/tb_client/tigerbeetle/src/cdc/amqp/spec.zig +0 -1704
  34. data/ext/tb_client/tigerbeetle/src/cdc/amqp/types.zig +0 -341
  35. data/ext/tb_client/tigerbeetle/src/cdc/amqp.zig +0 -1450
  36. data/ext/tb_client/tigerbeetle/src/cdc/runner.zig +0 -1659
  37. data/ext/tb_client/tigerbeetle/src/clients/c/samples/main.c +0 -406
  38. data/ext/tb_client/tigerbeetle/src/clients/c/tb_client/context.zig +0 -1092
  39. data/ext/tb_client/tigerbeetle/src/clients/c/tb_client/echo_client.zig +0 -286
  40. data/ext/tb_client/tigerbeetle/src/clients/c/tb_client/packet.zig +0 -158
  41. data/ext/tb_client/tigerbeetle/src/clients/c/tb_client/signal.zig +0 -229
  42. data/ext/tb_client/tigerbeetle/src/clients/c/tb_client/signal_fuzz.zig +0 -110
  43. data/ext/tb_client/tigerbeetle/src/clients/c/tb_client.h +0 -386
  44. data/ext/tb_client/tigerbeetle/src/clients/c/tb_client.zig +0 -34
  45. data/ext/tb_client/tigerbeetle/src/clients/c/tb_client_exports.zig +0 -281
  46. data/ext/tb_client/tigerbeetle/src/clients/c/tb_client_header.zig +0 -312
  47. data/ext/tb_client/tigerbeetle/src/clients/c/tb_client_header_test.zig +0 -138
  48. data/ext/tb_client/tigerbeetle/src/clients/c/test.zig +0 -466
  49. data/ext/tb_client/tigerbeetle/src/clients/docs_samples.zig +0 -157
  50. data/ext/tb_client/tigerbeetle/src/clients/docs_types.zig +0 -90
  51. data/ext/tb_client/tigerbeetle/src/clients/dotnet/ci.zig +0 -203
  52. data/ext/tb_client/tigerbeetle/src/clients/dotnet/docs.zig +0 -79
  53. data/ext/tb_client/tigerbeetle/src/clients/dotnet/dotnet_bindings.zig +0 -542
  54. data/ext/tb_client/tigerbeetle/src/clients/go/ci.zig +0 -109
  55. data/ext/tb_client/tigerbeetle/src/clients/go/docs.zig +0 -86
  56. data/ext/tb_client/tigerbeetle/src/clients/go/go_bindings.zig +0 -370
  57. data/ext/tb_client/tigerbeetle/src/clients/go/pkg/native/tb_client.h +0 -386
  58. data/ext/tb_client/tigerbeetle/src/clients/java/ci.zig +0 -167
  59. data/ext/tb_client/tigerbeetle/src/clients/java/docs.zig +0 -126
  60. data/ext/tb_client/tigerbeetle/src/clients/java/java_bindings.zig +0 -996
  61. data/ext/tb_client/tigerbeetle/src/clients/java/src/client.zig +0 -748
  62. data/ext/tb_client/tigerbeetle/src/clients/java/src/jni.zig +0 -3238
  63. data/ext/tb_client/tigerbeetle/src/clients/java/src/jni_tests.zig +0 -1718
  64. data/ext/tb_client/tigerbeetle/src/clients/java/src/jni_thread_cleaner.zig +0 -190
  65. data/ext/tb_client/tigerbeetle/src/clients/node/ci.zig +0 -104
  66. data/ext/tb_client/tigerbeetle/src/clients/node/docs.zig +0 -75
  67. data/ext/tb_client/tigerbeetle/src/clients/node/node.zig +0 -522
  68. data/ext/tb_client/tigerbeetle/src/clients/node/node_bindings.zig +0 -267
  69. data/ext/tb_client/tigerbeetle/src/clients/node/src/c.zig +0 -3
  70. data/ext/tb_client/tigerbeetle/src/clients/node/src/translate.zig +0 -379
  71. data/ext/tb_client/tigerbeetle/src/clients/python/ci.zig +0 -131
  72. data/ext/tb_client/tigerbeetle/src/clients/python/docs.zig +0 -63
  73. data/ext/tb_client/tigerbeetle/src/clients/python/python_bindings.zig +0 -588
  74. data/ext/tb_client/tigerbeetle/src/clients/rust/ci.zig +0 -73
  75. data/ext/tb_client/tigerbeetle/src/clients/rust/docs.zig +0 -106
  76. data/ext/tb_client/tigerbeetle/src/clients/rust/rust_bindings.zig +0 -305
  77. data/ext/tb_client/tigerbeetle/src/config.zig +0 -296
  78. data/ext/tb_client/tigerbeetle/src/constants.zig +0 -790
  79. data/ext/tb_client/tigerbeetle/src/copyhound.zig +0 -202
  80. data/ext/tb_client/tigerbeetle/src/counting_allocator.zig +0 -72
  81. data/ext/tb_client/tigerbeetle/src/direction.zig +0 -120
  82. data/ext/tb_client/tigerbeetle/src/docs_website/build.zig +0 -158
  83. data/ext/tb_client/tigerbeetle/src/docs_website/src/content.zig +0 -156
  84. data/ext/tb_client/tigerbeetle/src/docs_website/src/docs.zig +0 -252
  85. data/ext/tb_client/tigerbeetle/src/docs_website/src/file_checker.zig +0 -313
  86. data/ext/tb_client/tigerbeetle/src/docs_website/src/html.zig +0 -87
  87. data/ext/tb_client/tigerbeetle/src/docs_website/src/page_writer.zig +0 -63
  88. data/ext/tb_client/tigerbeetle/src/docs_website/src/redirects.zig +0 -47
  89. data/ext/tb_client/tigerbeetle/src/docs_website/src/search_index_writer.zig +0 -28
  90. data/ext/tb_client/tigerbeetle/src/docs_website/src/service_worker_writer.zig +0 -61
  91. data/ext/tb_client/tigerbeetle/src/docs_website/src/single_page_writer.zig +0 -169
  92. data/ext/tb_client/tigerbeetle/src/docs_website/src/website.zig +0 -46
  93. data/ext/tb_client/tigerbeetle/src/ewah.zig +0 -445
  94. data/ext/tb_client/tigerbeetle/src/ewah_benchmark.zig +0 -128
  95. data/ext/tb_client/tigerbeetle/src/ewah_fuzz.zig +0 -171
  96. data/ext/tb_client/tigerbeetle/src/fuzz_tests.zig +0 -179
  97. data/ext/tb_client/tigerbeetle/src/integration_tests.zig +0 -662
  98. data/ext/tb_client/tigerbeetle/src/io/common.zig +0 -155
  99. data/ext/tb_client/tigerbeetle/src/io/darwin.zig +0 -1093
  100. data/ext/tb_client/tigerbeetle/src/io/linux.zig +0 -1880
  101. data/ext/tb_client/tigerbeetle/src/io/test.zig +0 -1005
  102. data/ext/tb_client/tigerbeetle/src/io/windows.zig +0 -1598
  103. data/ext/tb_client/tigerbeetle/src/io.zig +0 -34
  104. data/ext/tb_client/tigerbeetle/src/iops.zig +0 -134
  105. data/ext/tb_client/tigerbeetle/src/list.zig +0 -236
  106. data/ext/tb_client/tigerbeetle/src/lsm/binary_search.zig +0 -848
  107. data/ext/tb_client/tigerbeetle/src/lsm/binary_search_benchmark.zig +0 -179
  108. data/ext/tb_client/tigerbeetle/src/lsm/cache_map.zig +0 -424
  109. data/ext/tb_client/tigerbeetle/src/lsm/cache_map_fuzz.zig +0 -420
  110. data/ext/tb_client/tigerbeetle/src/lsm/compaction.zig +0 -2114
  111. data/ext/tb_client/tigerbeetle/src/lsm/composite_key.zig +0 -185
  112. data/ext/tb_client/tigerbeetle/src/lsm/forest.zig +0 -1146
  113. data/ext/tb_client/tigerbeetle/src/lsm/forest_fuzz.zig +0 -1102
  114. data/ext/tb_client/tigerbeetle/src/lsm/forest_table_iterator.zig +0 -200
  115. data/ext/tb_client/tigerbeetle/src/lsm/groove.zig +0 -1495
  116. data/ext/tb_client/tigerbeetle/src/lsm/k_way_merge.zig +0 -739
  117. data/ext/tb_client/tigerbeetle/src/lsm/k_way_merge_benchmark.zig +0 -166
  118. data/ext/tb_client/tigerbeetle/src/lsm/manifest.zig +0 -754
  119. data/ext/tb_client/tigerbeetle/src/lsm/manifest_level.zig +0 -1294
  120. data/ext/tb_client/tigerbeetle/src/lsm/manifest_level_fuzz.zig +0 -510
  121. data/ext/tb_client/tigerbeetle/src/lsm/manifest_log.zig +0 -1241
  122. data/ext/tb_client/tigerbeetle/src/lsm/manifest_log_fuzz.zig +0 -628
  123. data/ext/tb_client/tigerbeetle/src/lsm/node_pool.zig +0 -247
  124. data/ext/tb_client/tigerbeetle/src/lsm/scan_buffer.zig +0 -116
  125. data/ext/tb_client/tigerbeetle/src/lsm/scan_builder.zig +0 -543
  126. data/ext/tb_client/tigerbeetle/src/lsm/scan_fuzz.zig +0 -938
  127. data/ext/tb_client/tigerbeetle/src/lsm/scan_lookup.zig +0 -293
  128. data/ext/tb_client/tigerbeetle/src/lsm/scan_merge.zig +0 -359
  129. data/ext/tb_client/tigerbeetle/src/lsm/scan_range.zig +0 -99
  130. data/ext/tb_client/tigerbeetle/src/lsm/scan_state.zig +0 -17
  131. data/ext/tb_client/tigerbeetle/src/lsm/scan_tree.zig +0 -962
  132. data/ext/tb_client/tigerbeetle/src/lsm/schema.zig +0 -617
  133. data/ext/tb_client/tigerbeetle/src/lsm/scratch_memory.zig +0 -84
  134. data/ext/tb_client/tigerbeetle/src/lsm/segmented_array.zig +0 -1500
  135. data/ext/tb_client/tigerbeetle/src/lsm/segmented_array_benchmark.zig +0 -149
  136. data/ext/tb_client/tigerbeetle/src/lsm/segmented_array_fuzz.zig +0 -7
  137. data/ext/tb_client/tigerbeetle/src/lsm/set_associative_cache.zig +0 -865
  138. data/ext/tb_client/tigerbeetle/src/lsm/table.zig +0 -607
  139. data/ext/tb_client/tigerbeetle/src/lsm/table_memory.zig +0 -843
  140. data/ext/tb_client/tigerbeetle/src/lsm/table_value_iterator.zig +0 -90
  141. data/ext/tb_client/tigerbeetle/src/lsm/timestamp_range.zig +0 -40
  142. data/ext/tb_client/tigerbeetle/src/lsm/tree.zig +0 -629
  143. data/ext/tb_client/tigerbeetle/src/lsm/tree_fuzz.zig +0 -933
  144. data/ext/tb_client/tigerbeetle/src/lsm/zig_zag_merge.zig +0 -534
  145. data/ext/tb_client/tigerbeetle/src/message_buffer.zig +0 -469
  146. data/ext/tb_client/tigerbeetle/src/message_bus.zig +0 -1219
  147. data/ext/tb_client/tigerbeetle/src/message_bus_fuzz.zig +0 -936
  148. data/ext/tb_client/tigerbeetle/src/message_pool.zig +0 -343
  149. data/ext/tb_client/tigerbeetle/src/multiversion.zig +0 -2195
  150. data/ext/tb_client/tigerbeetle/src/queue.zig +0 -390
  151. data/ext/tb_client/tigerbeetle/src/repl/completion.zig +0 -201
  152. data/ext/tb_client/tigerbeetle/src/repl/parser.zig +0 -1356
  153. data/ext/tb_client/tigerbeetle/src/repl/terminal.zig +0 -496
  154. data/ext/tb_client/tigerbeetle/src/repl.zig +0 -1034
  155. data/ext/tb_client/tigerbeetle/src/scripts/amqp.zig +0 -973
  156. data/ext/tb_client/tigerbeetle/src/scripts/cfo.zig +0 -1866
  157. data/ext/tb_client/tigerbeetle/src/scripts/changelog.zig +0 -304
  158. data/ext/tb_client/tigerbeetle/src/scripts/ci.zig +0 -227
  159. data/ext/tb_client/tigerbeetle/src/scripts/client_readmes.zig +0 -658
  160. data/ext/tb_client/tigerbeetle/src/scripts/devhub.zig +0 -466
  161. data/ext/tb_client/tigerbeetle/src/scripts/release.zig +0 -1058
  162. data/ext/tb_client/tigerbeetle/src/scripts.zig +0 -105
  163. data/ext/tb_client/tigerbeetle/src/shell.zig +0 -1195
  164. data/ext/tb_client/tigerbeetle/src/stack.zig +0 -260
  165. data/ext/tb_client/tigerbeetle/src/state_machine/auditor.zig +0 -911
  166. data/ext/tb_client/tigerbeetle/src/state_machine/workload.zig +0 -2079
  167. data/ext/tb_client/tigerbeetle/src/state_machine.zig +0 -4872
  168. data/ext/tb_client/tigerbeetle/src/state_machine_fuzz.zig +0 -288
  169. data/ext/tb_client/tigerbeetle/src/state_machine_tests.zig +0 -3128
  170. data/ext/tb_client/tigerbeetle/src/static_allocator.zig +0 -82
  171. data/ext/tb_client/tigerbeetle/src/stdx/bit_set.zig +0 -157
  172. data/ext/tb_client/tigerbeetle/src/stdx/bounded_array.zig +0 -292
  173. data/ext/tb_client/tigerbeetle/src/stdx/debug.zig +0 -65
  174. data/ext/tb_client/tigerbeetle/src/stdx/flags.zig +0 -1414
  175. data/ext/tb_client/tigerbeetle/src/stdx/huge_page_allocator.zig +0 -115
  176. data/ext/tb_client/tigerbeetle/src/stdx/mlock.zig +0 -92
  177. data/ext/tb_client/tigerbeetle/src/stdx/prng.zig +0 -677
  178. data/ext/tb_client/tigerbeetle/src/stdx/radix.zig +0 -336
  179. data/ext/tb_client/tigerbeetle/src/stdx/ring_buffer.zig +0 -511
  180. data/ext/tb_client/tigerbeetle/src/stdx/sort_test.zig +0 -112
  181. data/ext/tb_client/tigerbeetle/src/stdx/stdx.zig +0 -1163
  182. data/ext/tb_client/tigerbeetle/src/stdx/testing/low_level_hash_vectors.zig +0 -142
  183. data/ext/tb_client/tigerbeetle/src/stdx/testing/snaptest.zig +0 -361
  184. data/ext/tb_client/tigerbeetle/src/stdx/time_units.zig +0 -275
  185. data/ext/tb_client/tigerbeetle/src/stdx/unshare.zig +0 -295
  186. data/ext/tb_client/tigerbeetle/src/stdx/vendored/aegis.zig +0 -436
  187. data/ext/tb_client/tigerbeetle/src/stdx/windows.zig +0 -48
  188. data/ext/tb_client/tigerbeetle/src/stdx/zipfian.zig +0 -402
  189. data/ext/tb_client/tigerbeetle/src/storage.zig +0 -489
  190. data/ext/tb_client/tigerbeetle/src/storage_fuzz.zig +0 -180
  191. data/ext/tb_client/tigerbeetle/src/testing/bench.zig +0 -146
  192. data/ext/tb_client/tigerbeetle/src/testing/cluster/grid_checker.zig +0 -53
  193. data/ext/tb_client/tigerbeetle/src/testing/cluster/journal_checker.zig +0 -61
  194. data/ext/tb_client/tigerbeetle/src/testing/cluster/manifest_checker.zig +0 -76
  195. data/ext/tb_client/tigerbeetle/src/testing/cluster/message_bus.zig +0 -110
  196. data/ext/tb_client/tigerbeetle/src/testing/cluster/network.zig +0 -412
  197. data/ext/tb_client/tigerbeetle/src/testing/cluster/state_checker.zig +0 -331
  198. data/ext/tb_client/tigerbeetle/src/testing/cluster/storage_checker.zig +0 -458
  199. data/ext/tb_client/tigerbeetle/src/testing/cluster.zig +0 -1198
  200. data/ext/tb_client/tigerbeetle/src/testing/exhaustigen.zig +0 -128
  201. data/ext/tb_client/tigerbeetle/src/testing/fixtures.zig +0 -181
  202. data/ext/tb_client/tigerbeetle/src/testing/fuzz.zig +0 -144
  203. data/ext/tb_client/tigerbeetle/src/testing/id.zig +0 -97
  204. data/ext/tb_client/tigerbeetle/src/testing/io.zig +0 -317
  205. data/ext/tb_client/tigerbeetle/src/testing/marks.zig +0 -126
  206. data/ext/tb_client/tigerbeetle/src/testing/packet_simulator.zig +0 -533
  207. data/ext/tb_client/tigerbeetle/src/testing/reply_sequence.zig +0 -154
  208. data/ext/tb_client/tigerbeetle/src/testing/state_machine.zig +0 -389
  209. data/ext/tb_client/tigerbeetle/src/testing/storage.zig +0 -1247
  210. data/ext/tb_client/tigerbeetle/src/testing/table.zig +0 -249
  211. data/ext/tb_client/tigerbeetle/src/testing/time.zig +0 -98
  212. data/ext/tb_client/tigerbeetle/src/testing/tmp_tigerbeetle.zig +0 -212
  213. data/ext/tb_client/tigerbeetle/src/testing/vortex/constants.zig +0 -26
  214. data/ext/tb_client/tigerbeetle/src/testing/vortex/faulty_network.zig +0 -579
  215. data/ext/tb_client/tigerbeetle/src/testing/vortex/java_driver/ci.zig +0 -39
  216. data/ext/tb_client/tigerbeetle/src/testing/vortex/logged_process.zig +0 -214
  217. data/ext/tb_client/tigerbeetle/src/testing/vortex/rust_driver/ci.zig +0 -34
  218. data/ext/tb_client/tigerbeetle/src/testing/vortex/supervisor.zig +0 -785
  219. data/ext/tb_client/tigerbeetle/src/testing/vortex/workload.zig +0 -543
  220. data/ext/tb_client/tigerbeetle/src/testing/vortex/zig_driver.zig +0 -181
  221. data/ext/tb_client/tigerbeetle/src/tidy.zig +0 -1449
  222. data/ext/tb_client/tigerbeetle/src/tigerbeetle/benchmark_driver.zig +0 -227
  223. data/ext/tb_client/tigerbeetle/src/tigerbeetle/benchmark_load.zig +0 -1069
  224. data/ext/tb_client/tigerbeetle/src/tigerbeetle/cli.zig +0 -1422
  225. data/ext/tb_client/tigerbeetle/src/tigerbeetle/inspect.zig +0 -1658
  226. data/ext/tb_client/tigerbeetle/src/tigerbeetle/inspect_integrity.zig +0 -518
  227. data/ext/tb_client/tigerbeetle/src/tigerbeetle/libtb_client.zig +0 -36
  228. data/ext/tb_client/tigerbeetle/src/tigerbeetle/main.zig +0 -646
  229. data/ext/tb_client/tigerbeetle/src/tigerbeetle.zig +0 -958
  230. data/ext/tb_client/tigerbeetle/src/time.zig +0 -236
  231. data/ext/tb_client/tigerbeetle/src/trace/event.zig +0 -745
  232. data/ext/tb_client/tigerbeetle/src/trace/statsd.zig +0 -462
  233. data/ext/tb_client/tigerbeetle/src/trace.zig +0 -556
  234. data/ext/tb_client/tigerbeetle/src/unit_tests.zig +0 -321
  235. data/ext/tb_client/tigerbeetle/src/vopr.zig +0 -1785
  236. data/ext/tb_client/tigerbeetle/src/vortex.zig +0 -101
  237. data/ext/tb_client/tigerbeetle/src/vsr/checkpoint_trailer.zig +0 -473
  238. data/ext/tb_client/tigerbeetle/src/vsr/checksum.zig +0 -208
  239. data/ext/tb_client/tigerbeetle/src/vsr/checksum_benchmark.zig +0 -43
  240. data/ext/tb_client/tigerbeetle/src/vsr/client.zig +0 -768
  241. data/ext/tb_client/tigerbeetle/src/vsr/client_replies.zig +0 -532
  242. data/ext/tb_client/tigerbeetle/src/vsr/client_sessions.zig +0 -338
  243. data/ext/tb_client/tigerbeetle/src/vsr/clock.zig +0 -1019
  244. data/ext/tb_client/tigerbeetle/src/vsr/fault_detector.zig +0 -279
  245. data/ext/tb_client/tigerbeetle/src/vsr/free_set.zig +0 -1381
  246. data/ext/tb_client/tigerbeetle/src/vsr/free_set_fuzz.zig +0 -315
  247. data/ext/tb_client/tigerbeetle/src/vsr/grid.zig +0 -1460
  248. data/ext/tb_client/tigerbeetle/src/vsr/grid_blocks_missing.zig +0 -757
  249. data/ext/tb_client/tigerbeetle/src/vsr/grid_scrubber.zig +0 -797
  250. data/ext/tb_client/tigerbeetle/src/vsr/journal.zig +0 -2586
  251. data/ext/tb_client/tigerbeetle/src/vsr/marzullo.zig +0 -308
  252. data/ext/tb_client/tigerbeetle/src/vsr/message_header.zig +0 -1777
  253. data/ext/tb_client/tigerbeetle/src/vsr/multi_batch.zig +0 -715
  254. data/ext/tb_client/tigerbeetle/src/vsr/multi_batch_fuzz.zig +0 -185
  255. data/ext/tb_client/tigerbeetle/src/vsr/repair_budget.zig +0 -333
  256. data/ext/tb_client/tigerbeetle/src/vsr/replica.zig +0 -12356
  257. data/ext/tb_client/tigerbeetle/src/vsr/replica_format.zig +0 -416
  258. data/ext/tb_client/tigerbeetle/src/vsr/replica_reformat.zig +0 -165
  259. data/ext/tb_client/tigerbeetle/src/vsr/replica_test.zig +0 -2928
  260. data/ext/tb_client/tigerbeetle/src/vsr/routing.zig +0 -1075
  261. data/ext/tb_client/tigerbeetle/src/vsr/superblock.zig +0 -1603
  262. data/ext/tb_client/tigerbeetle/src/vsr/superblock_fuzz.zig +0 -484
  263. data/ext/tb_client/tigerbeetle/src/vsr/superblock_quorums.zig +0 -405
  264. data/ext/tb_client/tigerbeetle/src/vsr/superblock_quorums_fuzz.zig +0 -355
  265. data/ext/tb_client/tigerbeetle/src/vsr/sync.zig +0 -29
  266. data/ext/tb_client/tigerbeetle/src/vsr.zig +0 -1727
  267. data/lib/tb_client/shared_lib.rb +0 -66
  268. data/lib/tb_client.rb +0 -282
  269. data/lib/tigerbeetle/account.rb +0 -38
  270. data/lib/tigerbeetle/account_balance.rb +0 -23
  271. data/lib/tigerbeetle/account_filter.rb +0 -31
  272. data/lib/tigerbeetle/atomic_counter.rb +0 -14
  273. data/lib/tigerbeetle/client.rb +0 -214
  274. data/lib/tigerbeetle/converters/account.rb +0 -63
  275. data/lib/tigerbeetle/converters/account_balance.rb +0 -31
  276. data/lib/tigerbeetle/converters/account_filter.rb +0 -32
  277. data/lib/tigerbeetle/converters/base.rb +0 -35
  278. data/lib/tigerbeetle/converters/create_accounts_result.rb +0 -21
  279. data/lib/tigerbeetle/converters/create_transfers_result.rb +0 -21
  280. data/lib/tigerbeetle/converters/query_filter.rb +0 -33
  281. data/lib/tigerbeetle/converters/time.rb +0 -23
  282. data/lib/tigerbeetle/converters/transfer.rb +0 -64
  283. data/lib/tigerbeetle/converters/uint_128.rb +0 -24
  284. data/lib/tigerbeetle/converters.rb +0 -12
  285. data/lib/tigerbeetle/error.rb +0 -4
  286. data/lib/tigerbeetle/id.rb +0 -30
  287. data/lib/tigerbeetle/platforms.rb +0 -9
  288. data/lib/tigerbeetle/query_filter.rb +0 -31
  289. data/lib/tigerbeetle/request.rb +0 -7
  290. data/lib/tigerbeetle/transfer.rb +0 -40
  291. data/lib/tigerbeetle/version.rb +0 -4
  292. data/lib/tigerbeetle.rb +0 -13
  293. data/tigerbeetle.gemspec +0 -60
@@ -1,405 +0,0 @@
1
- const std = @import("std");
2
- const assert = std.debug.assert;
3
- const log = std.log.scoped(.superblock_quorums);
4
-
5
- const stdx = @import("stdx");
6
-
7
- const superblock = @import("./superblock.zig");
8
- const SuperBlockHeader = superblock.SuperBlockHeader;
9
- const fuzz = @import("./superblock_quorums_fuzz.zig");
10
-
11
- pub const Options = struct {
12
- superblock_copies: u8,
13
- };
14
-
15
- pub fn QuorumsType(comptime options: Options) type {
16
- return struct {
17
- const Quorums = @This();
18
-
19
- const Quorum = struct {
20
- header: *const SuperBlockHeader,
21
- valid: bool = false,
22
- /// Track which copies are a member of the quorum.
23
- /// Used to ignore duplicate copies of a header when determining a quorum.
24
- copies: QuorumCount = .{},
25
- /// An integer value indicates the copy index found in the corresponding slot.
26
- /// A `null` value indicates that the copy is invalid or not a member of the working
27
- /// quorum. All copies belong to the same (valid, working) quorum.
28
- slots: [options.superblock_copies]?u8 = @splat(null),
29
-
30
- pub fn repairs(quorum: Quorum) RepairIterator {
31
- assert(quorum.valid);
32
- return .{ .slots = quorum.slots };
33
- }
34
- };
35
-
36
- pub const QuorumCount = stdx.BitSetType(options.superblock_copies);
37
-
38
- pub const Error = error{
39
- Fork,
40
- NotFound,
41
- QuorumLost,
42
- ParentNotConnected,
43
- ParentSkipped,
44
- VSRStateNotMonotonic,
45
- };
46
-
47
- /// We use flexible quorums for even quorums with write quorum > read quorum, for example:
48
- /// * When writing, we must verify that at least 3/4 copies were written.
49
- /// * At startup, we must verify that at least 2/4 copies were read.
50
- ///
51
- /// This ensures that our read and write quorums will intersect.
52
- /// Using flexible quorums in this way increases resiliency of the superblock.
53
- pub const Threshold = enum {
54
- verify,
55
- open,
56
- // Working these threshold out by formula is easy to get wrong, so enumerate them:
57
- // The rule is that the write quorum plus the read quorum must be exactly copies + 1.
58
-
59
- pub fn count(threshold: Threshold) u8 {
60
- return switch (threshold) {
61
- .verify => switch (options.superblock_copies) {
62
- 4 => 3,
63
- 6 => 4,
64
- 8 => 5,
65
- else => unreachable,
66
- },
67
- // The open quorum must allow for at least two copy faults, because we update
68
- // copies in place, temporarily impairing one copy.
69
- .open => switch (options.superblock_copies) {
70
- 4 => 2,
71
- 6 => 3,
72
- 8 => 4,
73
- else => unreachable,
74
- },
75
- };
76
- }
77
- };
78
-
79
- array: [options.superblock_copies]Quorum = undefined,
80
- count: u8 = 0,
81
-
82
- /// Returns the working superblock according to the quorum with the highest sequence number.
83
- ///
84
- /// * When a member of the parent quorum is still present, verify that the highest quorum is
85
- /// connected.
86
- /// * When there are 2 quorums: 1/4 new and 3/4 old, favor the 3/4 old since it is safer to
87
- /// repair.
88
- /// TODO Re-examine this now that there are no superblock trailers to worry about.
89
- pub fn working(
90
- quorums: *Quorums,
91
- copies: []const SuperBlockHeader,
92
- threshold: Threshold,
93
- ) Error!Quorum {
94
- assert(copies.len == options.superblock_copies);
95
- assert(threshold.count() >= 2 and threshold.count() <= 5);
96
-
97
- quorums.array = undefined;
98
- quorums.count = 0;
99
-
100
- for (copies, 0..) |*copy, index| quorums.count_copy(copy, index, threshold);
101
-
102
- std.mem.sort(Quorum, quorums.slice(), {}, sort_priority_descending);
103
-
104
- for (quorums.slice()) |quorum| {
105
- if (quorum.copies.full()) {
106
- log.debug("quorum: checksum={x:0>32} parent={x:0>32} sequence={} count={} " ++
107
- "valid={}", .{
108
- quorum.header.checksum,
109
- quorum.header.parent,
110
- quorum.header.sequence,
111
- quorum.copies.count(),
112
- quorum.valid,
113
- });
114
- } else {
115
- log.warn("quorum: checksum={x:0>32} parent={x:0>32} sequence={} count={} " ++
116
- "valid={}", .{
117
- quorum.header.checksum,
118
- quorum.header.parent,
119
- quorum.header.sequence,
120
- quorum.copies.count(),
121
- quorum.valid,
122
- });
123
- }
124
- }
125
-
126
- // No working copies of any sequence number exist in the superblock storage zone at all.
127
- if (quorums.slice().len == 0) return error.NotFound;
128
-
129
- // At least one copy or quorum exists.
130
- const b = quorums.slice()[0];
131
-
132
- // Verify that the remaining quorums are correctly sorted:
133
- for (quorums.slice()[1..]) |a| {
134
- assert(sort_priority_descending({}, b, a));
135
- assert(a.header.valid_checksum());
136
- }
137
-
138
- // Even the best copy with the most quorum still has inadequate quorum.
139
- if (!b.valid) return error.QuorumLost;
140
-
141
- // If a parent quorum is present (either complete or incomplete) it must be connected to
142
- // the new working quorum. The parent quorum can exist due to:
143
- // - a crash during checkpoint()/view_change() before writing all copies
144
- // - a lost or misdirected write
145
- // - a latent sector error that prevented a write
146
- for (quorums.slice()[1..]) |a| {
147
- if (a.header.cluster != b.header.cluster) {
148
- log.warn("superblock copy={} has cluster={} instead of {}", .{
149
- a.header.copy,
150
- a.header.cluster,
151
- b.header.cluster,
152
- });
153
- continue;
154
- }
155
-
156
- if (a.header.vsr_state.replica_id != b.header.vsr_state.replica_id) {
157
- log.warn("superblock copy={} has replica_id={} instead of {}", .{
158
- a.header.copy,
159
- a.header.vsr_state.replica_id,
160
- b.header.vsr_state.replica_id,
161
- });
162
- continue;
163
- }
164
-
165
- if (a.header.sequence == b.header.sequence) {
166
- // Two quorums, same cluster+replica+sequence, but different checksums.
167
- // This shouldn't ever happen — but if it does, we can't safely repair.
168
- assert(a.header.checksum != b.header.checksum);
169
- return error.Fork;
170
- }
171
-
172
- if (a.header.sequence > b.header.sequence + 1) {
173
- // We read sequences such as (2,2,2,4) — 2 isn't safe to use, but there isn't a
174
- // valid quorum for 4 either.
175
- return error.ParentSkipped;
176
- }
177
-
178
- if (a.header.sequence + 1 == b.header.sequence) {
179
- assert(a.header.checksum != b.header.checksum);
180
- assert(a.header.cluster == b.header.cluster);
181
- assert(a.header.vsr_state.replica_id == b.header.vsr_state.replica_id);
182
-
183
- if (a.header.checksum != b.header.parent) {
184
- return error.ParentNotConnected;
185
- } else if (!a.header.vsr_state.monotonic(b.header.vsr_state)) {
186
- return error.VSRStateNotMonotonic;
187
- } else {
188
- assert(b.header.valid_checksum());
189
-
190
- return b;
191
- }
192
- }
193
- }
194
-
195
- assert(b.header.valid_checksum());
196
- return b;
197
- }
198
-
199
- fn count_copy(
200
- quorums: *Quorums,
201
- copy: *const SuperBlockHeader,
202
- slot: usize,
203
- threshold: Threshold,
204
- ) void {
205
- assert(slot < options.superblock_copies);
206
- assert(threshold.count() >= 2 and threshold.count() <= 5);
207
-
208
- if (!copy.valid_checksum()) {
209
- log.debug("copy: {}/{}: invalid checksum", .{ slot, options.superblock_copies });
210
- return;
211
- }
212
-
213
- if (copy.copy == slot) {
214
- log.debug("copy: {}/{}: checksum={x:0>32} parent={x:0>32} sequence={}", .{
215
- slot,
216
- options.superblock_copies,
217
- copy.checksum,
218
- copy.parent,
219
- copy.sequence,
220
- });
221
- } else if (copy.copy >= options.superblock_copies) {
222
- log.warn("copy: {}/{}: checksum={x:0>32} parent={x:0>32} sequence={} " ++
223
- "corrupt copy={}", .{
224
- slot,
225
- options.superblock_copies,
226
- copy.checksum,
227
- copy.parent,
228
- copy.sequence,
229
- copy.copy,
230
- });
231
- } else {
232
- // If our read was misdirected, we definitely still want to count the copy.
233
- // We must just be careful to count it idempotently.
234
- log.warn(
235
- "copy: {}/{}: checksum={x:0>32} parent={x:0>32} sequence={} " ++
236
- "misdirected from copy={}",
237
- .{
238
- slot,
239
- options.superblock_copies,
240
- copy.checksum,
241
- copy.parent,
242
- copy.sequence,
243
- copy.copy,
244
- },
245
- );
246
- }
247
-
248
- var quorum = quorums.find_or_insert_quorum_for_copy(copy);
249
- assert(quorum.header.checksum == copy.checksum);
250
- assert(quorum.header.equal(copy));
251
-
252
- if (copy.copy >= options.superblock_copies) {
253
- // This header is a valid member of the quorum, but with an unexpected copy number.
254
- // The "SuperBlockHeader.copy" field is not protected by the checksum, so if that
255
- // byte (and only that byte) is corrupted, the superblock is still valid — but we
256
- // don't know for certain which copy this was supposed to be.
257
- // We make the assumption that this was not a double-fault (corrupt + misdirect) —
258
- // that is, the copy is in the correct slot, and its copy index is simply corrupt.
259
- quorum.slots[slot] = @intCast(slot);
260
- quorum.copies.set(slot);
261
- } else if (quorum.copies.is_set(copy.copy)) {
262
- // Ignore the duplicate copy.
263
- } else {
264
- quorum.slots[slot] = @intCast(copy.copy);
265
- quorum.copies.set(copy.copy);
266
- }
267
-
268
- quorum.valid = quorum.copies.count() >= threshold.count();
269
- }
270
-
271
- fn find_or_insert_quorum_for_copy(
272
- quorums: *Quorums,
273
- copy: *const SuperBlockHeader,
274
- ) *Quorum {
275
- assert(copy.valid_checksum());
276
-
277
- for (quorums.array[0..quorums.count]) |*quorum| {
278
- if (copy.checksum == quorum.header.checksum) return quorum;
279
- } else {
280
- quorums.array[quorums.count] = Quorum{ .header = copy };
281
- quorums.count += 1;
282
-
283
- return &quorums.array[quorums.count - 1];
284
- }
285
- }
286
-
287
- fn slice(quorums: *Quorums) []Quorum {
288
- return quorums.array[0..quorums.count];
289
- }
290
-
291
- fn sort_priority_descending(_: void, a: Quorum, b: Quorum) bool {
292
- assert(a.header.checksum != b.header.checksum);
293
-
294
- if (a.valid and !b.valid) return true;
295
- if (b.valid and !a.valid) return false;
296
-
297
- if (a.header.sequence > b.header.sequence) return true;
298
- if (b.header.sequence > a.header.sequence) return false;
299
-
300
- if (a.copies.count() > b.copies.count()) return true;
301
- if (b.copies.count() > a.copies.count()) return false;
302
-
303
- // The sort order must be stable and deterministic:
304
- return a.header.checksum > b.header.checksum;
305
- }
306
-
307
- /// Repair a quorum's copies in the safest known order.
308
- /// Repair is complete when every copy is on-disk (not necessarily in its home slot).
309
- ///
310
- /// We must be careful when repairing superblock headers to avoid endangering our quorum if
311
- /// an additional fault occurs. We primarily guard against torn header writes — preventing a
312
- /// misdirected write from derailing repair is far more expensive and complex — but they are
313
- /// likewise far less likely to occur.
314
- ///
315
- /// For example, consider this case:
316
- /// 0. Sequence is initially A.
317
- /// 1. Checkpoint sequence B.
318
- /// 2. Write B₀ — ok.
319
- /// 3. Write B₁ — misdirected to B₂'s slot.
320
- /// 4. Crash.
321
- /// 5. Recover with quorum B[B₀,A₁,B₁,A₃].
322
- /// If we repair the superblock quorum while only considering the valid copies (and not
323
- /// slots) the following scenario could occur:
324
- /// 6. We already have a valid B₀ and B₁, so begin writing B₂.
325
- /// 7. Crash, tearing the B₂ write.
326
- /// 8. Recover with quorum A[B₀,A₁,_,A₂].
327
- /// The working quorum backtracked from B to A!
328
- pub const RepairIterator = struct {
329
- /// An integer value indicates the copy index found in the corresponding slot.
330
- /// A `null` value indicates that the copy is invalid or not a member of the working
331
- /// quorum. All copies belong to the same (valid, working) quorum.
332
- slots: [options.superblock_copies]?u8,
333
-
334
- /// Returns the slot/copy to repair next.
335
- /// We never (deliberately) write a copy to a slot other than its own. This is simpler
336
- /// to implement, and also reduces risk when one of open()'s reads was misdirected.
337
- pub fn next(iterator: *RepairIterator) ?u8 {
338
- // Corrupt copy indices have already been normalized.
339
- for (iterator.slots) |slot| {
340
- assert(slot == null or slot.? < options.superblock_copies);
341
- }
342
-
343
- // Set bits indicate that the corresponding copy was found at least once.
344
- var copies_any: QuorumCount = .{};
345
- // Set bits indicate that the corresponding copy was found more than once.
346
- var copies_duplicate: QuorumCount = .{};
347
-
348
- for (iterator.slots) |slot| {
349
- if (slot) |copy| {
350
- if (copies_any.is_set(copy)) copies_duplicate.set(copy);
351
- copies_any.set(copy);
352
- }
353
- }
354
-
355
- // In descending order, our priorities for repair are:
356
- // 1. The slot holds no header, and the copy was not found anywhere.
357
- // 2. The slot holds no header, but its copy was found elsewhere.
358
- // 3. The slot holds a misdirected header, but that copy is in another slot as well.
359
- var a: ?u8 = null;
360
- var b: ?u8 = null;
361
- var c: ?u8 = null;
362
- for (iterator.slots, 0..) |slot, i| {
363
- if (slot == null and !copies_any.is_set(i)) a = @intCast(i);
364
- if (slot == null and copies_any.is_set(i)) b = @intCast(i);
365
- if (slot) |slot_copy| {
366
- if (slot_copy != i and copies_duplicate.is_set(slot_copy)) c = @intCast(i);
367
- }
368
- }
369
-
370
- const repair = a orelse b orelse c orelse {
371
- for (iterator.slots) |slot| assert(slot != null);
372
- return null;
373
- };
374
-
375
- iterator.slots[repair] = repair;
376
- return repair;
377
- }
378
- };
379
- };
380
- }
381
-
382
- test "Quorums.working" {
383
- var prng = stdx.PRNG.from_seed_testing();
384
-
385
- // Don't print warnings from the Quorums.
386
- const level = std.testing.log_level;
387
- std.testing.log_level = std.log.Level.err;
388
- defer std.testing.log_level = level;
389
-
390
- try fuzz.fuzz_quorums_working(&prng);
391
- }
392
-
393
- test "Quorum.repairs" {
394
- var prng = stdx.PRNG.from_seed_testing();
395
-
396
- // Don't print warnings from the Quorums.
397
- const level = std.testing.log_level;
398
- std.testing.log_level = std.log.Level.err;
399
- defer std.testing.log_level = level;
400
-
401
- try fuzz.fuzz_quorum_repairs(&prng, .{ .superblock_copies = 4 });
402
- // TODO: Enable these once SuperBlockHeader is generic over its Constants.
403
- // try fuzz.fuzz_quorum_repairs(&prng, .{ .superblock_copies = 6 });
404
- // try fuzz.fuzz_quorum_repairs(&prng, .{ .superblock_copies = 8 });
405
- }