@delali/sirannon-db 0.3.4-next.62 → 0.3.4
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 +79 -56
- package/dist/backup/index.d.ts +44 -45
- package/dist/backup/index.mjs +7 -7
- package/dist/backup-scheduler/index.d.ts +42 -41
- package/dist/backup-scheduler/index.mjs +4 -4
- package/dist/baseline-Co3iIsN_.d.ts +19 -0
- package/dist/change-tracker-DqCdeEyx.d.ts +128 -0
- package/dist/{chunk-VOSJBZ6Q.mjs → chunk-2ES3DT4A.mjs} +71 -33
- package/dist/{chunk-6CMCO7S4.mjs → chunk-2O3PP4CF.mjs} +1 -1
- package/dist/{chunk-E7Q7HE46.mjs → chunk-3BZLZ47R.mjs} +26 -26
- package/dist/chunk-4KASJKKK.mjs +2501 -0
- package/dist/{chunk-MYNI2WFS.mjs → chunk-52XW3Z76.mjs} +40 -8
- package/dist/chunk-55YRLSM2.mjs +57 -0
- package/dist/{chunk-KDAHYFW7.mjs → chunk-6AOJCNRU.mjs} +5 -5
- package/dist/{chunk-KXTYR2OQ.mjs → chunk-A3PHCO6W.mjs} +39 -111
- package/dist/chunk-ADNWEHGZ.mjs +299 -0
- package/dist/{chunk-2QLXDHAP.mjs → chunk-BLMRNSUG.mjs} +11 -2
- package/dist/chunk-BVMZJOVM.mjs +5 -0
- package/dist/{chunk-IWGIYDMZ.mjs → chunk-BZWDPF4G.mjs} +1 -1
- package/dist/{chunk-YVF2ZJTE.mjs → chunk-CZL4D3BM.mjs} +1 -1
- package/dist/{chunk-7SC2TZAS.mjs → chunk-DX4WGJL7.mjs} +2 -2
- package/dist/{chunk-45MKELYA.mjs → chunk-ESTZZPT5.mjs} +132 -13
- package/dist/{chunk-QP5L5DFJ.mjs → chunk-FJPR2CJX.mjs} +3 -3
- package/dist/chunk-HR7K3GZW.mjs +36 -0
- package/dist/{chunk-LXCGPZPA.mjs → chunk-IEKIYO4V.mjs} +1 -1
- package/dist/{chunk-TUD5CJ76.mjs → chunk-KB4OLJAD.mjs} +26 -19
- package/dist/{chunk-PBRXXISQ.mjs → chunk-KINDFBQP.mjs} +3 -2
- package/dist/{chunk-E6IMX7RS.mjs → chunk-KJLNYOOL.mjs} +2 -2
- package/dist/{chunk-BTTFW4Z4.mjs → chunk-KU32OT4H.mjs} +2 -10
- package/dist/{chunk-JQWGHSEH.mjs → chunk-NVSQ2T5Q.mjs} +71 -70
- package/dist/{chunk-W4EUTJNT.mjs → chunk-NZGSDALX.mjs} +94 -96
- package/dist/{chunk-U445A3C4.mjs → chunk-QGVRRKB2.mjs} +1 -1
- package/dist/{chunk-GYCEJNU4.mjs → chunk-R7GBXNTO.mjs} +1 -1
- package/dist/{chunk-7C36BCSN.mjs → chunk-VDN6FHU4.mjs} +1 -1
- package/dist/{chunk-6IYS4WLH.mjs → chunk-VO3ZWA2G.mjs} +142 -115
- package/dist/chunk-WOMADPM4.mjs +12 -0
- package/dist/{chunk-OUSWVNWT.mjs → chunk-YCMB6GR4.mjs} +1 -1
- package/dist/{chunk-YNTDOFTN.mjs → chunk-YW7IKQ7T.mjs} +1 -1
- package/dist/{chunk-M2BEAH5I.mjs → chunk-ZN4HI5FK.mjs} +126 -72
- package/dist/{chunk-SBL6GN43.mjs → chunk-ZYWI45EN.mjs} +1 -1
- package/dist/client/index.d.ts +135 -137
- package/dist/client/index.mjs +177 -82
- package/dist/client/topology.d.ts +31 -31
- package/dist/client/topology.mjs +42 -23
- package/dist/client-base-BxTocU1x.d.ts +398 -0
- package/dist/client-streams-YKANXMWO.mjs +112 -0
- package/dist/codegen/cli.mjs +4 -4
- package/dist/codegen/index.d.ts +36 -29
- package/dist/codegen/index.mjs +4 -4
- package/dist/core/index.d.ts +130 -115
- package/dist/core/index.mjs +387 -297
- package/dist/core/writer-worker.mjs +3 -3
- package/dist/database-CGDsXW1K.d.ts +959 -0
- package/dist/database-backup-DcLhxoa1.d.ts +143 -0
- package/dist/driver/better-sqlite3.d.ts +11 -10
- package/dist/driver/better-sqlite3.mjs +11 -11
- package/dist/driver/bun.d.ts +9 -8
- package/dist/driver/expo.d.ts +6 -7
- package/dist/driver/node.d.ts +11 -10
- package/dist/driver/node.mjs +13 -11
- package/dist/driver/wa-sqlite.d.ts +6 -6
- package/dist/errors-CJUkQ-KL.d.ts +199 -0
- package/dist/file-migrations/index.d.ts +20 -18
- package/dist/file-migrations/index.mjs +3 -3
- package/dist/forward-rpc-VRWFZXHN.mjs +44 -0
- package/dist/operation-registry-CGhNT-Sn.d.ts +96 -0
- package/dist/primary-wins-CHNOYuN7.d.ts +81 -0
- package/dist/protocol-DFpNNsIT.d.ts +153 -0
- package/dist/query-types-5B02ixH0.d.ts +129 -0
- package/dist/react/index.d.ts +22 -22
- package/dist/replication/coordinator/etcd.d.ts +37 -31
- package/dist/replication/coordinator/etcd.mjs +296 -131
- package/dist/replication/index.d.ts +201 -161
- package/dist/replication/index.mjs +630 -529
- package/dist/restore-options-CH8mE-Tb.d.ts +84 -0
- package/dist/server/index.d.ts +201 -191
- package/dist/server/index.mjs +736 -619
- package/dist/server-options-aYtCkefX.d.ts +317 -0
- package/dist/server-streams-24XL4T43.mjs +254 -0
- package/dist/sirannon-J3EgPVD7.d.ts +179 -0
- package/dist/transport/grpc.d.ts +37 -24
- package/dist/transport/grpc.mjs +83 -3199
- package/dist/transport/memory.d.ts +25 -26
- package/dist/transport/memory.mjs +18 -9
- package/dist/types-BrAiDGOb.d.ts +505 -0
- package/dist/types-CEJG0eFS.d.ts +88 -0
- package/dist/types-Dc8oWlxj.d.ts +1580 -0
- package/dist/types-DqODKeOq.d.ts +123 -0
- package/dist/types-guEKSzMr.d.ts +367 -0
- package/package.json +7 -7
- package/dist/baseline-D93hcIEE.d.ts +0 -17
- package/dist/change-tracker-CjRFuZdB.d.ts +0 -144
- package/dist/client-base-Cmd9EVme.d.ts +0 -397
- package/dist/database-BLQvqjsw.d.ts +0 -917
- package/dist/database-backup-B7oszQ2n.d.ts +0 -141
- package/dist/errors-Dei4GdBb.d.ts +0 -196
- package/dist/operation-registry-oiPuSYI6.d.ts +0 -94
- package/dist/primary-wins-B0np8JS3.d.ts +0 -85
- package/dist/protocol-HI-nY8DD.d.ts +0 -152
- package/dist/query-types-p1liOP-b.d.ts +0 -127
- package/dist/restore-options-CksYsH1l.d.ts +0 -83
- package/dist/server-options-Bj5iJnjx.d.ts +0 -292
- package/dist/sirannon-BPxC5tC2.d.ts +0 -178
- package/dist/types-B0EhgDbr.d.ts +0 -340
- package/dist/types-CbjfRwrK.d.ts +0 -499
- package/dist/types-CjhxcjhA.d.ts +0 -123
- package/dist/types-DPSmjU54.d.ts +0 -1518
- package/dist/types-DTO4CYhW.d.ts +0 -88
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { verifyBackupRecord } from './chunk-
|
|
2
|
-
import { BackupManager, BackupScheduler, DEFAULT_PIECE_BYTES, sendFileInPieces } from './chunk-
|
|
3
|
-
import { DEFAULT_BACKUP_NAME_PREFIX, defaultStagingDir, DEFAULT_CAPTURE_INTERVAL_MS, DEFAULT_FULL_COPY_INTERVAL_MS } from './chunk-
|
|
1
|
+
import { verifyBackupRecord } from './chunk-DX4WGJL7.mjs';
|
|
2
|
+
import { BackupManager, BackupScheduler, DEFAULT_PIECE_BYTES, sendFileInPieces } from './chunk-NVSQ2T5Q.mjs';
|
|
3
|
+
import { DEFAULT_BACKUP_NAME_PREFIX, defaultStagingDir, DEFAULT_CAPTURE_INTERVAL_MS, DEFAULT_FULL_COPY_INTERVAL_MS } from './chunk-IEKIYO4V.mjs';
|
|
4
4
|
import { WORKER_CANCELLED_CODE, WORKER_COPY_STOPPED_CODE, deserializeError } from './chunk-MVSES6MS.mjs';
|
|
5
|
-
import { readCycleState, writeCycleState, removeCycleState, stagedCapturePath, captureAndCheckpointTurn } from './chunk-
|
|
6
|
-
import { checkpointLog } from './chunk-
|
|
7
|
-
import { logPathFor } from './chunk-
|
|
8
|
-
import { destinationWithDeadline, DEFAULT_DESTINATION_TIMEOUT_MS, reportQuietly } from './chunk-
|
|
9
|
-
import { DEFAULT_CHAIN_NAME, readBackupChains, appendChainRecord, appendChainHead, readChainHeadAt, readChainHeads } from './chunk-
|
|
5
|
+
import { readCycleState, writeCycleState, removeCycleState, stagedCapturePath, captureAndCheckpointTurn } from './chunk-6AOJCNRU.mjs';
|
|
6
|
+
import { checkpointLog } from './chunk-QGVRRKB2.mjs';
|
|
7
|
+
import { logPathFor } from './chunk-KJLNYOOL.mjs';
|
|
8
|
+
import { destinationWithDeadline, DEFAULT_DESTINATION_TIMEOUT_MS, reportQuietly } from './chunk-R7GBXNTO.mjs';
|
|
9
|
+
import { DEFAULT_CHAIN_NAME, readBackupChains, appendChainRecord, appendChainHead, readChainHeadAt, readChainHeads } from './chunk-CZL4D3BM.mjs';
|
|
10
10
|
import { randomHex } from './chunk-QBBLSQHQ.mjs';
|
|
11
|
-
import { SirannonError, ExtensionError } from './chunk-
|
|
11
|
+
import { SirannonError, ExtensionError } from './chunk-KINDFBQP.mjs';
|
|
12
12
|
import { Worker } from 'worker_threads';
|
|
13
13
|
import { existsSync } from 'fs';
|
|
14
14
|
import { resolve, dirname, join, sep } from 'path';
|
|
@@ -562,7 +562,7 @@ var BackupCycleStatusRecorder = class {
|
|
|
562
562
|
latestRun;
|
|
563
563
|
latestSkip;
|
|
564
564
|
latestError;
|
|
565
|
-
/** Marks a turn as
|
|
565
|
+
/** Marks a turn as in progress and clears the progress that the previous turn recorded. */
|
|
566
566
|
turnStarted() {
|
|
567
567
|
this.turnRunning = true;
|
|
568
568
|
this.turnStartedAt = Date.now();
|
|
@@ -574,24 +574,24 @@ var BackupCycleStatusRecorder = class {
|
|
|
574
574
|
this.turnStartedAt = 0;
|
|
575
575
|
this.latestProgress = void 0;
|
|
576
576
|
}
|
|
577
|
-
/** Records
|
|
577
|
+
/** Records the progress of the current turn. */
|
|
578
578
|
progressed(progress) {
|
|
579
579
|
this.latestProgress = progress;
|
|
580
580
|
}
|
|
581
|
-
/** Records
|
|
581
|
+
/** Records the report of a finished backup. */
|
|
582
582
|
ran(report) {
|
|
583
583
|
this.latestRun = report;
|
|
584
584
|
}
|
|
585
|
-
/** Records a turn
|
|
585
|
+
/** Records a skipped turn. */
|
|
586
586
|
skipped(skip) {
|
|
587
587
|
this.latestSkip = skip;
|
|
588
588
|
}
|
|
589
589
|
/**
|
|
590
|
-
* Records a failure
|
|
591
|
-
*
|
|
590
|
+
* Records a failure with its error code, the progress of the current backup,
|
|
591
|
+
* and the chain that the cycle extends.
|
|
592
592
|
*
|
|
593
|
-
* @param err -
|
|
594
|
-
* @param chainId - The chain the cycle
|
|
593
|
+
* @param err - The error that stops the turn.
|
|
594
|
+
* @param chainId - The chain that the cycle extends, where it holds one.
|
|
595
595
|
*/
|
|
596
596
|
failed(err, chainId) {
|
|
597
597
|
const at = Date.now();
|
|
@@ -605,10 +605,10 @@ var BackupCycleStatusRecorder = class {
|
|
|
605
605
|
};
|
|
606
606
|
}
|
|
607
607
|
/**
|
|
608
|
-
*
|
|
608
|
+
* Returns everything recorded so far.
|
|
609
609
|
*
|
|
610
|
-
* @param chainId - The chain the cycle
|
|
611
|
-
* @returns What the cycle is doing, and
|
|
610
|
+
* @param chainId - The chain that the cycle extends, where it holds one.
|
|
611
|
+
* @returns What the cycle is doing now, and the outcome of its recent turns.
|
|
612
612
|
*/
|
|
613
613
|
read(chainId) {
|
|
614
614
|
return {
|
|
@@ -631,24 +631,24 @@ var BackupTurnLog = class {
|
|
|
631
631
|
record = new BackupCycleStatusRecorder();
|
|
632
632
|
announced = /* @__PURE__ */ new Set();
|
|
633
633
|
/**
|
|
634
|
-
* Records a finished
|
|
634
|
+
* Records a finished backup and passes its report to the caller.
|
|
635
635
|
*
|
|
636
|
-
* @param report -
|
|
636
|
+
* @param report - The report of the backup.
|
|
637
637
|
*/
|
|
638
638
|
ran(report) {
|
|
639
639
|
this.record.ran(report);
|
|
640
640
|
reportQuietly(this.audience.onRun, report);
|
|
641
641
|
}
|
|
642
642
|
/**
|
|
643
|
-
* Records
|
|
643
|
+
* Records the progress of the current backup and passes it to the caller.
|
|
644
644
|
*
|
|
645
|
-
* @param progress - The counters that
|
|
645
|
+
* @param progress - The current counters of that backup.
|
|
646
646
|
*/
|
|
647
647
|
progressed(progress) {
|
|
648
648
|
this.record.progressed(progress);
|
|
649
649
|
reportQuietly(this.audience.onProgress, progress);
|
|
650
650
|
}
|
|
651
|
-
/** Marks a turn as
|
|
651
|
+
/** Marks a turn as in progress, and clears the failures that the previous turn reported. */
|
|
652
652
|
turnStarted() {
|
|
653
653
|
this.announced.clear();
|
|
654
654
|
this.record.turnStarted();
|
|
@@ -658,10 +658,10 @@ var BackupTurnLog = class {
|
|
|
658
658
|
this.record.turnFinished();
|
|
659
659
|
}
|
|
660
660
|
/**
|
|
661
|
-
* Records a failure as the turn
|
|
661
|
+
* Records a failure as the outcome of the turn and passes it to the caller.
|
|
662
662
|
*
|
|
663
|
-
* @param err -
|
|
664
|
-
* @param chainId - The chain to record
|
|
663
|
+
* @param err - The error that stops the turn.
|
|
664
|
+
* @param chainId - The chain to record the failure against, where the cycle holds one.
|
|
665
665
|
*/
|
|
666
666
|
failed(err, chainId) {
|
|
667
667
|
this.announced.add(err);
|
|
@@ -670,19 +670,19 @@ var BackupTurnLog = class {
|
|
|
670
670
|
reportQuietly(this.audience.onError, failure);
|
|
671
671
|
}
|
|
672
672
|
/**
|
|
673
|
-
*
|
|
673
|
+
* Returns whether this turn has already reported a given failure to the caller.
|
|
674
674
|
*
|
|
675
675
|
* @param err - The failure to look for.
|
|
676
|
-
* @returns Whether
|
|
676
|
+
* @returns Whether this turn has already reported that failure.
|
|
677
677
|
*/
|
|
678
678
|
hasAnnounced(err) {
|
|
679
679
|
return this.announced.has(err);
|
|
680
680
|
}
|
|
681
681
|
/**
|
|
682
|
-
* Records a turn
|
|
683
|
-
*
|
|
682
|
+
* Records a skipped turn and passes it to the caller, with the size of the
|
|
683
|
+
* write-ahead log on this node at the skip.
|
|
684
684
|
*
|
|
685
|
-
* @param skip -
|
|
685
|
+
* @param skip - The reason that the cycle skips the turn.
|
|
686
686
|
*/
|
|
687
687
|
async skipped(skip) {
|
|
688
688
|
const held = await uncapturedLogBytes(this.logPath);
|
|
@@ -691,10 +691,10 @@ var BackupTurnLog = class {
|
|
|
691
691
|
reportQuietly(this.audience.onSkip, passed);
|
|
692
692
|
}
|
|
693
693
|
/**
|
|
694
|
-
*
|
|
694
|
+
* Returns everything recorded so far.
|
|
695
695
|
*
|
|
696
|
-
* @param chainId - The chain the cycle
|
|
697
|
-
* @returns What the cycle is doing, and
|
|
696
|
+
* @param chainId - The chain that the cycle extends, where it holds one.
|
|
697
|
+
* @returns What the cycle is doing now, and the outcome of its recent turns.
|
|
698
698
|
*/
|
|
699
699
|
read(chainId) {
|
|
700
700
|
return this.record.read(chainId);
|
|
@@ -705,10 +705,10 @@ var BackupTurnLog = class {
|
|
|
705
705
|
var BackupCycleTimer = class {
|
|
706
706
|
handle = null;
|
|
707
707
|
/**
|
|
708
|
-
* Starts
|
|
709
|
-
* only when
|
|
708
|
+
* Starts the timer. At an interval of zero or less, the timer stays off and
|
|
709
|
+
* the cycle takes a turn only when a caller requests one.
|
|
710
710
|
*
|
|
711
|
-
* @param intervalMs -
|
|
711
|
+
* @param intervalMs - The number of milliseconds between one turn and the next.
|
|
712
712
|
* @param tick - Called on every interval.
|
|
713
713
|
*/
|
|
714
714
|
arm(intervalMs, tick) {
|
|
@@ -717,7 +717,7 @@ var BackupCycleTimer = class {
|
|
|
717
717
|
this.handle = setInterval(tick, intervalMs);
|
|
718
718
|
this.handle.unref?.();
|
|
719
719
|
}
|
|
720
|
-
/** Stops
|
|
720
|
+
/** Stops the timer. */
|
|
721
721
|
disarm() {
|
|
722
722
|
if (!this.handle) return;
|
|
723
723
|
clearInterval(this.handle);
|
|
@@ -727,10 +727,10 @@ var BackupCycleTimer = class {
|
|
|
727
727
|
var SerialTurns = class {
|
|
728
728
|
inFlight = Promise.resolve();
|
|
729
729
|
/**
|
|
730
|
-
* Starts an operation once every turn
|
|
730
|
+
* Starts an operation once every turn requested before it settles.
|
|
731
731
|
*
|
|
732
732
|
* @param op - The turn to take.
|
|
733
|
-
* @returns
|
|
733
|
+
* @returns The result of that turn.
|
|
734
734
|
*/
|
|
735
735
|
run(op) {
|
|
736
736
|
const turn = this.inFlight.then(op, op);
|
|
@@ -948,10 +948,10 @@ var BackupCycle = class {
|
|
|
948
948
|
this.preferredNode = request.preferredNode ?? "replica";
|
|
949
949
|
}
|
|
950
950
|
/**
|
|
951
|
-
*
|
|
952
|
-
* full copy, and then repeats on the interval.
|
|
953
|
-
* ordinary turn, so the frames written
|
|
954
|
-
*
|
|
951
|
+
* Resumes the chain that the state file records, or starts a new chain with a
|
|
952
|
+
* full copy, and then repeats the turn on the interval. On a resumed chain,
|
|
953
|
+
* Sirannon takes an ordinary turn straight away, so it sends the frames written
|
|
954
|
+
* while this node was down to the destination before the first interval ends.
|
|
955
955
|
*/
|
|
956
956
|
async start() {
|
|
957
957
|
await mkdir(this.stagingDir, { recursive: true });
|
|
@@ -970,19 +970,19 @@ var BackupCycle = class {
|
|
|
970
970
|
if (!this.stopped) this.timer.arm(this.intervalMs, () => void this.tick());
|
|
971
971
|
}
|
|
972
972
|
/**
|
|
973
|
-
* Takes one turn now.
|
|
973
|
+
* Takes one turn now. In a turn, Sirannon sends any staged capture, reads the
|
|
974
974
|
* frames written since the previous turn, and then checkpoints the log.
|
|
975
975
|
*
|
|
976
|
-
*
|
|
977
|
-
*
|
|
978
|
-
* log
|
|
979
|
-
*
|
|
980
|
-
* turns with nothing left
|
|
976
|
+
* At most one turn waits in the queue. A call during a turn in progress
|
|
977
|
+
* queues one turn after it, and every later call returns that queued turn,
|
|
978
|
+
* which reads the log when it begins and so captures the writes of every one
|
|
979
|
+
* of those callers. Without that limit, repeated calls during a long full
|
|
980
|
+
* copy would build a queue of turns with nothing left to capture.
|
|
981
981
|
*
|
|
982
|
-
*
|
|
983
|
-
* and reports a skip.
|
|
982
|
+
* On a node whose replication group takes its backups from another node, a
|
|
983
|
+
* turn writes nothing and reports a skip.
|
|
984
984
|
*
|
|
985
|
-
* @returns
|
|
985
|
+
* @returns The report of what the turn writes, or undefined where it writes nothing.
|
|
986
986
|
*/
|
|
987
987
|
runOnce() {
|
|
988
988
|
const queued = this.queued;
|
|
@@ -996,9 +996,8 @@ var BackupCycle = class {
|
|
|
996
996
|
return turn;
|
|
997
997
|
}
|
|
998
998
|
/**
|
|
999
|
-
* Stops the cycle
|
|
1000
|
-
* made since the previous turn
|
|
1001
|
-
* closes behind it.
|
|
999
|
+
* Stops the cycle after one final turn, so that Sirannon sends the writes
|
|
1000
|
+
* made since the previous turn to the destination before the database closes.
|
|
1002
1001
|
*/
|
|
1003
1002
|
async stop() {
|
|
1004
1003
|
if (this.stopped) return;
|
|
@@ -1017,7 +1016,7 @@ var BackupCycle = class {
|
|
|
1017
1016
|
});
|
|
1018
1017
|
}
|
|
1019
1018
|
/**
|
|
1020
|
-
*
|
|
1019
|
+
* Returns every chain at the destination.
|
|
1021
1020
|
*
|
|
1022
1021
|
* @returns Every chain, newest first, each with its full copy and its change pieces.
|
|
1023
1022
|
*/
|
|
@@ -1025,34 +1024,33 @@ var BackupCycle = class {
|
|
|
1025
1024
|
return readBackupChains(this.request.destination, this.chainName);
|
|
1026
1025
|
}
|
|
1027
1026
|
/**
|
|
1028
|
-
*
|
|
1029
|
-
* produced.
|
|
1027
|
+
* Returns what the cycle is doing now and the outcome of its recent turns.
|
|
1030
1028
|
*
|
|
1031
|
-
*
|
|
1032
|
-
* the turn, and it answers between turns as well.
|
|
1029
|
+
* It returns straight away, both during a long full copy and between turns.
|
|
1033
1030
|
*
|
|
1034
|
-
* @returns Whether a turn is
|
|
1031
|
+
* @returns Whether a turn is in progress, the progress of that turn, and the last run, skip, and failure.
|
|
1035
1032
|
*/
|
|
1036
1033
|
status() {
|
|
1037
1034
|
return this.turnLog.read(this.state?.chainId);
|
|
1038
1035
|
}
|
|
1039
1036
|
/**
|
|
1040
|
-
* Reads one
|
|
1041
|
-
*
|
|
1037
|
+
* Reads one backup from the destination and checks it against its record in
|
|
1038
|
+
* the chains at that destination.
|
|
1042
1039
|
*
|
|
1043
|
-
* @param name -
|
|
1044
|
-
* @returns The pieces read,
|
|
1040
|
+
* @param name - The name that Sirannon stores the backup under.
|
|
1041
|
+
* @returns The number of pieces read, their total size in bytes, and the fingerprint where the record holds one.
|
|
1045
1042
|
*/
|
|
1046
1043
|
async verify(name) {
|
|
1047
1044
|
return verifyBackupRecord(this.request.destination, await this.chains(), name);
|
|
1048
1045
|
}
|
|
1049
1046
|
/**
|
|
1050
|
-
* Runs one turn and
|
|
1051
|
-
*
|
|
1052
|
-
*
|
|
1053
|
-
*
|
|
1054
|
-
*
|
|
1055
|
-
* backup replaces
|
|
1047
|
+
* Runs one turn and reports to the operator any error that stops it. Some
|
|
1048
|
+
* deeper steps report a failure themselves before they throw it, so this
|
|
1049
|
+
* reports an error only where no step has reported it already, and the
|
|
1050
|
+
* operator receives each failure once. When the turn captures nothing and the
|
|
1051
|
+
* log has grown past the limit, Sirannon then empties the log, and the
|
|
1052
|
+
* resulting report of the writes that no backup holds replaces any failure
|
|
1053
|
+
* that the turn recorded.
|
|
1056
1054
|
*/
|
|
1057
1055
|
runTurn(op) {
|
|
1058
1056
|
return this.turns.run(async () => {
|
|
@@ -1072,7 +1070,7 @@ var BackupCycle = class {
|
|
|
1072
1070
|
}
|
|
1073
1071
|
});
|
|
1074
1072
|
}
|
|
1075
|
-
/**
|
|
1073
|
+
/** The callbacks and paths that the stand-down code uses to release the chain of this cycle. */
|
|
1076
1074
|
get standDownRequest() {
|
|
1077
1075
|
return {
|
|
1078
1076
|
request: this.request,
|
|
@@ -1087,7 +1085,7 @@ var BackupCycle = class {
|
|
|
1087
1085
|
report: (err) => this.report(err)
|
|
1088
1086
|
};
|
|
1089
1087
|
}
|
|
1090
|
-
/** Empties
|
|
1088
|
+
/** Empties the log when this turn captures nothing from it and it has grown past the limit that the operator sets. */
|
|
1091
1089
|
async releaseLogPastLimit() {
|
|
1092
1090
|
if (this.stopped) return;
|
|
1093
1091
|
try {
|
|
@@ -1097,10 +1095,11 @@ var BackupCycle = class {
|
|
|
1097
1095
|
}
|
|
1098
1096
|
}
|
|
1099
1097
|
/**
|
|
1100
|
-
*
|
|
1101
|
-
*
|
|
1102
|
-
*
|
|
1103
|
-
*
|
|
1098
|
+
* Returns whether this node takes the turn that it is starting. Where the
|
|
1099
|
+
* replication group takes its backups from another node, this node stands
|
|
1100
|
+
* down from its chain and empties its log. Where Sirannon cannot read the
|
|
1101
|
+
* group, this node keeps its chain and its log as they are, because no backup
|
|
1102
|
+
* holds the frames that it has yet to capture.
|
|
1104
1103
|
*/
|
|
1105
1104
|
async takesTheTurn() {
|
|
1106
1105
|
const decision = await decideBackupTurn(this.request.replicationGroup, this.preferredNode);
|
|
@@ -1115,7 +1114,7 @@ var BackupCycle = class {
|
|
|
1115
1114
|
}
|
|
1116
1115
|
return false;
|
|
1117
1116
|
}
|
|
1118
|
-
/**
|
|
1117
|
+
/** Reports a skipped turn when the decision carries a reason for it. */
|
|
1119
1118
|
async reportSkip(skip) {
|
|
1120
1119
|
if (skip) await this.turnLog.skipped(skip);
|
|
1121
1120
|
}
|
|
@@ -1144,13 +1143,12 @@ var BackupCycle = class {
|
|
|
1144
1143
|
this.state = null;
|
|
1145
1144
|
}
|
|
1146
1145
|
/**
|
|
1147
|
-
* Runs one turn.
|
|
1148
|
-
*
|
|
1149
|
-
*
|
|
1150
|
-
* Where the
|
|
1151
|
-
* second failure against the chain
|
|
1152
|
-
*
|
|
1153
|
-
* which one they have lost.
|
|
1146
|
+
* Runs one turn. When the turn fails with `BACKUP_LOG_REWOUND` or
|
|
1147
|
+
* `BACKUP_CHAIN_BROKEN`, no later piece can extend the chain, so this starts a
|
|
1148
|
+
* new chain. The caller still receives the error, because no backup holds the
|
|
1149
|
+
* lost writes. Where the new chain also fails to start, Sirannon records that
|
|
1150
|
+
* second failure against the broken chain, because the cycle holds no chain by
|
|
1151
|
+
* then and the operator needs the status to name the chain that they lost.
|
|
1154
1152
|
*/
|
|
1155
1153
|
async turnOrStartOver() {
|
|
1156
1154
|
try {
|
|
@@ -1178,15 +1176,15 @@ var BackupCycle = class {
|
|
|
1178
1176
|
return last;
|
|
1179
1177
|
}
|
|
1180
1178
|
/**
|
|
1181
|
-
*
|
|
1179
|
+
* Reports a failure to the operator and records it as the outcome of the
|
|
1180
|
+
* turn, against the chain that the cycle holds now.
|
|
1182
1181
|
*
|
|
1183
|
-
* @param err -
|
|
1184
|
-
* @param chainId - The chain to record it against, which defaults to the one the cycle holds now.
|
|
1182
|
+
* @param err - The error that stops the turn.
|
|
1185
1183
|
*/
|
|
1186
1184
|
report(err) {
|
|
1187
1185
|
this.turnLog.failed(err, this.state?.chainId);
|
|
1188
1186
|
}
|
|
1189
|
-
/** Records a failure against a chain the cycle may already have
|
|
1187
|
+
/** Records a failure against a chain that the cycle may already have released. */
|
|
1190
1188
|
reportAgainstChain(err, chainId) {
|
|
1191
1189
|
this.turnLog.failed(err, chainId);
|
|
1192
1190
|
}
|
|
@@ -1219,10 +1217,10 @@ var BackupCycle = class {
|
|
|
1219
1217
|
this.captured = true;
|
|
1220
1218
|
}
|
|
1221
1219
|
/**
|
|
1222
|
-
* Sends the capture staged against the chain this cycle holds.
|
|
1223
|
-
* a capture
|
|
1224
|
-
* second
|
|
1225
|
-
*
|
|
1220
|
+
* Sends the capture staged against the chain that this cycle holds. Once the
|
|
1221
|
+
* destination refuses a capture, Sirannon skips the send for the rest of the
|
|
1222
|
+
* turn, because a second try would wait out the destination deadline again
|
|
1223
|
+
* and delay every turn queued after it.
|
|
1226
1224
|
*/
|
|
1227
1225
|
async sendWaitingCapture() {
|
|
1228
1226
|
if (this.sendRefused) return void 0;
|