@rizom/ops 0.2.0-alpha.640 → 0.2.0-alpha.642
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/brains-ops.js +109 -109
- package/dist/index.js +120 -120
- package/package.json +1 -1
- package/templates/rover-pilot/deploy/scripts/create-predeploy-backup.ts +17 -3
package/package.json
CHANGED
|
@@ -176,12 +176,26 @@ function gitRemoteEnvironment():
|
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
/** How long a snapshot read waits on a runtime that holds the database. */
|
|
180
|
+
const SNAPSHOT_BUSY_TIMEOUT_MS = 10_000;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Open a database for reading a snapshot. The runtime is live while the
|
|
184
|
+
* backup runs, so a reader can meet a writer's lock or a WAL recovery in
|
|
185
|
+
* progress; it waits for them instead of failing the backup at once.
|
|
186
|
+
*/
|
|
187
|
+
function openSnapshotReader(path: string): Database {
|
|
188
|
+
const database = new Database(path, { readonly: true });
|
|
189
|
+
database.run(`PRAGMA busy_timeout = ${SNAPSHOT_BUSY_TIMEOUT_MS}`);
|
|
190
|
+
return database;
|
|
191
|
+
}
|
|
192
|
+
|
|
179
193
|
async function quickCheck(
|
|
180
194
|
path: string,
|
|
181
195
|
driver: QuickCheckDriver,
|
|
182
196
|
): Promise<string> {
|
|
183
197
|
if (driver === "bun") {
|
|
184
|
-
const database =
|
|
198
|
+
const database = openSnapshotReader(path);
|
|
185
199
|
try {
|
|
186
200
|
const result: unknown = database.query("PRAGMA quick_check").get();
|
|
187
201
|
const row = isPlainRecord(result) ? result : null;
|
|
@@ -252,7 +266,7 @@ function vectorDigest(path: string): {
|
|
|
252
266
|
counts: Record<string, number>;
|
|
253
267
|
sha256: string;
|
|
254
268
|
} {
|
|
255
|
-
const database =
|
|
269
|
+
const database = openSnapshotReader(path);
|
|
256
270
|
try {
|
|
257
271
|
return vectorDigestDatabase(database);
|
|
258
272
|
} finally {
|
|
@@ -275,7 +289,7 @@ async function captureDatabases(
|
|
|
275
289
|
}
|
|
276
290
|
|
|
277
291
|
const startedAt = new Date().toISOString();
|
|
278
|
-
const database =
|
|
292
|
+
const database = openSnapshotReader(source.source);
|
|
279
293
|
let originalVectorDigest:
|
|
280
294
|
{ counts: Record<string, number>; sha256: string } | undefined;
|
|
281
295
|
if (source.method === "serialize") {
|