tigerbeetle-node 0.11.12 → 0.12.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 (143) hide show
  1. package/README.md +212 -196
  2. package/dist/bin/aarch64-linux-gnu/client.node +0 -0
  3. package/dist/bin/aarch64-linux-musl/client.node +0 -0
  4. package/dist/bin/aarch64-macos/client.node +0 -0
  5. package/dist/bin/x86_64-linux-gnu/client.node +0 -0
  6. package/dist/bin/x86_64-linux-musl/client.node +0 -0
  7. package/dist/bin/x86_64-macos/client.node +0 -0
  8. package/dist/index.js +33 -1
  9. package/dist/index.js.map +1 -1
  10. package/package-lock.json +66 -0
  11. package/package.json +8 -17
  12. package/src/index.ts +56 -1
  13. package/src/node.zig +10 -9
  14. package/dist/.client.node.sha256 +0 -1
  15. package/scripts/build_lib.sh +0 -61
  16. package/scripts/download_node_headers.sh +0 -32
  17. package/src/tigerbeetle/scripts/benchmark.bat +0 -48
  18. package/src/tigerbeetle/scripts/benchmark.sh +0 -66
  19. package/src/tigerbeetle/scripts/confirm_image.sh +0 -44
  20. package/src/tigerbeetle/scripts/fuzz_loop.sh +0 -15
  21. package/src/tigerbeetle/scripts/fuzz_unique_errors.sh +0 -7
  22. package/src/tigerbeetle/scripts/install.bat +0 -7
  23. package/src/tigerbeetle/scripts/install.sh +0 -21
  24. package/src/tigerbeetle/scripts/install_zig.bat +0 -113
  25. package/src/tigerbeetle/scripts/install_zig.sh +0 -90
  26. package/src/tigerbeetle/scripts/lint.zig +0 -199
  27. package/src/tigerbeetle/scripts/pre-commit.sh +0 -9
  28. package/src/tigerbeetle/scripts/scripts/benchmark.bat +0 -48
  29. package/src/tigerbeetle/scripts/scripts/benchmark.sh +0 -66
  30. package/src/tigerbeetle/scripts/scripts/confirm_image.sh +0 -44
  31. package/src/tigerbeetle/scripts/scripts/fuzz_loop.sh +0 -15
  32. package/src/tigerbeetle/scripts/scripts/fuzz_unique_errors.sh +0 -7
  33. package/src/tigerbeetle/scripts/scripts/install.bat +0 -7
  34. package/src/tigerbeetle/scripts/scripts/install.sh +0 -21
  35. package/src/tigerbeetle/scripts/scripts/install_zig.bat +0 -113
  36. package/src/tigerbeetle/scripts/scripts/install_zig.sh +0 -90
  37. package/src/tigerbeetle/scripts/scripts/lint.zig +0 -199
  38. package/src/tigerbeetle/scripts/scripts/pre-commit.sh +0 -9
  39. package/src/tigerbeetle/scripts/scripts/shellcheck.sh +0 -5
  40. package/src/tigerbeetle/scripts/scripts/tests_on_alpine.sh +0 -10
  41. package/src/tigerbeetle/scripts/scripts/tests_on_ubuntu.sh +0 -14
  42. package/src/tigerbeetle/scripts/scripts/upgrade_ubuntu_kernel.sh +0 -48
  43. package/src/tigerbeetle/scripts/scripts/validate_docs.sh +0 -23
  44. package/src/tigerbeetle/scripts/scripts/vr_state_enumerate +0 -46
  45. package/src/tigerbeetle/scripts/shellcheck.sh +0 -5
  46. package/src/tigerbeetle/scripts/tests_on_alpine.sh +0 -10
  47. package/src/tigerbeetle/scripts/tests_on_ubuntu.sh +0 -14
  48. package/src/tigerbeetle/scripts/upgrade_ubuntu_kernel.sh +0 -48
  49. package/src/tigerbeetle/scripts/validate_docs.sh +0 -23
  50. package/src/tigerbeetle/scripts/vr_state_enumerate +0 -46
  51. package/src/tigerbeetle/src/benchmark.zig +0 -314
  52. package/src/tigerbeetle/src/config.zig +0 -234
  53. package/src/tigerbeetle/src/constants.zig +0 -436
  54. package/src/tigerbeetle/src/ewah.zig +0 -286
  55. package/src/tigerbeetle/src/ewah_benchmark.zig +0 -120
  56. package/src/tigerbeetle/src/ewah_fuzz.zig +0 -130
  57. package/src/tigerbeetle/src/fifo.zig +0 -120
  58. package/src/tigerbeetle/src/io/benchmark.zig +0 -213
  59. package/src/tigerbeetle/src/io/darwin.zig +0 -814
  60. package/src/tigerbeetle/src/io/linux.zig +0 -1062
  61. package/src/tigerbeetle/src/io/test.zig +0 -643
  62. package/src/tigerbeetle/src/io/windows.zig +0 -1183
  63. package/src/tigerbeetle/src/io.zig +0 -34
  64. package/src/tigerbeetle/src/iops.zig +0 -107
  65. package/src/tigerbeetle/src/lsm/README.md +0 -308
  66. package/src/tigerbeetle/src/lsm/binary_search.zig +0 -341
  67. package/src/tigerbeetle/src/lsm/bloom_filter.zig +0 -125
  68. package/src/tigerbeetle/src/lsm/compaction.zig +0 -603
  69. package/src/tigerbeetle/src/lsm/composite_key.zig +0 -77
  70. package/src/tigerbeetle/src/lsm/direction.zig +0 -11
  71. package/src/tigerbeetle/src/lsm/eytzinger.zig +0 -587
  72. package/src/tigerbeetle/src/lsm/eytzinger_benchmark.zig +0 -330
  73. package/src/tigerbeetle/src/lsm/forest.zig +0 -204
  74. package/src/tigerbeetle/src/lsm/forest_fuzz.zig +0 -401
  75. package/src/tigerbeetle/src/lsm/grid.zig +0 -573
  76. package/src/tigerbeetle/src/lsm/groove.zig +0 -972
  77. package/src/tigerbeetle/src/lsm/k_way_merge.zig +0 -474
  78. package/src/tigerbeetle/src/lsm/level_iterator.zig +0 -332
  79. package/src/tigerbeetle/src/lsm/manifest.zig +0 -617
  80. package/src/tigerbeetle/src/lsm/manifest_level.zig +0 -877
  81. package/src/tigerbeetle/src/lsm/manifest_log.zig +0 -789
  82. package/src/tigerbeetle/src/lsm/manifest_log_fuzz.zig +0 -691
  83. package/src/tigerbeetle/src/lsm/merge_iterator.zig +0 -106
  84. package/src/tigerbeetle/src/lsm/node_pool.zig +0 -235
  85. package/src/tigerbeetle/src/lsm/posted_groove.zig +0 -378
  86. package/src/tigerbeetle/src/lsm/segmented_array.zig +0 -1328
  87. package/src/tigerbeetle/src/lsm/segmented_array_benchmark.zig +0 -148
  88. package/src/tigerbeetle/src/lsm/segmented_array_fuzz.zig +0 -9
  89. package/src/tigerbeetle/src/lsm/set_associative_cache.zig +0 -850
  90. package/src/tigerbeetle/src/lsm/table.zig +0 -1031
  91. package/src/tigerbeetle/src/lsm/table_immutable.zig +0 -203
  92. package/src/tigerbeetle/src/lsm/table_iterator.zig +0 -340
  93. package/src/tigerbeetle/src/lsm/table_mutable.zig +0 -220
  94. package/src/tigerbeetle/src/lsm/test.zig +0 -438
  95. package/src/tigerbeetle/src/lsm/tree.zig +0 -1193
  96. package/src/tigerbeetle/src/lsm/tree_fuzz.zig +0 -474
  97. package/src/tigerbeetle/src/message_bus.zig +0 -1012
  98. package/src/tigerbeetle/src/message_pool.zig +0 -156
  99. package/src/tigerbeetle/src/ring_buffer.zig +0 -399
  100. package/src/tigerbeetle/src/simulator.zig +0 -569
  101. package/src/tigerbeetle/src/state_machine/auditor.zig +0 -577
  102. package/src/tigerbeetle/src/state_machine/workload.zig +0 -883
  103. package/src/tigerbeetle/src/state_machine.zig +0 -1881
  104. package/src/tigerbeetle/src/static_allocator.zig +0 -65
  105. package/src/tigerbeetle/src/stdx.zig +0 -162
  106. package/src/tigerbeetle/src/storage.zig +0 -393
  107. package/src/tigerbeetle/src/testing/cluster/message_bus.zig +0 -82
  108. package/src/tigerbeetle/src/testing/cluster/network.zig +0 -237
  109. package/src/tigerbeetle/src/testing/cluster/state_checker.zig +0 -169
  110. package/src/tigerbeetle/src/testing/cluster/storage_checker.zig +0 -202
  111. package/src/tigerbeetle/src/testing/cluster.zig +0 -443
  112. package/src/tigerbeetle/src/testing/fuzz.zig +0 -140
  113. package/src/tigerbeetle/src/testing/hash_log.zig +0 -66
  114. package/src/tigerbeetle/src/testing/id.zig +0 -99
  115. package/src/tigerbeetle/src/testing/packet_simulator.zig +0 -364
  116. package/src/tigerbeetle/src/testing/priority_queue.zig +0 -645
  117. package/src/tigerbeetle/src/testing/reply_sequence.zig +0 -139
  118. package/src/tigerbeetle/src/testing/state_machine.zig +0 -249
  119. package/src/tigerbeetle/src/testing/storage.zig +0 -757
  120. package/src/tigerbeetle/src/testing/table.zig +0 -247
  121. package/src/tigerbeetle/src/testing/time.zig +0 -84
  122. package/src/tigerbeetle/src/tigerbeetle.zig +0 -227
  123. package/src/tigerbeetle/src/time.zig +0 -112
  124. package/src/tigerbeetle/src/tracer.zig +0 -529
  125. package/src/tigerbeetle/src/unit_tests.zig +0 -42
  126. package/src/tigerbeetle/src/vopr.zig +0 -495
  127. package/src/tigerbeetle/src/vsr/README.md +0 -209
  128. package/src/tigerbeetle/src/vsr/client.zig +0 -544
  129. package/src/tigerbeetle/src/vsr/clock.zig +0 -853
  130. package/src/tigerbeetle/src/vsr/journal.zig +0 -2413
  131. package/src/tigerbeetle/src/vsr/journal_format_fuzz.zig +0 -111
  132. package/src/tigerbeetle/src/vsr/marzullo.zig +0 -309
  133. package/src/tigerbeetle/src/vsr/replica.zig +0 -6381
  134. package/src/tigerbeetle/src/vsr/replica_format.zig +0 -219
  135. package/src/tigerbeetle/src/vsr/superblock.zig +0 -1631
  136. package/src/tigerbeetle/src/vsr/superblock_client_table.zig +0 -256
  137. package/src/tigerbeetle/src/vsr/superblock_free_set.zig +0 -929
  138. package/src/tigerbeetle/src/vsr/superblock_free_set_fuzz.zig +0 -334
  139. package/src/tigerbeetle/src/vsr/superblock_fuzz.zig +0 -390
  140. package/src/tigerbeetle/src/vsr/superblock_manifest.zig +0 -615
  141. package/src/tigerbeetle/src/vsr/superblock_quorums.zig +0 -394
  142. package/src/tigerbeetle/src/vsr/superblock_quorums_fuzz.zig +0 -314
  143. package/src/tigerbeetle/src/vsr.zig +0 -1352
