@camstack/system 1.2.318 → 1.2.319
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/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -76
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -76
- package/dist/builtins/composer/composer-apply-waits.d.ts +21 -0
- package/dist/builtins/composer/composer-live-set.d.ts +22 -0
- package/dist/builtins/composer/composer-runtime-factory.d.ts +22 -0
- package/dist/builtins/composer/composer-seeds.d.ts +22 -0
- package/dist/builtins/composer/composer.addon.js +1903 -1807
- package/dist/builtins/composer/composer.addon.mjs +1903 -1807
- package/dist/builtins/composer/composer.d.ts +3 -15
- package/dist/builtins/sqlite-storage/shm-lock-canary.d.ts +60 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.ts +1 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
- package/dist/builtins/sqlite-storage/wal-checkpoint-policy.d.ts +115 -34
- package/dist/builtins/sqlite-storage/wal-checkpointer.d.ts +6 -0
- package/dist/builtins/system-backup/system-backup.service.d.ts +2 -17
- package/dist/wal-checkpoint-policy-BahrTtyD.mjs +186 -0
- package/dist/wal-checkpoint-policy-d2z2qPqx.js +233 -0
- package/dist/wal-checkpoint-worker.js +63 -57
- package/dist/wal-checkpoint-worker.mjs +63 -57
- package/package.json +1 -1
- package/dist/wal-checkpoint-policy-CAcg63o-.mjs +0 -92
- package/dist/wal-checkpoint-policy-CCJZngds.js +0 -127
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Longest the worker lets pending frames sit before folding them, in ms. A
|
|
3
|
-
* quiet database (a developer machine, an agent with little to persist) still
|
|
4
|
-
* gets its WAL folded and its pages made durable within a minute.
|
|
5
|
-
*/
|
|
6
|
-
var WAL_CHECKPOINT_MAX_INTERVAL_MS = 6e4;
|
|
7
|
-
/** How often the worker looks at the wal-index, in ms. A 136-byte read. */
|
|
8
|
-
var WAL_CHECKPOINT_POLL_MS = 1e3;
|
|
9
|
-
/**
|
|
10
|
-
* A checkpoint that took this long is reported at WARN with its numbers.
|
|
11
|
-
* Matched to `SQLITE_SLOW_CALL_MS`: it is the same "the disk held us" event
|
|
12
|
-
* the profiler used to file as a slow `set`, now on the thread that paid it.
|
|
13
|
-
*/
|
|
14
|
-
var WAL_CHECKPOINT_SLOW_MS = 1e3;
|
|
15
|
-
/** Should the worker run `wal_checkpoint(PASSIVE)` now? */
|
|
16
|
-
function decideCheckpoint(input) {
|
|
17
|
-
const intervalDue = input.sinceLastRunMs >= WAL_CHECKPOINT_MAX_INTERVAL_MS;
|
|
18
|
-
if (input.mxFrame === null || input.nBackfill === null) return intervalDue ? {
|
|
19
|
-
run: true,
|
|
20
|
-
reason: "unknown-interval",
|
|
21
|
-
pendingFrames: null
|
|
22
|
-
} : {
|
|
23
|
-
run: false,
|
|
24
|
-
reason: "unknown-below-interval",
|
|
25
|
-
pendingFrames: null
|
|
26
|
-
};
|
|
27
|
-
const pendingFrames = Math.max(0, input.mxFrame - input.nBackfill);
|
|
28
|
-
if (pendingFrames === 0) return {
|
|
29
|
-
run: false,
|
|
30
|
-
reason: "nothing-pending",
|
|
31
|
-
pendingFrames
|
|
32
|
-
};
|
|
33
|
-
if (pendingFrames >= 1e3) return {
|
|
34
|
-
run: true,
|
|
35
|
-
reason: "threshold",
|
|
36
|
-
pendingFrames
|
|
37
|
-
};
|
|
38
|
-
if (intervalDue) return {
|
|
39
|
-
run: true,
|
|
40
|
-
reason: "interval",
|
|
41
|
-
pendingFrames
|
|
42
|
-
};
|
|
43
|
-
return {
|
|
44
|
-
run: false,
|
|
45
|
-
reason: "below-threshold",
|
|
46
|
-
pendingFrames
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Byte offsets in the `-shm` file, from `wal.c` ("WAL-index file format"):
|
|
51
|
-
* two copies of the 48-byte `WalIndexHdr` (copy 2 at 48), then `WalCkptInfo`
|
|
52
|
-
* at 96 whose first field is `nBackfill`. `mxFrame` is at byte 16 of the
|
|
53
|
-
* header. Both are u32 in the writer's native byte order — little-endian on
|
|
54
|
-
* every x86-64 and arm64 node this ships to.
|
|
55
|
-
*/
|
|
56
|
-
var WAL_INDEX_MXFRAME_OFFSET = 16;
|
|
57
|
-
var WAL_INDEX_HDR_SIZE = 48;
|
|
58
|
-
var WAL_INDEX_NBACKFILL_OFFSET = 96;
|
|
59
|
-
/**
|
|
60
|
-
* `mxFrame` and `nBackfill` from the first {@link WAL_INDEX_HEADER_READ_BYTES}
|
|
61
|
-
* of the `-shm` file, or `null` when the buffer is short or the two header
|
|
62
|
-
* copies disagree (a writer was updating them — SQLite's own readers retry on
|
|
63
|
-
* exactly that comparison; this caller simply waits for the next poll).
|
|
64
|
-
*/
|
|
65
|
-
function parseWalIndexHeader(buffer) {
|
|
66
|
-
if (buffer.length < 100) return null;
|
|
67
|
-
const copy1 = buffer.subarray(0, WAL_INDEX_HDR_SIZE);
|
|
68
|
-
const copy2 = buffer.subarray(WAL_INDEX_HDR_SIZE, WAL_INDEX_HDR_SIZE * 2);
|
|
69
|
-
if (!copy1.equals(copy2)) return null;
|
|
70
|
-
return {
|
|
71
|
-
mxFrame: buffer.readUInt32LE(WAL_INDEX_MXFRAME_OFFSET),
|
|
72
|
-
nBackfill: buffer.readUInt32LE(WAL_INDEX_NBACKFILL_OFFSET)
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
function isRecord(value) {
|
|
76
|
-
return typeof value === "object" && value !== null;
|
|
77
|
-
}
|
|
78
|
-
/** Narrow a message off the worker port without a cast. */
|
|
79
|
-
function isWorkerMessage(value) {
|
|
80
|
-
if (!isRecord(value)) return false;
|
|
81
|
-
switch (value["kind"]) {
|
|
82
|
-
case "ready": return true;
|
|
83
|
-
case "failed": return typeof value["error"] === "string";
|
|
84
|
-
case "checkpointed": return typeof value["reason"] === "string" && (typeof value["pendingFrames"] === "number" || value["pendingFrames"] === null) && typeof value["walFrames"] === "number" && typeof value["checkpointedFrames"] === "number" && typeof value["busy"] === "boolean" && typeof value["ms"] === "number";
|
|
85
|
-
default: return false;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function isWorkerStop(value) {
|
|
89
|
-
return isRecord(value) && value["kind"] === "stop";
|
|
90
|
-
}
|
|
91
|
-
//#endregion
|
|
92
|
-
Object.defineProperty(exports, "WAL_CHECKPOINT_POLL_MS", {
|
|
93
|
-
enumerable: true,
|
|
94
|
-
get: function() {
|
|
95
|
-
return WAL_CHECKPOINT_POLL_MS;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
Object.defineProperty(exports, "WAL_CHECKPOINT_SLOW_MS", {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
get: function() {
|
|
101
|
-
return WAL_CHECKPOINT_SLOW_MS;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
Object.defineProperty(exports, "decideCheckpoint", {
|
|
105
|
-
enumerable: true,
|
|
106
|
-
get: function() {
|
|
107
|
-
return decideCheckpoint;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
Object.defineProperty(exports, "isWorkerMessage", {
|
|
111
|
-
enumerable: true,
|
|
112
|
-
get: function() {
|
|
113
|
-
return isWorkerMessage;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
Object.defineProperty(exports, "isWorkerStop", {
|
|
117
|
-
enumerable: true,
|
|
118
|
-
get: function() {
|
|
119
|
-
return isWorkerStop;
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
Object.defineProperty(exports, "parseWalIndexHeader", {
|
|
123
|
-
enumerable: true,
|
|
124
|
-
get: function() {
|
|
125
|
-
return parseWalIndexHeader;
|
|
126
|
-
}
|
|
127
|
-
});
|