@rocicorp/zero 0.12.2025012901 → 0.12.2025013000
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/out/advanced.js +1 -1
- package/out/{chunk-VYAI3OU4.js → chunk-UEPZPKPV.js} +125 -171
- package/out/{chunk-VYAI3OU4.js.map → chunk-UEPZPKPV.js.map} +4 -4
- package/out/{chunk-QAAJZ32T.js → chunk-ZVLXEWWB.js} +71 -11
- package/out/chunk-ZVLXEWWB.js.map +7 -0
- package/out/otel/src/log-options.d.ts +23 -0
- package/out/otel/src/log-options.d.ts.map +1 -0
- package/out/otel/src/log-options.js +34 -0
- package/out/otel/src/log-options.js.map +1 -0
- package/out/otel/src/maybe-time.d.ts +3 -0
- package/out/otel/src/maybe-time.d.ts.map +1 -0
- package/out/otel/src/maybe-time.js +13 -0
- package/out/otel/src/maybe-time.js.map +1 -0
- package/out/solid.js +2 -2
- package/out/zero-cache/src/auth/write-authorizer.d.ts +1 -1
- package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.js +3 -1
- package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
- package/out/zero-cache/src/config/zero-config.d.ts +17 -13
- package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
- package/out/zero-cache/src/config/zero-config.js +1 -19
- package/out/zero-cache/src/config/zero-config.js.map +1 -1
- package/out/zero-cache/src/server/multi/config.d.ts +8 -0
- package/out/zero-cache/src/server/multi/config.d.ts.map +1 -1
- package/out/zero-cache/src/server/multi/main.d.ts +2 -2
- package/out/zero-cache/src/server/multi/main.d.ts.map +1 -1
- package/out/zero-cache/src/server/multi/main.js +4 -89
- package/out/zero-cache/src/server/multi/main.js.map +1 -1
- package/out/zero-cache/src/server/multi/run-worker.d.ts +4 -0
- package/out/zero-cache/src/server/multi/run-worker.d.ts.map +1 -0
- package/out/zero-cache/src/server/multi/run-worker.js +91 -0
- package/out/zero-cache/src/server/multi/run-worker.js.map +1 -0
- package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/server/syncer.js +1 -1
- package/out/zero-cache/src/server/syncer.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/change-source.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/change-source.js +93 -120
- package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts +18 -18
- package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/data.js +5 -2
- package/out/zero-cache/src/services/change-source/protocol/current/data.js.map +1 -1
- package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts +24 -24
- package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts +8 -8
- package/out/zero-cache/src/services/change-streamer/storer.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/storer.js +3 -2
- package/out/zero-cache/src/services/change-streamer/storer.js.map +1 -1
- package/out/zero-cache/src/services/life-cycle.d.ts.map +1 -1
- package/out/zero-cache/src/services/life-cycle.js +4 -2
- package/out/zero-cache/src/services/life-cycle.js.map +1 -1
- package/out/zero-cache/src/services/replicator/change-processor.js +7 -3
- package/out/zero-cache/src/services/replicator/change-processor.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +2 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +5 -3
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.js +26 -2
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-cache/src/types/processes.d.ts +1 -0
- package/out/zero-cache/src/types/processes.d.ts.map +1 -1
- package/out/zero-cache/src/types/processes.js +5 -1
- package/out/zero-cache/src/types/processes.js.map +1 -1
- package/out/zero-cache/src/workers/replicator.d.ts.map +1 -1
- package/out/zero-cache/src/workers/replicator.js +9 -7
- package/out/zero-cache/src/workers/replicator.js.map +1 -1
- package/out/zero-client/src/client/custom.d.ts +78 -0
- package/out/zero-client/src/client/custom.d.ts.map +1 -0
- package/out/zero-client/src/client/options.d.ts +4 -2
- package/out/zero-client/src/client/options.d.ts.map +1 -1
- package/out/zero-client/src/types/client-state.d.ts +8 -0
- package/out/zero-client/src/types/client-state.d.ts.map +1 -0
- package/out/zero.js +2 -2
- package/out/zql/src/ivm/change.d.ts +4 -4
- package/out/zql/src/ivm/change.d.ts.map +1 -1
- package/out/zql/src/ivm/change.js +1 -4
- package/out/zql/src/ivm/change.js.map +1 -1
- package/out/zql/src/ivm/data.d.ts +2 -1
- package/out/zql/src/ivm/data.d.ts.map +1 -1
- package/out/zql/src/ivm/data.js +7 -0
- package/out/zql/src/ivm/data.js.map +1 -1
- package/out/zql/src/ivm/exists.d.ts +3 -2
- package/out/zql/src/ivm/exists.d.ts.map +1 -1
- package/out/zql/src/ivm/exists.js +55 -64
- package/out/zql/src/ivm/exists.js.map +1 -1
- package/out/zql/src/ivm/filter-push.js +1 -1
- package/out/zql/src/ivm/filter-push.js.map +1 -1
- package/out/zql/src/ivm/filter.d.ts +2 -3
- package/out/zql/src/ivm/filter.d.ts.map +1 -1
- package/out/zql/src/ivm/filter.js +12 -7
- package/out/zql/src/ivm/filter.js.map +1 -1
- package/out/zql/src/ivm/join.d.ts +4 -1
- package/out/zql/src/ivm/join.d.ts.map +1 -1
- package/out/zql/src/ivm/join.js +32 -25
- package/out/zql/src/ivm/join.js.map +1 -1
- package/out/zql/src/ivm/skip.d.ts.map +1 -1
- package/out/zql/src/ivm/skip.js +1 -2
- package/out/zql/src/ivm/skip.js.map +1 -1
- package/out/zql/src/ivm/take.d.ts.map +1 -1
- package/out/zql/src/ivm/take.js +4 -3
- package/out/zql/src/ivm/take.js.map +1 -1
- package/out/zql/src/ivm/view-apply-change.d.ts.map +1 -1
- package/out/zql/src/ivm/view-apply-change.js +4 -10
- package/out/zql/src/ivm/view-apply-change.js.map +1 -1
- package/out/zqlite/src/db.d.ts.map +1 -1
- package/out/zqlite/src/db.js +11 -1
- package/out/zqlite/src/db.js.map +1 -1
- package/out/zqlite/src/table-source.d.ts +3 -1
- package/out/zqlite/src/table-source.d.ts.map +1 -1
- package/out/zqlite/src/table-source.js +22 -6
- package/out/zqlite/src/table-source.js.map +1 -1
- package/package.json +2 -1
- package/out/chunk-QAAJZ32T.js.map +0 -7
|
@@ -1,94 +1,9 @@
|
|
|
1
1
|
import 'dotenv/config'; // Imports ENV variables from .env
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { orTimeout } from "../../types/timeout.js";
|
|
6
|
-
import { createLogContext } from "../logging.js";
|
|
7
|
-
import { getMultiZeroConfig } from "./config.js";
|
|
8
|
-
import { getTaskID } from "./runtime.js";
|
|
9
|
-
import { TenantDispatcher } from "./tenant-dispatcher.js";
|
|
10
|
-
export default async function runWorker(parent, env) {
|
|
11
|
-
const startMs = Date.now();
|
|
12
|
-
const { config, env: baseEnv } = getMultiZeroConfig(env);
|
|
13
|
-
const lc = createLogContext(config, { worker: 'main' });
|
|
14
|
-
const processes = new ProcessManager(lc, parent ?? process);
|
|
15
|
-
const { port, changeStreamerPort = port + 1 } = config;
|
|
16
|
-
let { taskID } = config;
|
|
17
|
-
if (!taskID) {
|
|
18
|
-
taskID = await getTaskID(lc);
|
|
19
|
-
baseEnv['ZERO_TASK_ID'] = taskID;
|
|
20
|
-
}
|
|
21
|
-
lc.info?.(`starting task ${taskID}`);
|
|
22
|
-
const multiMode = config.tenants.length;
|
|
23
|
-
if (!multiMode) {
|
|
24
|
-
// Run a single tenant on main `port`, and skip the TenantDispatcher.
|
|
25
|
-
config.tenants.push({
|
|
26
|
-
id: '',
|
|
27
|
-
env: {
|
|
28
|
-
['ZERO_PORT']: String(port),
|
|
29
|
-
['ZERO_CVR_DB']: config.cvr.db,
|
|
30
|
-
['ZERO_CHANGE_DB']: config.change.db,
|
|
31
|
-
['ZERO_REPLICA_FILE']: config.replicaFile,
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
// In the multi-node configuration, determine if this process
|
|
36
|
-
// should be dispatching sync requests (i.e. by `host` / `port`),
|
|
37
|
-
// or change-streamer requests (i.e. by tenant `id`).
|
|
38
|
-
const runAsReplicationManager = config.numSyncWorkers === 0;
|
|
39
|
-
// Start the first tenant at (port + 2) unless explicitly
|
|
40
|
-
// overridden by its own ZERO_PORT ...
|
|
41
|
-
let tenantPort = port;
|
|
42
|
-
const tenants = config.tenants.map(tenant => {
|
|
43
|
-
const mergedEnv = {
|
|
44
|
-
...process.env, // propagate all ENV variables from this process
|
|
45
|
-
...baseEnv, // defaults
|
|
46
|
-
['ZERO_TENANT_ID']: tenant.id,
|
|
47
|
-
['ZERO_PORT']: String((tenantPort += 2)), // and bump the port by 2 thereafter.
|
|
48
|
-
...tenant.env, // overrides
|
|
49
|
-
};
|
|
50
|
-
if (runAsReplicationManager) {
|
|
51
|
-
// Sanity-check. It doesn't make sense to run sync workers in the
|
|
52
|
-
// replication-manager.
|
|
53
|
-
assert(mergedEnv['ZERO_NUM_SYNC_WORKERS'] === '0', `Tenant ${tenant.id} cannot run sync workers in the replication-manager`);
|
|
54
|
-
}
|
|
55
|
-
const changeStreamerURI = mergedEnv['ZERO_CHANGE_STREAMER_URI'];
|
|
56
|
-
if (changeStreamerURI && multiMode) {
|
|
57
|
-
// Requests from the view-syncer to the replication-manager are
|
|
58
|
-
// delineated/dispatched by the tenant ID as the first path component.
|
|
59
|
-
mergedEnv['ZERO_CHANGE_STREAMER_URI'] += changeStreamerURI.endsWith('/')
|
|
60
|
-
? tenant.id
|
|
61
|
-
: `/${tenant.id}`;
|
|
62
|
-
}
|
|
63
|
-
return { ...tenant, worker: childWorker('./server/main.ts', mergedEnv) };
|
|
64
|
-
});
|
|
65
|
-
for (const tenant of tenants) {
|
|
66
|
-
processes.addWorker(tenant.worker, 'user-facing', tenant.id);
|
|
67
|
-
}
|
|
68
|
-
const s = tenants.length > 1 ? 's' : '';
|
|
69
|
-
lc.info?.(`waiting for zero-cache${s} to be ready ...`);
|
|
70
|
-
if ((await orTimeout(processes.allWorkersReady(), 60_000)) === 'timed-out') {
|
|
71
|
-
lc.info?.(`timed out waiting for readiness (${Date.now() - startMs} ms)`);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
lc.info?.(`zero-cache${s} ready (${Date.now() - startMs} ms)`);
|
|
75
|
-
}
|
|
76
|
-
const mainServices = [];
|
|
77
|
-
if (multiMode) {
|
|
78
|
-
mainServices.push(new TenantDispatcher(lc, runAsReplicationManager, tenants, {
|
|
79
|
-
port: runAsReplicationManager ? changeStreamerPort : port,
|
|
80
|
-
}));
|
|
81
|
-
}
|
|
82
|
-
parent?.send(['ready', { ready: true }]);
|
|
83
|
-
try {
|
|
84
|
-
await runUntilKilled(lc, parent ?? process, ...mainServices);
|
|
85
|
-
}
|
|
86
|
-
catch (err) {
|
|
87
|
-
processes.logErrorAndExit(err, 'main');
|
|
88
|
-
}
|
|
89
|
-
await processes.done();
|
|
90
|
-
}
|
|
2
|
+
import { exitAfter } from "../../services/life-cycle.js";
|
|
3
|
+
import { parentWorker, singleProcessMode } from "../../types/processes.js";
|
|
4
|
+
import { runWorker } from "./run-worker.js";
|
|
91
5
|
if (!singleProcessMode()) {
|
|
92
6
|
void exitAfter(() => runWorker(parentWorker, process.env));
|
|
93
7
|
}
|
|
8
|
+
export default runWorker;
|
|
94
9
|
//# sourceMappingURL=main.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../../../../zero-cache/src/server/multi/main.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC,CAAC,kCAAkC;AAC1D,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../../../../zero-cache/src/server/multi/main.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC,CAAC,kCAAkC;AAC1D,OAAO,EAAC,SAAS,EAAC,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAC,YAAY,EAAE,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAE1C,IAAI,CAAC,iBAAiB,EAAE,EAAE,CAAC;IACzB,KAAK,SAAS,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-worker.d.ts","sourceRoot":"","sources":["../../../../../../zero-cache/src/server/multi/run-worker.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAIvB,OAAO,EAAc,KAAK,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAOlE,wBAAsB,SAAS,CAC7B,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,GAAG,EAAE,MAAM,CAAC,UAAU,GACrB,OAAO,CAAC,IAAI,CAAC,CA+Ff"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import 'dotenv/config'; // Imports ENV variables from .env
|
|
2
|
+
import { assert } from "../../../../shared/src/asserts.js";
|
|
3
|
+
import { ProcessManager, runUntilKilled } from "../../services/life-cycle.js";
|
|
4
|
+
import { childWorker } from "../../types/processes.js";
|
|
5
|
+
import { orTimeout } from "../../types/timeout.js";
|
|
6
|
+
import { createLogContext } from "../logging.js";
|
|
7
|
+
import { getMultiZeroConfig } from "./config.js";
|
|
8
|
+
import { getTaskID } from "./runtime.js";
|
|
9
|
+
import { TenantDispatcher } from "./tenant-dispatcher.js";
|
|
10
|
+
export async function runWorker(parent, env) {
|
|
11
|
+
const startMs = Date.now();
|
|
12
|
+
const { config, env: baseEnv } = getMultiZeroConfig(env);
|
|
13
|
+
const lc = createLogContext(config, { worker: 'main' });
|
|
14
|
+
const processes = new ProcessManager(lc, parent ?? process);
|
|
15
|
+
const { port, changeStreamerPort = port + 1 } = config;
|
|
16
|
+
let { taskID } = config;
|
|
17
|
+
if (!taskID) {
|
|
18
|
+
taskID = await getTaskID(lc);
|
|
19
|
+
baseEnv['ZERO_TASK_ID'] = taskID;
|
|
20
|
+
}
|
|
21
|
+
lc.info?.(`starting task ${taskID}`);
|
|
22
|
+
const multiMode = config.tenants.length;
|
|
23
|
+
if (!multiMode) {
|
|
24
|
+
// Run a single tenant on main `port`, and skip the TenantDispatcher.
|
|
25
|
+
config.tenants.push({
|
|
26
|
+
id: '',
|
|
27
|
+
env: {
|
|
28
|
+
['ZERO_PORT']: String(port),
|
|
29
|
+
['ZERO_CVR_DB']: config.cvr.db,
|
|
30
|
+
['ZERO_CHANGE_DB']: config.change.db,
|
|
31
|
+
['ZERO_REPLICA_FILE']: config.replicaFile,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
// In the multi-node configuration, determine if this process
|
|
36
|
+
// should be dispatching sync requests (i.e. by `host` / `port`),
|
|
37
|
+
// or change-streamer requests (i.e. by tenant `id`).
|
|
38
|
+
const runAsReplicationManager = config.numSyncWorkers === 0;
|
|
39
|
+
// Start the first tenant at (port + 2) unless explicitly
|
|
40
|
+
// overridden by its own ZERO_PORT ...
|
|
41
|
+
let tenantPort = port;
|
|
42
|
+
const tenants = config.tenants.map(tenant => {
|
|
43
|
+
const mergedEnv = {
|
|
44
|
+
...process.env, // propagate all ENV variables from this process
|
|
45
|
+
...baseEnv, // defaults
|
|
46
|
+
['ZERO_TENANT_ID']: tenant.id,
|
|
47
|
+
['ZERO_PORT']: String((tenantPort += 2)), // and bump the port by 2 thereafter.
|
|
48
|
+
...tenant.env, // overrides
|
|
49
|
+
};
|
|
50
|
+
if (runAsReplicationManager) {
|
|
51
|
+
// Sanity-check. It doesn't make sense to run sync workers in the
|
|
52
|
+
// replication-manager.
|
|
53
|
+
assert(mergedEnv['ZERO_NUM_SYNC_WORKERS'] === '0', `Tenant ${tenant.id} cannot run sync workers in the replication-manager`);
|
|
54
|
+
}
|
|
55
|
+
const changeStreamerURI = mergedEnv['ZERO_CHANGE_STREAMER_URI'];
|
|
56
|
+
if (changeStreamerURI && multiMode) {
|
|
57
|
+
// Requests from the view-syncer to the replication-manager are
|
|
58
|
+
// delineated/dispatched by the tenant ID as the first path component.
|
|
59
|
+
mergedEnv['ZERO_CHANGE_STREAMER_URI'] += changeStreamerURI.endsWith('/')
|
|
60
|
+
? tenant.id
|
|
61
|
+
: `/${tenant.id}`;
|
|
62
|
+
}
|
|
63
|
+
return { ...tenant, worker: childWorker('./server/main.ts', mergedEnv) };
|
|
64
|
+
});
|
|
65
|
+
for (const tenant of tenants) {
|
|
66
|
+
processes.addWorker(tenant.worker, 'user-facing', tenant.id);
|
|
67
|
+
}
|
|
68
|
+
const s = tenants.length > 1 ? 's' : '';
|
|
69
|
+
lc.info?.(`waiting for zero-cache${s} to be ready ...`);
|
|
70
|
+
if ((await orTimeout(processes.allWorkersReady(), 60_000)) === 'timed-out') {
|
|
71
|
+
lc.info?.(`timed out waiting for readiness (${Date.now() - startMs} ms)`);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
lc.info?.(`zero-cache${s} ready (${Date.now() - startMs} ms)`);
|
|
75
|
+
}
|
|
76
|
+
const mainServices = [];
|
|
77
|
+
if (multiMode) {
|
|
78
|
+
mainServices.push(new TenantDispatcher(lc, runAsReplicationManager, tenants, {
|
|
79
|
+
port: runAsReplicationManager ? changeStreamerPort : port,
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
parent?.send(['ready', { ready: true }]);
|
|
83
|
+
try {
|
|
84
|
+
await runUntilKilled(lc, parent ?? process, ...mainServices);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
processes.logErrorAndExit(err, 'main');
|
|
88
|
+
}
|
|
89
|
+
await processes.done();
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=run-worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-worker.js","sourceRoot":"","sources":["../../../../../../zero-cache/src/server/multi/run-worker.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC,CAAC,kCAAkC;AAC1D,OAAO,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AACzD,OAAO,EAAC,cAAc,EAAE,cAAc,EAAC,MAAM,8BAA8B,CAAC;AAE5E,OAAO,EAAC,WAAW,EAAc,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AAExD,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAAqB,EACrB,GAAsB;IAEtB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC3B,MAAM,EAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAC,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACvD,MAAM,EAAE,GAAG,gBAAgB,CAAC,MAAM,EAAE,EAAC,MAAM,EAAE,MAAM,EAAC,CAAC,CAAC;IACtD,MAAM,SAAS,GAAG,IAAI,cAAc,CAAC,EAAE,EAAE,MAAM,IAAI,OAAO,CAAC,CAAC;IAE5D,MAAM,EAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,GAAG,CAAC,EAAC,GAAG,MAAM,CAAC;IACrD,IAAI,EAAC,MAAM,EAAC,GAAG,MAAM,CAAC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AAC,WAAW,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,MAAM,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,YAAY,GAAc,EAAE,CAAC;IACnC,IAAI,SAAS,EAAE,CAAC;QACd,YAAY,CAAC,IAAI,CACf,IAAI,gBAAgB,CAAC,EAAE,EAAE,uBAAuB,EAAE,OAAO,EAAE;YACzD,IAAI,EAAE,uBAAuB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI;SAC1D,CAAC,CACH,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC;IAEvC,IAAI,CAAC;QACH,MAAM,cAAc,CAAC,EAAE,EAAE,MAAM,IAAI,OAAO,EAAE,GAAG,YAAY,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncer.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/server/syncer.ts"],"names":[],"mappings":"AA2BA,OAAO,EAGL,KAAK,MAAM,EACZ,MAAM,uBAAuB,CAAC;AAU/B,wBAA8B,SAAS,CACrC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,GAAG,IAAI,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"syncer.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/server/syncer.ts"],"names":[],"mappings":"AA2BA,OAAO,EAGL,KAAK,MAAM,EACZ,MAAM,uBAAuB,CAAC;AAU/B,wBAA8B,SAAS,CACrC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,GAAG,IAAI,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,IAAI,CAAC,CA8Gf"}
|
|
@@ -77,7 +77,7 @@ export default async function runWorker(parent, env, ...args) {
|
|
|
77
77
|
.withContext('component', 'view-syncer')
|
|
78
78
|
.withContext('clientGroupID', id)
|
|
79
79
|
.withContext('instance', randomID());
|
|
80
|
-
return new ViewSyncerService(logger, must(config.taskID, 'main must set --task-id'), id, config.shard.id, cvrDB, new PipelineDriver(logger, new Snapshotter(logger, replicaFile), operatorStorage.createClientGroupStorage(id), id), sub, drainCoordinator, permissions);
|
|
80
|
+
return new ViewSyncerService(logger, must(config.taskID, 'main must set --task-id'), id, config.shard.id, cvrDB, new PipelineDriver(logger, config.log, new Snapshotter(logger, replicaFile), operatorStorage.createClientGroupStorage(id), id), sub, drainCoordinator, permissions);
|
|
81
81
|
};
|
|
82
82
|
const mutagenFactory = (id) => new MutagenService(lc.withContext('component', 'mutagen').withContext('clientGroupID', id), config.shard.id, id, upstreamDB, config, schema, permissions);
|
|
83
83
|
const syncer = new Syncer(lc, config, viewSyncerFactory, mutagenFactory, parent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncer.js","sourceRoot":"","sources":["../../../../../zero-cache/src/server/syncer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAC,OAAO,EAAC,MAAM,yBAAyB,CAAC;AAChD,OAAO,EACL,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAC,MAAM,EAAC,MAAM,SAAS,CAAC;AAC/B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,GAAG,EAAC,MAAM,cAAc,CAAC;AACjC,OAAO,EAAC,gBAAgB,EAAC,MAAM,yCAAy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
|
1
|
-
{"version":3,"file":"change-source.d.ts","sourceRoot":"","sources":["../../../../../../../zero-cache/src/services/change-source/pg/change-source.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EACL,yBAAyB,EAG1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAEV,eAAe,EAChB,MAAM,uEAAuE,CAAC;AAc/E,OAAO,KAAK,EAEV,kBAAkB,EAEnB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAW,KAAK,WAAW,EAAC,MAAM,gCAAgC,CAAC;AAO1E,OAAO,KAAK,EACV,YAAY,EAEb,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,wCAAwC,CAAC;AAYhD,OAAO,EAAkB,KAAK,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAI3E,OAAO,EAAqB,KAAK,eAAe,EAAC,MAAM,uBAAuB,CAAC;AAQ/E,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAMnD;;;;GAIG;AACH,wBAAsB,8BAA8B,CAClD,EAAE,EAAE,UAAU,EACd,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,WAAW,EAClB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,kBAAkB,GAC9B,OAAO,CAAC;IAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAAC,YAAY,EAAE,YAAY,CAAA;CAAC,CAAC,CA4C7E;
|
|
1
|
+
{"version":3,"file":"change-source.d.ts","sourceRoot":"","sources":["../../../../../../../zero-cache/src/services/change-source/pg/change-source.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EACL,yBAAyB,EAG1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAEV,eAAe,EAChB,MAAM,uEAAuE,CAAC;AAc/E,OAAO,KAAK,EAEV,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100
100
|
const slot = replicationSlot(this.#shardID);
|
|
101
|
-
const clientStart = oneAfter(clientWatermark);
|
|
102
101
|
try {
|
|
103
102
|
await this.#stopExistingReplicationSlotSubscriber(db, slot);
|
|
104
103
|
const config = await getInternalShardConfig(db, this.#shardID);
|
|
105
|
-
this.#lc.info?.(`starting replication stream
|
|
104
|
+
this.#lc.info?.(`starting replication stream@${slot}`);
|
|
106
105
|
// Enabling ssl according to the logic in:
|
|
107
106
|
// https://github.com/brianc/node-postgres/blob/95d7e620ef8b51743b4cbca05dd3c3ce858ecea7/packages/pg-connection-string/index.js#L90
|
|
108
107
|
const url = new URL(this.#upstreamUri);
|
|
@@ -114,7 +113,7 @@ class PostgresChangeSource {
|
|
|
114
113
|
// Unlike the postgres.js client, the pg client does not have an option to
|
|
115
114
|
// only use SSL if the server supports it. We achieve it manually by
|
|
116
115
|
// trying SSL first, and then falling back to connecting without SSL.
|
|
117
|
-
return await this.#startStream(slot,
|
|
116
|
+
return await this.#startStream(slot, clientWatermark, config, useSSL);
|
|
118
117
|
}
|
|
119
118
|
catch (e) {
|
|
120
119
|
if (e instanceof SSLUnsupportedError) {
|
|
@@ -144,7 +143,7 @@ class PostgresChangeSource {
|
|
|
144
143
|
await db.end();
|
|
145
144
|
}
|
|
146
145
|
}
|
|
147
|
-
async #startStream(slot,
|
|
146
|
+
async #startStream(slot, clientWatermark, shardConfig, useSSL) {
|
|
148
147
|
const changes = Subscription.create({
|
|
149
148
|
cleanup: () => service.stop(),
|
|
150
149
|
});
|
|
@@ -200,6 +199,7 @@ class PostgresChangeSource {
|
|
|
200
199
|
}))
|
|
201
200
|
.on('error', handleError);
|
|
202
201
|
acker = new Acker(service);
|
|
202
|
+
const clientStart = oneAfter(clientWatermark);
|
|
203
203
|
service
|
|
204
204
|
.subscribe(new PgoutputPlugin({
|
|
205
205
|
protoVersion: 1,
|
|
@@ -208,7 +208,8 @@ class PostgresChangeSource {
|
|
|
208
208
|
}), slot, fromLexiVersion(clientStart))
|
|
209
209
|
.then(() => changes.cancel(), handleError);
|
|
210
210
|
await started;
|
|
211
|
-
|
|
211
|
+
const { replicaVersion } = this.#replicationConfig;
|
|
212
|
+
this.#lc.info?.(`started replication stream@${slot} from ${clientWatermark} (replicaVersion: ${replicaVersion})`);
|
|
212
213
|
return {
|
|
213
214
|
changes,
|
|
214
215
|
acks: { push: status => acker.ack(status[2].watermark) },
|
|
@@ -320,9 +321,13 @@ class ChangeMaker {
|
|
|
320
321
|
return [
|
|
321
322
|
['begin', msg, { commitWatermark: toLexiVersion(must(msg.commitLsn)) }],
|
|
322
323
|
];
|
|
323
|
-
case 'delete':
|
|
324
|
-
|
|
325
|
-
|
|
324
|
+
case 'delete': {
|
|
325
|
+
const key = msg.key ?? msg.old;
|
|
326
|
+
if (!key) {
|
|
327
|
+
throw new Error(`Invalid DELETE msg (missing key): ${stringify(msg)}`);
|
|
328
|
+
}
|
|
329
|
+
return [['data', msg.key ? msg : { ...msg, key }]];
|
|
330
|
+
}
|
|
326
331
|
case 'insert':
|
|
327
332
|
case 'update':
|
|
328
333
|
case 'truncate':
|
|
@@ -386,10 +391,18 @@ class ChangeMaker {
|
|
|
386
391
|
* but SQLite will error instead (https://sqlite.org/forum/forumpost/2e62dba69f?t=c&hist).
|
|
387
392
|
* The current workaround is to drop indexes first.
|
|
388
393
|
*
|
|
389
|
-
*
|
|
394
|
+
* Also note that although it should not be possible to both rename and
|
|
395
|
+
* add/drop tables/columns in a single statement, the operations are
|
|
396
|
+
* ordered to handle that possibility, by always dropping old entities,
|
|
397
|
+
* then modifying kept entities, and then adding new entities.
|
|
398
|
+
*
|
|
399
|
+
* Thus, the order of replicating DDL updates is:
|
|
390
400
|
* - drop indexes
|
|
391
|
-
* - alter tables
|
|
392
401
|
* - drop tables
|
|
402
|
+
* - alter tables
|
|
403
|
+
* - drop columns
|
|
404
|
+
* - alter columns
|
|
405
|
+
* - add columns
|
|
393
406
|
* - create tables
|
|
394
407
|
* - create indexes
|
|
395
408
|
*
|
|
@@ -399,137 +412,87 @@ class ChangeMaker {
|
|
|
399
412
|
* the type of a column that's indexed.
|
|
400
413
|
*/
|
|
401
414
|
#makeSchemaChanges(preSchema, update) {
|
|
402
|
-
const [
|
|
403
|
-
const [
|
|
404
|
-
const { tag } = update.event;
|
|
415
|
+
const [prevTbl, prevIdx] = specsByID(preSchema);
|
|
416
|
+
const [nextTbl, nextIdx] = specsByID(update.schema);
|
|
405
417
|
const changes = [];
|
|
406
418
|
// Validate the new table schemas
|
|
407
|
-
for (const table of
|
|
419
|
+
for (const table of nextTbl.values()) {
|
|
408
420
|
validate(this.#lc, this.#shardID, table);
|
|
409
421
|
}
|
|
410
|
-
const [
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
const { schema, name } = must(prevIndexes.get(id));
|
|
422
|
+
const [droppedIdx, createdIdx] = symmetricDifferences(prevIdx, nextIdx);
|
|
423
|
+
for (const id of droppedIdx) {
|
|
424
|
+
const { schema, name } = must(prevIdx.get(id));
|
|
414
425
|
changes.push({ tag: 'drop-index', id: { schema, name } });
|
|
415
426
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
427
|
+
// DROP
|
|
428
|
+
const [droppedTbl, createdTbl] = symmetricDifferences(prevTbl, nextTbl);
|
|
429
|
+
for (const id of droppedTbl) {
|
|
430
|
+
const { schema, name } = must(prevTbl.get(id));
|
|
431
|
+
changes.push({ tag: 'drop-table', id: { schema, name } });
|
|
421
432
|
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
if (!prevTable) {
|
|
427
|
-
// table rename. Find the old name.
|
|
428
|
-
let old;
|
|
429
|
-
for (const [id, { schema, name }] of prevTables.entries()) {
|
|
430
|
-
if (!nextTables.has(id)) {
|
|
431
|
-
old = { schema, name };
|
|
432
|
-
break;
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
if (!old) {
|
|
436
|
-
throw new Error(`can't find previous table: ${stringify(update)}`);
|
|
437
|
-
}
|
|
438
|
-
changes.push({ tag: 'rename-table', old, new: table });
|
|
439
|
-
}
|
|
440
|
-
else {
|
|
441
|
-
changes.push(...this.#getSingleColumnChange(prevTable, table));
|
|
442
|
-
}
|
|
433
|
+
// ALTER
|
|
434
|
+
const tables = intersection(prevTbl, nextTbl);
|
|
435
|
+
for (const id of tables) {
|
|
436
|
+
changes.push(...this.#getTableChanges(must(prevTbl.get(id)), must(nextTbl.get(id))));
|
|
443
437
|
}
|
|
444
|
-
//
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
const [dropped, created] = symmetricDifferences(prevTables, nextTables);
|
|
449
|
-
for (const id of dropped) {
|
|
450
|
-
const { schema, name } = must(prevTables.get(id));
|
|
451
|
-
changes.push({ tag: 'drop-table', id: { schema, name } });
|
|
452
|
-
}
|
|
453
|
-
for (const id of created) {
|
|
454
|
-
const spec = must(nextTables.get(id));
|
|
455
|
-
changes.push({ tag: 'create-table', spec });
|
|
456
|
-
}
|
|
438
|
+
// CREATE
|
|
439
|
+
for (const id of createdTbl) {
|
|
440
|
+
const spec = must(nextTbl.get(id));
|
|
441
|
+
changes.push({ tag: 'create-table', spec });
|
|
457
442
|
}
|
|
458
443
|
// Add indexes last since they may reference tables / columns that need
|
|
459
444
|
// to be created first.
|
|
460
|
-
for (const id of
|
|
461
|
-
const spec = must(
|
|
445
|
+
for (const id of createdIdx) {
|
|
446
|
+
const spec = must(nextIdx.get(id));
|
|
462
447
|
changes.push({ tag: 'create-index', spec });
|
|
463
448
|
}
|
|
464
449
|
return changes;
|
|
465
450
|
}
|
|
466
|
-
|
|
467
|
-
#getAddedOrDroppedColumnChanges(oldTable, newTable) {
|
|
468
|
-
const table = { schema: newTable.schema, name: newTable.name };
|
|
469
|
-
const [dropped, added] = symmetricDifferences(new Set(Object.keys(oldTable.columns)), new Set(Object.keys(newTable.columns)));
|
|
451
|
+
#getTableChanges(oldTable, newTable) {
|
|
470
452
|
const changes = [];
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
}
|
|
474
|
-
for (const name of added) {
|
|
453
|
+
if (oldTable.schema !== newTable.schema ||
|
|
454
|
+
oldTable.name !== newTable.name) {
|
|
475
455
|
changes.push({
|
|
476
|
-
tag: '
|
|
477
|
-
|
|
478
|
-
|
|
456
|
+
tag: 'rename-table',
|
|
457
|
+
old: { schema: oldTable.schema, name: oldTable.name },
|
|
458
|
+
new: { schema: newTable.schema, name: newTable.name },
|
|
479
459
|
});
|
|
480
460
|
}
|
|
481
|
-
return changes;
|
|
482
|
-
}
|
|
483
|
-
// ALTER TABLE can add, drop, or change/rename a single column.
|
|
484
|
-
#getSingleColumnChange(oldTable, newTable) {
|
|
485
461
|
const table = { schema: newTable.schema, name: newTable.name };
|
|
486
|
-
const
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
return [
|
|
494
|
-
{
|
|
495
|
-
tag: 'update-column',
|
|
496
|
-
table,
|
|
497
|
-
old: { name: oldName, spec: oldTable.columns[oldName] },
|
|
498
|
-
new: { name: newName, spec: newTable.columns[newName] },
|
|
499
|
-
},
|
|
500
|
-
];
|
|
501
|
-
}
|
|
502
|
-
else if (added.length) {
|
|
503
|
-
const name = added[0];
|
|
504
|
-
return [
|
|
505
|
-
{
|
|
506
|
-
tag: 'add-column',
|
|
507
|
-
table,
|
|
508
|
-
column: { name, spec: newTable.columns[name] },
|
|
509
|
-
},
|
|
510
|
-
];
|
|
511
|
-
}
|
|
512
|
-
else if (dropped.length) {
|
|
513
|
-
return [{ tag: 'drop-column', table, column: dropped[0] }];
|
|
462
|
+
const oldColumns = columnsByID(oldTable.columns);
|
|
463
|
+
const newColumns = columnsByID(newTable.columns);
|
|
464
|
+
// DROP
|
|
465
|
+
const [dropped, added] = symmetricDifferences(oldColumns, newColumns);
|
|
466
|
+
for (const id of dropped) {
|
|
467
|
+
const { name: column } = must(oldColumns.get(id));
|
|
468
|
+
changes.push({ tag: 'drop-column', table, column });
|
|
514
469
|
}
|
|
515
|
-
//
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
470
|
+
// ALTER
|
|
471
|
+
const both = intersection(oldColumns, newColumns);
|
|
472
|
+
for (const id of both) {
|
|
473
|
+
const { name: oldName, ...oldSpec } = must(oldColumns.get(id));
|
|
474
|
+
const { name: newName, ...newSpec } = must(newColumns.get(id));
|
|
475
|
+
// The three things that we care about are:
|
|
476
|
+
// 1. name
|
|
477
|
+
// 2. type
|
|
478
|
+
// 3. not-null
|
|
479
|
+
if (oldName !== newName ||
|
|
480
|
+
oldSpec.dataType !== newSpec.dataType ||
|
|
521
481
|
oldSpec.notNull !== newSpec.notNull) {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
},
|
|
529
|
-
];
|
|
482
|
+
changes.push({
|
|
483
|
+
tag: 'update-column',
|
|
484
|
+
table,
|
|
485
|
+
old: { name: oldName, spec: oldSpec },
|
|
486
|
+
new: { name: newName, spec: newSpec },
|
|
487
|
+
});
|
|
530
488
|
}
|
|
531
489
|
}
|
|
532
|
-
|
|
490
|
+
// ADD
|
|
491
|
+
for (const id of added) {
|
|
492
|
+
const { name, ...spec } = must(newColumns.get(id));
|
|
493
|
+
changes.push({ tag: 'add-column', table, column: { name, spec } });
|
|
494
|
+
}
|
|
495
|
+
return changes;
|
|
533
496
|
}
|
|
534
497
|
#parseReplicationEvent(content) {
|
|
535
498
|
const str = content instanceof Buffer
|
|
@@ -611,7 +574,8 @@ export function tablesDifferent(a, b) {
|
|
|
611
574
|
const [bname, bcol] = bcols[i];
|
|
612
575
|
return (aname !== bname ||
|
|
613
576
|
acol.pos !== bcol.pos ||
|
|
614
|
-
acol.typeOID !== bcol.typeOID
|
|
577
|
+
acol.typeOID !== bcol.typeOID ||
|
|
578
|
+
acol.notNull !== bcol.notNull);
|
|
615
579
|
}));
|
|
616
580
|
}
|
|
617
581
|
export function relationDifferent(a, b) {
|
|
@@ -639,14 +603,23 @@ function translateError(e) {
|
|
|
639
603
|
return e;
|
|
640
604
|
}
|
|
641
605
|
const idString = (id) => `${id.schema}.${id.name}`;
|
|
642
|
-
function
|
|
606
|
+
function specsByID(published) {
|
|
643
607
|
return [
|
|
644
608
|
// It would have been nice to use a CustomKeyMap here, but we rely on set-utils
|
|
645
609
|
// operations which use plain Sets.
|
|
646
|
-
new Map(published.tables.map(t => [
|
|
610
|
+
new Map(published.tables.map(t => [t.oid, t])),
|
|
647
611
|
new Map(published.indexes.map(i => [idString(i), i])),
|
|
648
612
|
];
|
|
649
613
|
}
|
|
614
|
+
function columnsByID(columns) {
|
|
615
|
+
const colsByID = new Map();
|
|
616
|
+
for (const [name, spec] of Object.entries(columns)) {
|
|
617
|
+
// The `pos` field is the `attnum` in `pg_attribute`, which is a stable
|
|
618
|
+
// identifier for the column in this table (i.e. never reused).
|
|
619
|
+
colsByID.set(spec.pos, { ...spec, name });
|
|
620
|
+
}
|
|
621
|
+
return colsByID;
|
|
622
|
+
}
|
|
650
623
|
class SSLUnsupportedError extends Error {
|
|
651
624
|
}
|
|
652
625
|
export class UnsupportedSchemaChangeError extends Error {
|