@@ -1,209 +0,0 @@
1
- # Protocols
2
-
3
- ### Commands
4
-
5
- | `vsr.Header.Command` | Source | Target | Protocols |
6
- | -------------------: | ------: | -----------: | -------------------------------------------------------------- |
7
- | `ping` | replica | replica | [Ping (Replica-Replica)](#protocol-ping-replica-replica) |
8
- | `pong` | replica | replica | [Ping (Replica-Replica)](#protocol-ping-replica-replica) |
9
- | `ping_client` | client | replica | [Ping (Replica-Client)](#protocol-ping-replica-client) |
10
- | `pong_client` | replica | client | [Ping (Replica-Client)](#protocol-ping-replica-client) |
11
- | `request` | client | primary | [Normal](#protocol-normal) |
12
- | `prepare` | replica | backup | [Normal](#protocol-normal), [Repair WAL](#protocol-repair-wal) |
13
- | `prepare_ok` | replica | primary | [Normal](#protocol-normal), [Repair WAL](#protocol-repair-wal) |
14
- | `reply` | primary | client | [Normal](#protocol-normal) |
15
- | `commit` | primary | backup | [Normal](#protocol-normal) |
16
- | `start_view_change` | replica | all replicas | [Start-View-Change](#protocol-start-view-change) |
17
- | `do_view_change` | replica | all replicas | [View-Change](#protocol-view-change) |
18
- | `start_view` | primary | backup | [Request/Start View](#protocol-request-start-view) |
19
- | `request_start_view` | backup | primary | [Request/Start View](#protocol-request-start-view) |
20
- | `request_headers` | replica | replica | [Repair Journal](#protocol-repair-journal) |
21
- | `request_prepare` | replica | replica | [Repair WAL](#protocol-repair-wal) |
22
- | `headers` | replica | replica | [Repair Journal](#protocol-repair-journal) |
23
- | `nack_prepare` | backup | primary | [Repair WAL](#protocol-repair-wal) |
24
- | `eviction` | primary | client | [Client](#protocol-client) |
25
-
26
- ### Recovery
27
-
28
- Unlike [VRR](https://pmg.csail.mit.edu/papers/vr-revisited.pdf), TigerBeetle does not implement Recovery Protocol (see §4.3).
29
- Instead, replicas persist their VSR state to the superblock.
30
- This ensures that a recovering replica never backtracks to an older view (from the point of view of the cluster).
31
-
32
- ## Protocol: Ping (Replica-Replica)
33
-
34
- Replicas send `command=ping`/`command=pong` messages to one another to synchronize clocks.
35
-
36
- ## Protocol: Ping (Replica-Client)
37
-
38
- Clients send `command=ping_client` (and receive `command=pong_client`) messages to (from) replicas to learn the cluster's current view.
39
-
40
- ## Protocol: Normal
41
-
42
- Normal protocol prepares and commits requests (from clients) and sends replies (to clients).
43
-
44
- 1. The client sends a `command=request` message to the primary. (If the client's view is outdated, the receiver will forward the message on to the actual primary).
45
- 2. The primary converts the `command=request` to a `command=prepare` (assigning it an `op` and `timestamp`).
46
- 3. Each replica (in a chain beginning with the primary) performs the following steps concurrently:
47
- - Write the prepare to the WAL.
48
- - Forward the prepare to the next replica in the chain.
49
- 4. Each replica sends a `command=prepare_ok` message to the primary once it has written the prepare to the WAL.
50
- 5. When a primary collects a [replication quorum](#quorums) of `prepare_ok`s _and_ it has committed all preceding prepares, it commits the prepare.
51
- 6. The primary replies to the client.
52
- 7. The backups are informed that the prepare was committed by either:
53
- - a subsequent prepare, or
54
- - a periodic `command=commit` heartbeat message.
55
-
56
- ```mermaid
57
- sequenceDiagram
58
- participant C0 as Client
59
- participant R0 as Replica 0 (primary)
60
- participant R1 as Replica 1 (backup)
61
- participant R2 as Replica 2 (backup)
62
-
63
- C0->>R0: Request A
64
-
65
- R0->>+R0: Prepare A
66
- R0->>+R1: Prepare A
67
- R1->>+R2: Prepare A
68
-
69
- R0->>-R0: Prepare-Ok A
70
- R1->>-R0: Prepare-Ok A
71
- R0->>C0: Reply A
72
- R2->>-R0: Prepare-Ok A
73
- ```
74
-
75
- See also:
76
-
77
- - [VRR](https://pmg.csail.mit.edu/papers/vr-revisited.pdf) §4.1
78
-
79
- ## Protocol: Start-View-Change
80
-
81
- Start-View-Change (SVC) protocol initiates [view-changes](#protocol-view-change) with minimal disruption.
82
-
83
- Unlike the Start-View-Change described in [VRR](https://pmg.csail.mit.edu/papers/vr-revisited.pdf) §4.2, this protocol runs in both `status=normal` and `status=view_change` (not just `status=view_change`).
84
-
85
- 1. Depending on the replica's status:
86
- - `status=normal` & primary: When the replica has not recently received a `prepare_ok` (and it has a prepare in flight), pause broadcasting `command=commit`.
87
- - `status=normal` & backup: When the replica has not recently received a `command=commit`, broadcast `command=start_view_change` to all replicas (including self).
88
- - `status=view_change`: If the replica has not completed a view-change recently, send a `command=start_view_change` to all replicas (including self).
89
- 2. (Periodically retry sending the SVC).
90
- 3. If the backup receives a `command=commit` or changes views (respectively), stop the `command=start_view_change` retries.
91
- 4. If the replica collects a [view-change quorum](#quorums) of SVC messages, transition to `status=view_change` for the next view. (That is, increment the replica's view and start sending a DVC).
92
-
93
- This protocol approach enables liveness under asymmetric network partitions. For example, a replica which can send to the cluster but not receive may send SVCs, but if the remainder of the cluster is healthy, they will never achieve a quorum, so the view is stable. When the partition heals, the formerly-isolated replica may rejoin the original view (if it was isolated in `status=normal`) or a new view (if it was isolated in `status=view_change`).
94
-
95
- See also:
96
-
97
- - [Raft does not Guarantee Liveness in the face of Network Faults](https://decentralizedthoughts.github.io/2020-12-12-raft-liveness-full-omission/) ("PreVote and CheckQuorum")
98
- - ["Consensus: Bridging Theory and Practice"](https://web.stanford.edu/~ouster/cgi-bin/papers/OngaroPhD.pdf) §6.2 "Leaders" describes periodically committing a heartbeat to detect stale leaders.
99
-
100
- ## Protocol: View-Change
101
-
102
- A replica sends `command=do_view_change` to all replicas, with the `view` it is attempting to start.
103
- - The _primary_ of the `view` collects a [view-change quorum](#quorums) of DVCs.
104
- - The _backup_ of the `view` uses to `do_view_change` to updates its current `view` (transitioning to `status=view_change`).
105
-
106
- DVCs include headers from prepares which are:
107
- - _present_ (in the replica's WAL) and valid
108
- - _missing_ (never written to the replica's WAL)
109
- - _corrupt_ (in the replica's WAL)
110
-
111
- These cases are distinguished during [WAL repair](#protocol-repair-wal).
112
-
113
- When the primary collects its quorum:
114
- 1. The primary installs the headers to its suffix.
115
- 2. Then the primary repairs its headers. ([Protocol: Repair Journal](#protocol-repair-journal)).
116
- 3. Then the primary repairs its prepares. ([Protocol: Repair WAL](#protocol-repair-wal)) (and potentially truncates uncommitted ops).
117
- 4. Then primary commits all prepares which are not known to be uncommitted.
118
- 5. Then the primary transitions to `status=normal` and broadcasts a `command=start_view`.
119
-
120
- ## Protocol: Request/Start View
121
-
122
- ### `request_start_view`
123
-
124
- A backup sends a `command=request_start_view` to the primary of a view when any of the following occur:
125
-
126
- - the backup learns about a newer view via a `command=commit` message, or
127
- - the backup learns about a newer view via a `command=prepare` message, or
128
- - a replica recovers to `status=recovering_head`
129
-
130
- ### `start_view`
131
-
132
- When a `status=normal` primary receives `command=request_start_view`, it replies with a `command=start_view`.
133
- `command=start_view` includes the view's current suffix — the headers of the latest messages in the view.
134
-
135
- Upon receiving a `start_view` for the new view, the backup installs the suffix, transitions to `status=normal`, and begins repair.
136
-
137
- ## Protocol: Repair Journal
138
-
139
- `request_headers` and `headers` repair gaps or breaks in a replica's journal headers.
140
- Repaired headers are a prerequisite for [repairing prepares](#protocol-repair-wal).
141
-
142
- Because the headers are repaired backwards (from the head) by hash-chaining, it is safe for both backups and transitioning primaries.
143
-
144
- Gaps/breaks in a replica's journal headers may occur:
145
-
146
- - On a backup, receiving nonconsecutive ops, leaving a gap in its headers.
147
- - On a backup, which has not finished repair.
148
- - On a new primary during a view-change, which has not finished repair.
149
-
150
- ## Protocol: Repair WAL
151
-
152
- The replica's journal tracks which prepares the WAL requires — i.e. headers for which either:
153
- - no prepare was ever received, or
154
- - the prepare was received and written, but was since discovered to be corrupt
155
-
156
- During repair, missing/damaged prepares are requested & repaired chronologically, which:
157
- - improves the chances that older entries will be available, i.e. not yet overwritten
158
- - enables better pipelining of repair and commit.
159
-
160
- In response to a `request_prepare`:
161
-
162
- - Reply the `command=prepare` with the requested prepare, if available and valid.
163
- - Reply `command=nack_prepare` if the request origin is the primary of the ongoing view-change and we never received the prepare. (This enables the primary to truncate uncommitted messages and remain available).
164
- - Otherwise do not reply. (e.g. the corresponding slot in the WAL is corrupt)
165
-
166
- Per [PAR's CTRL Protocol](https://www.usenix.org/system/files/conference/fast18/fast18-alagappan.pdf), we do not nack corrupt entries, since they _might_ be the prepare being requested.
167
-
168
- ## Protocol: Client
169
-
170
- 1. Client sends `command=request operation=register` to registers with the cluster by starting a new request-reply hashchain. (See also: [Protocol: Normal](#protocol-normal)).
171
- 2. Client receives `command=reply operation=register` from the cluster. (If the cluster is at the maximum number of clients, it evicts the oldest).
172
- 3. Repeat:
173
- 1. Send `command=request` to cluster.
174
- 2. If the client has been evicted, receive `command=eviction` from the cluster. (The client must re-register before sending more requests.)
175
- 3. If the client has not been evicted, receive `command=reply` from cluster.
176
-
177
- See also:
178
-
179
- - [Integration: Client Session Lifecycle](../../docs/usage/integration/md#client-session-lifecycle)
180
- - [Integration: Client Session Eviction](../../docs/usage/integration/md#client-session-eviction)
181
-
182
- ## Protocol: Repair Grid (Backup)
183
-
184
- TODO (Unimplemented)
185
-
186
- ## Protocol: Repair: State Transfer
187
-
188
- TODO (Unimplemented)
189
-
190
- ## Protocol: Reconfiguration
191
-
192
- TODO (Unimplemented)
193
-
194
- # Quorums
195
-
196
- - The _replication quorum_ is the minimum number of replicas required to complete a commit.
197
- - The _view-change quorum_ is the minimum number of replicas required to complete a view-change.
198
-
199
- With the default configuration:
200
-
201
- | **Replica Count** | 1 | 2 | 3 | 4 | 5 | 6 |
202
- | ---------------------: | --: | -: | -: | -: | -: | -: |
203
- | **Replication Quorum** | 1 | 2 | 2 | 3 | 3 | 3 |
204
- | **View-Change Quorum** | 1 | 2 | 2 | 3 | 3 | 4 |
205
-
206
- See also:
207
-
208
- - `constants.quorum_replication_max` for configuration.
209
- - [Flexible Paxos](https://fpaxos.github.io/)