@based/db 0.0.57 → 0.0.58
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/lib/darwin_aarch64/libnode-v20.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v21.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v22.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v23.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v24.node +0 -0
- package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
- package/dist/lib/linux_aarch64/libselva.so +0 -0
- package/dist/lib/linux_x86_64/libselva.so +0 -0
- package/dist/src/client/modify/create.js +0 -1
- package/dist/src/server/index.js +7 -1
- package/dist/src/server/migrate/index.js +11 -7
- package/package.json +2 -2
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/src/server/index.js
CHANGED
|
@@ -242,7 +242,9 @@ export class DbServer extends DbShared {
|
|
|
242
242
|
}
|
|
243
243
|
modify(buf) {
|
|
244
244
|
const schemaHash = readUint64(buf, 0);
|
|
245
|
-
if
|
|
245
|
+
// if !schema
|
|
246
|
+
if (schemaHash !== this.schema?.hash) {
|
|
247
|
+
this.emit('info', 'Schema mismatch in modify');
|
|
246
248
|
return null;
|
|
247
249
|
}
|
|
248
250
|
buf = buf.subarray(8);
|
|
@@ -255,6 +257,10 @@ export class DbServer extends DbShared {
|
|
|
255
257
|
i += 2;
|
|
256
258
|
const startId = readUint32(buf, i);
|
|
257
259
|
const def = this.schemaTypesParsedById[typeId];
|
|
260
|
+
if (!def) {
|
|
261
|
+
console.error(`Wrong cannot get def in modify ${typeId} ${schemaHash} ${this.schema?.hash}!}`);
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
258
264
|
let offset = def.lastId - startId;
|
|
259
265
|
if (offset < 0) {
|
|
260
266
|
offset = 0;
|
|
@@ -6,7 +6,6 @@ import { destructureCsmtKey, foreachDirtyBlock, specialBlock } from '../tree.js'
|
|
|
6
6
|
import { fileURLToPath } from 'url';
|
|
7
7
|
import { setNativeSchema, setSchemaOnServer, writeSchemaFile, } from '../schema.js';
|
|
8
8
|
import { setToAwake, waitUntilSleeping } from './utils.js';
|
|
9
|
-
import { deepMerge } from '@saulx/utils';
|
|
10
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
11
10
|
const __dirname = dirname(__filename);
|
|
12
11
|
const workerPath = join(__dirname, 'worker.js');
|
|
@@ -32,7 +31,12 @@ export const migrate = async (server, fromSchema, toSchema, transform) => {
|
|
|
32
31
|
const migrationId = toSchema.hash;
|
|
33
32
|
server.migrating = migrationId;
|
|
34
33
|
server.emit('info', `migrating schema ${migrationId}`);
|
|
34
|
+
let killed = false;
|
|
35
35
|
const abort = () => {
|
|
36
|
+
if (killed) {
|
|
37
|
+
server.emit('info', `migration killed something went wrong ${migrationId}`);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
36
40
|
server.emit('info', `abort migration - migrating: ${server.migrating} abort: ${migrationId}`);
|
|
37
41
|
return server.migrating !== migrationId;
|
|
38
42
|
};
|
|
@@ -73,7 +77,10 @@ export const migrate = async (server, fromSchema, toSchema, transform) => {
|
|
|
73
77
|
transferList: [port2],
|
|
74
78
|
});
|
|
75
79
|
// handle?
|
|
76
|
-
worker.on('error',
|
|
80
|
+
worker.on('error', (err) => {
|
|
81
|
+
killed = true;
|
|
82
|
+
console.error(`Error in migration ${err.message}`);
|
|
83
|
+
});
|
|
77
84
|
// Block handling
|
|
78
85
|
let i = 0;
|
|
79
86
|
let rangesToMigrate = [];
|
|
@@ -127,12 +134,9 @@ export const migrate = async (server, fromSchema, toSchema, transform) => {
|
|
|
127
134
|
// ----------------MAKE NICE THIS------------------
|
|
128
135
|
// pass last node IDS { type: lastId }
|
|
129
136
|
setSchemaOnServer(server, toSchema);
|
|
130
|
-
|
|
131
|
-
server.schemaTypesParsed = deepMerge(tmpDb.server.schemaTypesParsed, schemaTypesParsed);
|
|
132
|
-
server.schemaTypesParsedById = {};
|
|
133
|
-
for (const key in server.schemaTypesParsed) {
|
|
137
|
+
for (const key in schemaTypesParsed) {
|
|
134
138
|
const def = server.schemaTypesParsed[key];
|
|
135
|
-
|
|
139
|
+
def.lastId = schemaTypesParsed[key].lastId;
|
|
136
140
|
}
|
|
137
141
|
// -----------------------------------------
|
|
138
142
|
tmpDb.server.dbCtxExternal = fromCtx;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@based/db",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.58",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/src/index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"basedDbNative.cjs"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@based/schema": "5.0.0-alpha.
|
|
41
|
+
"@based/schema": "5.0.0-alpha.18",
|
|
42
42
|
"@saulx/hash": "^3.0.0",
|
|
43
43
|
"@saulx/utils": "^6.7.0",
|
|
44
44
|
"exit-hook": "^4.0.0",
|