tigerbeetle-node 0.4.3 → 0.5.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.
- package/README.md +20 -4
- package/dist/benchmark.js.map +1 -1
- package/dist/index.d.ts +18 -16
- package/dist/index.js +35 -13
- package/dist/index.js.map +1 -1
- package/dist/test.js +12 -0
- package/dist/test.js.map +1 -1
- package/package.json +1 -1
- package/src/benchmark.ts +2 -2
- package/src/index.ts +29 -4
- package/src/node.zig +103 -2
- package/src/test.ts +14 -0
- package/src/tigerbeetle/scripts/install.sh +1 -1
- package/src/tigerbeetle/scripts/install_zig.bat +109 -0
- package/src/tigerbeetle/scripts/vopr.bat +48 -0
- package/src/tigerbeetle/src/benchmark.zig +2 -2
- package/src/tigerbeetle/src/demo.zig +8 -0
- package/src/tigerbeetle/src/demo_07_lookup_transfers.zig +8 -0
- package/src/tigerbeetle/src/io.zig +2 -2
- package/src/tigerbeetle/src/io_darwin.zig +4 -0
- package/src/tigerbeetle/src/message_bus.zig +3 -3
- package/src/tigerbeetle/src/ring_buffer.zig +135 -68
- package/src/tigerbeetle/src/state_machine.zig +808 -14
- package/src/tigerbeetle/src/test/state_checker.zig +1 -1
- package/src/tigerbeetle/src/test/storage.zig +16 -0
- package/src/tigerbeetle/src/tigerbeetle.zig +0 -1
- package/src/tigerbeetle/src/vsr/client.zig +4 -4
- package/src/tigerbeetle/src/vsr/replica.zig +2 -2
|
@@ -86,7 +86,7 @@ pub const StateChecker = struct {
|
|
|
86
86
|
// The replica has transitioned to state `b` that is not yet in the history.
|
|
87
87
|
// Check if this is a valid new state based on all currently inflight client requests.
|
|
88
88
|
for (state_checker.client_requests) |*queue| {
|
|
89
|
-
if (queue.
|
|
89
|
+
if (queue.head_ptr()) |input| {
|
|
90
90
|
if (b == StateMachine.hash(state_checker.state, std.mem.asBytes(input))) {
|
|
91
91
|
const transitions_executed = state_checker.history.get(a).?;
|
|
92
92
|
if (transitions_executed < state_checker.transitions) {
|
|
@@ -287,6 +287,7 @@ pub const Storage = struct {
|
|
|
287
287
|
// We need to ensure there is message_size_max fault-free padding
|
|
288
288
|
// between faulty areas of memory so that a single message
|
|
289
289
|
// cannot straddle the corruptable areas of a majority of replicas.
|
|
290
|
+
comptime assert(config.replicas_max == 6);
|
|
290
291
|
switch (replica_count) {
|
|
291
292
|
1 => {
|
|
292
293
|
// If there is only one replica in the cluster, storage faults are not recoverable.
|
|
@@ -332,6 +333,21 @@ pub const Storage = struct {
|
|
|
332
333
|
out[3] = .{ .first_offset = 2 * message_size_max, .period = 6 * message_size_max };
|
|
333
334
|
out[4] = .{ .first_offset = 4 * message_size_max, .period = 6 * message_size_max };
|
|
334
335
|
},
|
|
336
|
+
6 => {
|
|
337
|
+
// 0123456789
|
|
338
|
+
// 0X X
|
|
339
|
+
// 1X X
|
|
340
|
+
// 2 X X
|
|
341
|
+
// 3 X X
|
|
342
|
+
// 4 X X
|
|
343
|
+
// 5 X X
|
|
344
|
+
out[0] = .{ .first_offset = 0 * message_size_max, .period = 6 * message_size_max };
|
|
345
|
+
out[1] = .{ .first_offset = 0 * message_size_max, .period = 6 * message_size_max };
|
|
346
|
+
out[2] = .{ .first_offset = 2 * message_size_max, .period = 6 * message_size_max };
|
|
347
|
+
out[3] = .{ .first_offset = 2 * message_size_max, .period = 6 * message_size_max };
|
|
348
|
+
out[4] = .{ .first_offset = 4 * message_size_max, .period = 6 * message_size_max };
|
|
349
|
+
out[5] = .{ .first_offset = 4 * message_size_max, .period = 6 * message_size_max };
|
|
350
|
+
},
|
|
335
351
|
else => unreachable,
|
|
336
352
|
}
|
|
337
353
|
|
|
@@ -249,7 +249,6 @@ pub const CommitTransferResult = packed enum(u32) {
|
|
|
249
249
|
transfer_not_found,
|
|
250
250
|
transfer_not_two_phase_commit,
|
|
251
251
|
transfer_expired,
|
|
252
|
-
already_auto_committed,
|
|
253
252
|
already_committed,
|
|
254
253
|
already_committed_but_accepted,
|
|
255
254
|
already_committed_but_rejected,
|
|
@@ -279,7 +279,7 @@ pub fn Client(comptime StateMachine: type, comptime MessageBus: type) type {
|
|
|
279
279
|
return;
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
if (self.request_queue.
|
|
282
|
+
if (self.request_queue.head_ptr()) |inflight| {
|
|
283
283
|
if (reply.header.request < inflight.message.header.request) {
|
|
284
284
|
log.debug("{}: on_reply: ignoring (request {} < {})", .{
|
|
285
285
|
self.id,
|
|
@@ -334,7 +334,7 @@ pub fn Client(comptime StateMachine: type, comptime MessageBus: type) type {
|
|
|
334
334
|
|
|
335
335
|
// We must process the next request before releasing control back to the callback.
|
|
336
336
|
// Otherwise, requests may run through send_request_for_the_first_time() more than once.
|
|
337
|
-
if (self.request_queue.
|
|
337
|
+
if (self.request_queue.head_ptr()) |next_request| {
|
|
338
338
|
self.send_request_for_the_first_time(next_request.message);
|
|
339
339
|
}
|
|
340
340
|
|
|
@@ -363,7 +363,7 @@ pub fn Client(comptime StateMachine: type, comptime MessageBus: type) type {
|
|
|
363
363
|
fn on_request_timeout(self: *Self) void {
|
|
364
364
|
self.request_timeout.backoff(&self.prng);
|
|
365
365
|
|
|
366
|
-
const message = self.request_queue.
|
|
366
|
+
const message = self.request_queue.head_ptr().?.message;
|
|
367
367
|
assert(message.header.command == .request);
|
|
368
368
|
assert(message.header.request < self.request_number);
|
|
369
369
|
assert(message.header.checksum == self.parent);
|
|
@@ -478,7 +478,7 @@ pub fn Client(comptime StateMachine: type, comptime MessageBus: type) type {
|
|
|
478
478
|
}
|
|
479
479
|
|
|
480
480
|
fn send_request_for_the_first_time(self: *Self, message: *Message) void {
|
|
481
|
-
assert(self.request_queue.
|
|
481
|
+
assert(self.request_queue.head_ptr().?.message == message);
|
|
482
482
|
|
|
483
483
|
assert(message.header.command == .request);
|
|
484
484
|
assert(message.header.parent == 0);
|
|
@@ -1467,7 +1467,7 @@ pub fn Replica(
|
|
|
1467
1467
|
assert(self.status == .normal);
|
|
1468
1468
|
assert(self.leader());
|
|
1469
1469
|
|
|
1470
|
-
const prepare = self.pipeline.
|
|
1470
|
+
const prepare = self.pipeline.head_ptr().?;
|
|
1471
1471
|
assert(prepare.message.header.command == .prepare);
|
|
1472
1472
|
|
|
1473
1473
|
if (prepare.ok_quorum_received) {
|
|
@@ -1925,7 +1925,7 @@ pub fn Replica(
|
|
|
1925
1925
|
assert(self.leader());
|
|
1926
1926
|
assert(self.pipeline.count > 0);
|
|
1927
1927
|
|
|
1928
|
-
while (self.pipeline.
|
|
1928
|
+
while (self.pipeline.head_ptr()) |prepare| {
|
|
1929
1929
|
assert(self.pipeline.count > 0);
|
|
1930
1930
|
assert(self.commit_min == self.commit_max);
|
|
1931
1931
|
assert(self.commit_max + self.pipeline.count == self.op);
|