@serfab/quereus-plugin-sereus 1.19.1 → 1.20.0
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 +1 -1
- package/dist/app-schema.d.ts +30 -12
- package/dist/app-schema.js +95 -26
- package/dist/app-schema.js.map +1 -1
- package/dist/cached-storage.d.ts +3 -1
- package/dist/cached-storage.js +12 -2
- package/dist/cached-storage.js.map +1 -1
- package/dist/compose-strand.js +9 -5
- package/dist/compose-strand.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/plugin-browser.js +28 -28
- package/dist/plugin-browser.js.map +4 -4
- package/dist/types.d.ts +16 -8
- package/package.json +8 -8
- package/src/app-schema.ts +121 -30
- package/src/cached-storage.ts +13 -2
- package/src/compose-strand.ts +9 -5
- package/src/index.ts +1 -1
- package/src/types.ts +17 -8
package/README.md
CHANGED
|
@@ -276,7 +276,7 @@ The result's `onCommitDurability(listener)` is called after every commit that wr
|
|
|
276
276
|
|
|
277
277
|
### Offline mode
|
|
278
278
|
|
|
279
|
-
With `offline` given, the result's `offline` is the queue's controller (`enter()`, `exit()`, `whenDrained()`, `onStatus(listener)`, `entries()`, …), passed through from `@optimystic/quereus-plugin-optimystic` ([Offline mode](https://github.com/gotchoices/optimystic/blob/main/packages/quereus-plugin-optimystic/README.md#offline-mode--pluginoffline)); `offlineControllerOf(db)` finds it from the `Database`, and the status, state and error types are re-exported here. The `Strand` tables are always acknowledged by the network, and an `App` schema apply that queued transactions refuse is retried once they drain rather than failing the connect: the result's `appSchema` settles with how it ended, and `appSchemaDeferredBy` names the transactions that refused it. Both, and where the queue is saved, are in [strands.md → Offline mode](../../docs/strands.md#offline-mode).
|
|
279
|
+
With `offline` given, the result's `offline` is the queue's controller (`enter()`, `exit()`, `whenDrained()`, `onStatus(listener)`, `entries()`, …), passed through from `@optimystic/quereus-plugin-optimystic` ([Offline mode](https://github.com/gotchoices/optimystic/blob/main/packages/quereus-plugin-optimystic/README.md#offline-mode--pluginoffline)); `offlineControllerOf(db)` finds it from the `Database`, and the status, state and error types are re-exported here. The `Strand` tables are always acknowledged by the network, and an `App` schema apply that queued transactions refuse is retried once they drain rather than failing the connect: the result's `appSchema` settles with how it ended, `appSchemaWaitingFor` is `'queue'`, and `appSchemaDeferredBy` names the transactions that refused it. An apply that cannot reach the strand's cohort is deferred the same way, offline mode or not (`appSchemaWaitingFor: 'cohort'`). Both, and where the queue is saved, are in [strands.md → Offline mode](../../docs/strands.md#offline-mode).
|
|
280
280
|
|
|
281
281
|
### Founding a strand: `createEmptyCollections()`
|
|
282
282
|
|
package/dist/app-schema.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type Database } from '@quereus/quereus';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Libp2p } from '@libp2p/interface';
|
|
3
|
+
import type { StrandOfflineController, AppSchemaOutcome, AppSchemaWait } from './types.js';
|
|
3
4
|
/**
|
|
4
5
|
* Step 7 of `composeStrand`: declare the sApp's schema as `App` and apply it — a
|
|
5
6
|
* declarative diff against the catalog, so re-applying a schema that is already in place
|
|
6
7
|
* emits nothing. The one site that applies an `App` schema: `composeStrand` calls it at
|
|
7
|
-
* bring-up (through {@link
|
|
8
|
+
* bring-up (through {@link applyAppSchemaOrDefer}, whose deferred retry shares its
|
|
8
9
|
* declaration), and cadre-core's `StrandDatabase.attachAppSchema` calls it on a live storage
|
|
9
10
|
* replica when an app claims the strand. The database must already be composed (optimystic
|
|
10
11
|
* set as the default vtab), or the tables land in memory instead of the strand.
|
|
@@ -18,21 +19,38 @@ import type { StrandOfflineController, AppSchemaOutcome } from './types.js';
|
|
|
18
19
|
* the same key at once would collide. Rows an app needs at birth are the founding app's to write.
|
|
19
20
|
*/
|
|
20
21
|
export declare function applyAppSchema(db: Database, schema: string): Promise<void>;
|
|
21
|
-
/** What {@link
|
|
22
|
+
/** What {@link applyAppSchemaOrDefer} reports, in the shape `SereusPluginResult` carries it. */
|
|
22
23
|
export interface AppSchemaApply {
|
|
23
24
|
appSchema: Promise<AppSchemaOutcome>;
|
|
25
|
+
/** What the connect-time apply waits for. Present only when it was deferred. */
|
|
26
|
+
appSchemaWaitingFor?: AppSchemaWait;
|
|
27
|
+
/** The queued transaction ids that refused the connect-time apply. Present only when the queue refused it. */
|
|
24
28
|
appSchemaDeferredBy?: readonly string[];
|
|
25
29
|
}
|
|
30
|
+
/** The strand node's peer events, which a retry waiting for the cohort wakes on. */
|
|
31
|
+
export type PeerConnectEvents = Pick<Libp2p, 'addEventListener' | 'removeEventListener'>;
|
|
32
|
+
/** Where a deferred apply waits: the offline queue, when there is one, and the strand node, when there is one. */
|
|
33
|
+
export interface AppSchemaWaits {
|
|
34
|
+
queue?: Pick<StrandOfflineController, 'whenDrained'>;
|
|
35
|
+
peers?: PeerConnectEvents;
|
|
36
|
+
}
|
|
26
37
|
/**
|
|
27
|
-
* Step 7 of `composeStrand`: {@link applyAppSchema}, except that an apply refused
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
38
|
+
* Step 7 of `composeStrand`: {@link applyAppSchema}, except that an apply refused for a reason
|
|
39
|
+
* that passes does not throw. Two such reasons:
|
|
40
|
+
*
|
|
41
|
+
* - queued offline transactions wrote a table the apply changes (`QueuedEntriesBlockSchemaChangeError`);
|
|
42
|
+
* retried each time the queue drains;
|
|
43
|
+
* - the strand's cohort could not be reached (Optimystic's `classifyCommitFailure` says
|
|
44
|
+
* `cohort-unreachable`): an apply writes the strand's catalog, which needs the cohort, so a member
|
|
45
|
+
* alone after an app update would otherwise not open the strand at all (gotchoices/sereus#55).
|
|
46
|
+
* Retried when the strand node connects to a peer, and on a backoff ({@link COHORT_RETRY_MS}).
|
|
47
|
+
*
|
|
48
|
+
* Quereus unwinds a refused apply, so `db` keeps the `App` schema it had, and `appSchema` settles
|
|
49
|
+
* with how the retries ended. Any other error from the first apply is thrown.
|
|
32
50
|
*
|
|
33
|
-
* Waiting
|
|
34
|
-
*
|
|
35
|
-
*
|
|
51
|
+
* Waiting before returning was rejected: that withholds the strand from the app right after an app
|
|
52
|
+
* update, which is when a phone is most likely to be offline. So was refusing the connect: the queue
|
|
53
|
+
* can drain only while the composition is alive.
|
|
36
54
|
*
|
|
37
55
|
* `released` is aborted when the composition shuts down; a retry not yet landed then settles
|
|
38
56
|
* `cancelled`.
|
|
@@ -42,4 +60,4 @@ export interface AppSchemaApply {
|
|
|
42
60
|
* apply would be committed or rolled back with the app's rows, and a rollback leaves the index it
|
|
43
61
|
* built holding entries for rows that are gone.
|
|
44
62
|
*/
|
|
45
|
-
export declare function
|
|
63
|
+
export declare function applyAppSchemaOrDefer(db: Database, schema: string, waits: AppSchemaWaits, released: AbortSignal): Promise<AppSchemaApply>;
|
package/dist/app-schema.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import debug from 'debug';
|
|
2
2
|
import { TransactionActiveError } from '@quereus/quereus';
|
|
3
|
+
import { classifyCommitFailure } from '@optimystic/db-core';
|
|
3
4
|
import { QueuedEntriesBlockSchemaChangeError, QueueDisposedError } from '@optimystic/quereus-plugin-optimystic/plugin';
|
|
4
5
|
const log = debug('sereus:plugin:strand');
|
|
5
6
|
/**
|
|
6
7
|
* Step 7 of `composeStrand`: declare the sApp's schema as `App` and apply it — a
|
|
7
8
|
* declarative diff against the catalog, so re-applying a schema that is already in place
|
|
8
9
|
* emits nothing. The one site that applies an `App` schema: `composeStrand` calls it at
|
|
9
|
-
* bring-up (through {@link
|
|
10
|
+
* bring-up (through {@link applyAppSchemaOrDefer}, whose deferred retry shares its
|
|
10
11
|
* declaration), and cadre-core's `StrandDatabase.attachAppSchema` calls it on a live storage
|
|
11
12
|
* replica when an app claims the strand. The database must already be composed (optimystic
|
|
12
13
|
* set as the default vtab), or the tables land in memory instead of the strand.
|
|
@@ -34,15 +35,22 @@ async function declareAppSchema(db, schema) {
|
|
|
34
35
|
assertNoSeedItems(db);
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
|
-
* Step 7 of `composeStrand`: {@link applyAppSchema}, except that an apply refused
|
|
38
|
-
*
|
|
39
|
-
* throw. Quereus unwinds the refused apply, so `db` keeps the `App` schema it had; the apply is
|
|
40
|
-
* retried in the background each time `queue` drains, for as long as the queue is what refuses it,
|
|
41
|
-
* and `appSchema` settles with how that ended. Any other error from the first apply is thrown.
|
|
38
|
+
* Step 7 of `composeStrand`: {@link applyAppSchema}, except that an apply refused for a reason
|
|
39
|
+
* that passes does not throw. Two such reasons:
|
|
42
40
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* the
|
|
41
|
+
* - queued offline transactions wrote a table the apply changes (`QueuedEntriesBlockSchemaChangeError`);
|
|
42
|
+
* retried each time the queue drains;
|
|
43
|
+
* - the strand's cohort could not be reached (Optimystic's `classifyCommitFailure` says
|
|
44
|
+
* `cohort-unreachable`): an apply writes the strand's catalog, which needs the cohort, so a member
|
|
45
|
+
* alone after an app update would otherwise not open the strand at all (gotchoices/sereus#55).
|
|
46
|
+
* Retried when the strand node connects to a peer, and on a backoff ({@link COHORT_RETRY_MS}).
|
|
47
|
+
*
|
|
48
|
+
* Quereus unwinds a refused apply, so `db` keeps the `App` schema it had, and `appSchema` settles
|
|
49
|
+
* with how the retries ended. Any other error from the first apply is thrown.
|
|
50
|
+
*
|
|
51
|
+
* Waiting before returning was rejected: that withholds the strand from the app right after an app
|
|
52
|
+
* update, which is when a phone is most likely to be offline. So was refusing the connect: the queue
|
|
53
|
+
* can drain only while the composition is alive.
|
|
46
54
|
*
|
|
47
55
|
* `released` is aborted when the composition shuts down; a retry not yet landed then settles
|
|
48
56
|
* `cancelled`.
|
|
@@ -52,31 +60,34 @@ async function declareAppSchema(db, schema) {
|
|
|
52
60
|
* apply would be committed or rolled back with the app's rows, and a rollback leaves the index it
|
|
53
61
|
* built holding entries for rows that are gone.
|
|
54
62
|
*/
|
|
55
|
-
export async function
|
|
63
|
+
export async function applyAppSchemaOrDefer(db, schema, waits, released) {
|
|
56
64
|
try {
|
|
57
65
|
await applyAppSchema(db, schema);
|
|
58
66
|
log('sApp schema applied');
|
|
59
67
|
return { appSchema: Promise.resolve({ state: 'applied' }) };
|
|
60
68
|
}
|
|
61
69
|
catch (err) {
|
|
62
|
-
const
|
|
63
|
-
if (!
|
|
70
|
+
const deferral = deferralOf(err);
|
|
71
|
+
if (!deferral) {
|
|
64
72
|
throw err;
|
|
65
73
|
}
|
|
66
|
-
|
|
74
|
+
logDeferral('sApp schema apply', deferral);
|
|
67
75
|
return {
|
|
68
|
-
appSchema:
|
|
69
|
-
|
|
76
|
+
appSchema: retryDeferredAppSchema(db, schema, deferral, waits, released),
|
|
77
|
+
appSchemaWaitingFor: deferral.wait,
|
|
78
|
+
...(deferral.wait === 'queue' && { appSchemaDeferredBy: deferral.transactionIds }),
|
|
70
79
|
};
|
|
71
80
|
}
|
|
72
81
|
}
|
|
73
|
-
async function
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// as undrained, so no such state is known; if one shows up as a busy loop, back off between tries.
|
|
82
|
+
async function retryDeferredAppSchema(db, schema, first, waits, released) {
|
|
83
|
+
let deferral = first;
|
|
84
|
+
let cohortRetries = 0;
|
|
77
85
|
for (;;) {
|
|
78
86
|
try {
|
|
79
|
-
await
|
|
87
|
+
await nextChance(deferral, waits, cohortRetries, released);
|
|
88
|
+
if (deferral.wait === 'cohort') {
|
|
89
|
+
cohortRetries++;
|
|
90
|
+
}
|
|
80
91
|
if (released.aborted) {
|
|
81
92
|
return { state: 'cancelled' };
|
|
82
93
|
}
|
|
@@ -95,24 +106,82 @@ async function retryAppSchemaAfterDrain(db, schema, queue, released) {
|
|
|
95
106
|
await abortableDelay(OPEN_TRANSACTION_RETRY_MS, released);
|
|
96
107
|
continue;
|
|
97
108
|
}
|
|
98
|
-
const
|
|
99
|
-
if (!
|
|
109
|
+
const again = deferralOf(err);
|
|
110
|
+
if (!again) {
|
|
100
111
|
log('Deferred sApp schema apply failed: %O', err);
|
|
101
112
|
return { state: 'failed', error: err };
|
|
102
113
|
}
|
|
103
|
-
|
|
114
|
+
logDeferral('Deferred sApp schema apply', again);
|
|
115
|
+
deferral = again;
|
|
104
116
|
}
|
|
105
117
|
}
|
|
106
118
|
}
|
|
107
|
-
/**
|
|
108
|
-
function
|
|
119
|
+
/** Waits for whatever may get the retry past `deferral`. */
|
|
120
|
+
async function nextChance(deferral, waits, cohortRetries, released) {
|
|
121
|
+
if (deferral.wait === 'queue' && waits.queue) {
|
|
122
|
+
// NOTE: this loops without a pause when `whenDrained` resolves at once while the refusal stands
|
|
123
|
+
// (a segment left sealed with nothing queued, say). Upstream counts a removal still in progress
|
|
124
|
+
// as undrained, so no such state is known; if one shows up as a busy loop, back off between tries.
|
|
125
|
+
await waits.queue.whenDrained();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
await nextCohortChance(waits.peers, cohortRetryDelay(cohortRetries), released);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The refusal `err` is or wraps, when a later retry can get past it: Quereus rewraps an error out of
|
|
132
|
+
* `apply schema`, keeping it as `cause`.
|
|
133
|
+
*/
|
|
134
|
+
function deferralOf(err) {
|
|
109
135
|
for (let at = err; at instanceof Error; at = at.cause) {
|
|
110
136
|
if (at instanceof QueuedEntriesBlockSchemaChangeError) {
|
|
111
|
-
return at;
|
|
137
|
+
return { wait: 'queue', transactionIds: at.transactionIds };
|
|
138
|
+
}
|
|
139
|
+
if (classifyCommitFailure(at).kind === 'cohort-unreachable') {
|
|
140
|
+
return { wait: 'cohort' };
|
|
112
141
|
}
|
|
113
142
|
}
|
|
114
143
|
return undefined;
|
|
115
144
|
}
|
|
145
|
+
function logDeferral(what, deferral) {
|
|
146
|
+
if (deferral.wait === 'queue') {
|
|
147
|
+
log('%s refused by queued transactions %o; retrying once they settle', what, deferral.transactionIds);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
log('%s could not reach the strand cohort; retrying when a peer connects', what);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Backoff for a retry waiting for the cohort, by how many came before it. A connect wakes the retry
|
|
155
|
+
* sooner, so the backoff only bounds how long a missed or too-early connect leaves the schema behind.
|
|
156
|
+
*/
|
|
157
|
+
const COHORT_RETRY_MS = [15000, 30000, 60000, 120000, 300000];
|
|
158
|
+
function cohortRetryDelay(retriesBefore) {
|
|
159
|
+
return COHORT_RETRY_MS[Math.min(retriesBefore, COHORT_RETRY_MS.length - 1)];
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* How long a retry woken by a connect waits first, so the peer is identified and in the ring before
|
|
163
|
+
* the apply asks for its cohort; a retry that still finds it missing waits for the next chance.
|
|
164
|
+
*/
|
|
165
|
+
const COHORT_CONNECT_SETTLE_MS = 2000;
|
|
166
|
+
/** Resolves {@link COHORT_CONNECT_SETTLE_MS} after the strand node's next peer connect, after `delayMs`, or when `signal` aborts. */
|
|
167
|
+
async function nextCohortChance(peers, delayMs, signal) {
|
|
168
|
+
const byConnect = await new Promise(resolve => {
|
|
169
|
+
const done = (connected) => {
|
|
170
|
+
clearTimeout(timer);
|
|
171
|
+
peers?.removeEventListener('peer:connect', onConnect);
|
|
172
|
+
signal.removeEventListener('abort', onAbort);
|
|
173
|
+
resolve(connected);
|
|
174
|
+
};
|
|
175
|
+
const onConnect = () => done(true);
|
|
176
|
+
const onAbort = () => done(false);
|
|
177
|
+
const timer = setTimeout(() => done(false), delayMs);
|
|
178
|
+
peers?.addEventListener('peer:connect', onConnect);
|
|
179
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
180
|
+
});
|
|
181
|
+
if (byConnect) {
|
|
182
|
+
await abortableDelay(COHORT_CONNECT_SETTLE_MS, signal);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
116
185
|
/** How long a deferred sApp schema apply waits before trying again while another caller's transaction is open. */
|
|
117
186
|
const OPEN_TRANSACTION_RETRY_MS = 250;
|
|
118
187
|
/** Resolves after `ms`, or as soon as `signal` aborts. */
|
package/dist/app-schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-schema.js","sourceRoot":"","sources":["../src/app-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAiB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"app-schema.js","sourceRoot":"","sources":["../src/app-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAiB,MAAM,kBAAkB,CAAC;AAEzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,mCAAmC,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAGvH,MAAM,GAAG,GAAG,KAAK,CAAC,sBAAsB,CAAC,CAAC;AAE1C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EAAY,EAAE,MAAc;IAChE,MAAM,gBAAgB,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACnC,MAAM,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;AACpC,CAAC;AAED,kHAAkH;AAClH,KAAK,UAAU,gBAAgB,CAAC,EAAY,EAAE,MAAc;IAC3D,MAAM,EAAE,CAAC,IAAI,CAAC;;KAEV,MAAM;;EAET,CAAC,CAAC;IACH,oBAAoB,CAAC,EAAE,CAAC,CAAC;IACzB,iBAAiB,CAAC,EAAE,CAAC,CAAC;AACvB,CAAC;AAuBD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAC1C,EAAY,EACZ,MAAc,EACd,KAAqB,EACrB,QAAqB;IAErB,IAAI,CAAC;QACJ,MAAM,cAAc,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QACjC,GAAG,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C,CAAC;QACnC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,EAAY;IACrC,OAAO,EAAE,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;AACvE,CAAC;AAED,SAAS,oBAAoB,CAAC,EAAY;IACzC,MAAM,OAAO,GAAG,gBAAgB,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,gBAAgB,CAAC,CAAC,MAAM,CAAC;IAC3F,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QACjB,oEAAoE;QACpE,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,oNAAoN,CAAC,CAAC;IACjQ,CAAC;AACF,CAAC;AAED,SAAS,iBAAiB,CAAC,EAAY;IACtC,uFAAuF;IACvF,MAAM,MAAM,GAAG,gBAAgB,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1G,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,6CAA6C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,8HAA8H,CAAC,CAAC;IAC/M,CAAC;AACF,CAAC"}
|
package/dist/cached-storage.d.ts
CHANGED
|
@@ -29,7 +29,9 @@
|
|
|
29
29
|
* backend, which is the invariant's other half.
|
|
30
30
|
*
|
|
31
31
|
* `MemoryRawStorage` is returned unwrapped on upstream's own guidance: the backend
|
|
32
|
-
* is already in-memory, so the cache adds bookkeeping with nothing to save.
|
|
32
|
+
* is already in-memory, so the cache adds bookkeeping with nothing to save. So is a
|
|
33
|
+
* storage that reports `readCached` with a cache of its own (React Native's
|
|
34
|
+
* `LevelDBRawStorage`), which upstream refuses to have wrapped again.
|
|
33
35
|
*
|
|
34
36
|
* **{@link wrapStorageWithCache} and {@link disposeStorageCache} are a matched pair
|
|
35
37
|
* with a holder count between them.** Every wrap that hands back a cache this module
|
package/dist/cached-storage.js
CHANGED
|
@@ -29,7 +29,9 @@
|
|
|
29
29
|
* backend, which is the invariant's other half.
|
|
30
30
|
*
|
|
31
31
|
* `MemoryRawStorage` is returned unwrapped on upstream's own guidance: the backend
|
|
32
|
-
* is already in-memory, so the cache adds bookkeeping with nothing to save.
|
|
32
|
+
* is already in-memory, so the cache adds bookkeeping with nothing to save. So is a
|
|
33
|
+
* storage that reports `readCached` with a cache of its own (React Native's
|
|
34
|
+
* `LevelDBRawStorage`), which upstream refuses to have wrapped again.
|
|
33
35
|
*
|
|
34
36
|
* **{@link wrapStorageWithCache} and {@link disposeStorageCache} are a matched pair
|
|
35
37
|
* with a holder count between them.** Every wrap that hands back a cache this module
|
|
@@ -86,6 +88,14 @@ function addHolder(wrapped) {
|
|
|
86
88
|
claim.holders += 1;
|
|
87
89
|
}
|
|
88
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* A storage that carries its own read cache and is not one of this module's wrappers, such as
|
|
93
|
+
* the React Native `LevelDBRawStorage`. Upstream refuses a second cache over it
|
|
94
|
+
* (`redundant read cache`), and it stays its creator's to close.
|
|
95
|
+
*/
|
|
96
|
+
function isOwnReadCache(storage) {
|
|
97
|
+
return storage.readCached === true && !(storage instanceof CachedRawStorage);
|
|
98
|
+
}
|
|
89
99
|
/**
|
|
90
100
|
* The cached view of `storage`, memoized per instance, with one holder claim taken for
|
|
91
101
|
* this caller — release it with {@link disposeStorageCache} when this caller's scope
|
|
@@ -94,7 +104,7 @@ function addHolder(wrapped) {
|
|
|
94
104
|
* one backend is the failure that matters and a stale pool label is not.
|
|
95
105
|
*/
|
|
96
106
|
export function wrapStorageWithCache(storage, label) {
|
|
97
|
-
if (storage instanceof MemoryRawStorage) {
|
|
107
|
+
if (storage instanceof MemoryRawStorage || isOwnReadCache(storage)) {
|
|
98
108
|
return storage;
|
|
99
109
|
}
|
|
100
110
|
if (storage instanceof CachedRawStorage) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cached-storage.js","sourceRoot":"","sources":["../src/cached-storage.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cached-storage.js","sourceRoot":"","sources":["../src/cached-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AAEH,6EAA6E;AAC7E,gFAAgF;AAChF,4EAA4E;AAC5E,kEAAkE;AAClE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAoB,MAAM,uBAAuB,CAAC;AAE7F,MAAM,KAAK,GAAG,IAAI,OAAO,EAAiC,CAAC;AAmB3D,MAAM,MAAM,GAAG,IAAI,OAAO,EAAgC,CAAC;AAE3D;;;;GAIG;AACH,SAAS,SAAS,CAAC,OAAyB;IAC3C,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,KAAK,EAAE,CAAC;QACX,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;IACpB,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,SAAS,cAAc,CAAC,OAAoB;IAC3C,OAAO,OAAO,CAAC,UAAU,KAAK,IAAI,IAAI,CAAC,CAAC,OAAO,YAAY,gBAAgB,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAoB,EAAE,KAAa;IACvE,IAAI,OAAO,YAAY,gBAAgB,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;QACpE,O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K,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1B,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;AACzB,CAAC"}
|
package/dist/compose-strand.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import debug from 'debug';
|
|
2
2
|
import optimysticPlugin from '@optimystic/quereus-plugin-optimystic/plugin';
|
|
3
|
-
import {
|
|
3
|
+
import { applyAppSchemaOrDefer } from './app-schema.js';
|
|
4
4
|
import { STRAND_SCHEMA } from './strand-schema.js';
|
|
5
5
|
import { resolveStrandClusterSize, STRAND_CLUSTER_POLICY } from './cluster-size.js';
|
|
6
6
|
import { wrapStorageWithCache, disposeStorageCache } from './cached-storage.js';
|
|
@@ -151,6 +151,8 @@ export async function composeStrand(db, options, platform) {
|
|
|
151
151
|
const released = new AbortController();
|
|
152
152
|
let appSchemaApply;
|
|
153
153
|
let createdNode = null;
|
|
154
|
+
// The strand node, when there is one: a deferred sApp schema apply waiting for the cohort wakes on its connects.
|
|
155
|
+
let peers;
|
|
154
156
|
let hydrated;
|
|
155
157
|
try {
|
|
156
158
|
// 3. Acquire the libp2p node. Skip only when this is the unit-test fake
|
|
@@ -186,6 +188,7 @@ export async function composeStrand(db, options, platform) {
|
|
|
186
188
|
coordinatedRepo = repo;
|
|
187
189
|
log('Created libp2p node (port: %d, fretProfile: %s, storage=%s)', port, fretProfile, !!storage);
|
|
188
190
|
}
|
|
191
|
+
peers = node;
|
|
189
192
|
collectionFactory.registerLibp2pNode(networkName, node, coordinatedRepo);
|
|
190
193
|
log('Registered libp2p node with collection factory');
|
|
191
194
|
}
|
|
@@ -250,12 +253,13 @@ export async function composeStrand(db, options, platform) {
|
|
|
250
253
|
// migrated instead of restored. No schema in this repo evolves that way, so this
|
|
251
254
|
// is a note for whoever first ships a migration that does.
|
|
252
255
|
//
|
|
253
|
-
// The
|
|
254
|
-
// connect. The strand comes up on the `App`
|
|
255
|
-
// queue drains (see
|
|
256
|
+
// The exception: an apply refused by queued offline transactions, or because the strand's
|
|
257
|
+
// cohort could not be reached, does not fail the connect. The strand comes up on the `App`
|
|
258
|
+
// schema it had, and the apply is retried as the queue drains or when a peer connects (see
|
|
259
|
+
// `applyAppSchemaOrDefer`).
|
|
256
260
|
if (schema) {
|
|
257
261
|
log('Applying sApp schema for strand %s', strandId);
|
|
258
|
-
appSchemaApply = await
|
|
262
|
+
appSchemaApply = await applyAppSchemaOrDefer(db, schema, { queue: pluginResult.offline, peers }, released.signal);
|
|
259
263
|
}
|
|
260
264
|
}
|
|
261
265
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose-strand.js","sourceRoot":"","sources":["../src/compose-strand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,gBAAgB,MAAM,8CAA8C,CAAC;AAS5E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"compose-strand.js","sourceRoot":"","sources":["../src/compose-strand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,gBAAgB,MAAM,8CAA8C,CAAC;AAS5E,OAAO,EAAE,qBAAqB,EAA+C,MAAM,iBAAiB,CAAC;AACrG,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAiC,MAAM,wBAAwB,CAAC;AAE/F,MAAM,GAAG,GAAG,KAAK,CAAC,sBAAsB,CAAC,CAAC;AAC1C,MAAM,MAAM,GAAG,KAAK,CAAC,6BAA6B,CAAC,CAAC;AAEpD,wGAAwG;AACxG,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAU,CAAC;AAEnD,yGAAyG;AACzG,MAAM,kBA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,CAAC,OAAO,EAAE,CAAC;QAC7D,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC/B,YAAY,CAAC,iBAAiB,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC;IAChD,CAAC;IACD,2FAA2F;IAC3F,+FAA+F;IAC/F,yFAAyF;IACzF,8FAA8F;IAC9F,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,YAAY,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IACvC,CAAC;IACD,mFAAmF;IACnF,qFAAqF;IACrF,+DAA+D;IAC/D,MAAM,YAAY,GAAG,gBAAgB,CACpC,EAAE,EACF,YAAiE,CAC5B,CAAC;IACvC,kBAAkB,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;IACrC,GAAG,CAAC,6CAA6C,CAAC,CAAC;IACnD,OAAO,YAAY,CAAC;AACrB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { applyAppSchema } from './app-schema.js';
|
|
|
4
4
|
export { createEmptyCollections, type CollectionRegistrySource } from './empty-collections.js';
|
|
5
5
|
export { MIN_CLUSTER_SIZE, COHORT_READ_DEADLINE_MS, CONTROL_REPLICATION_BREADTH, CONTROL_CLUSTER_POLICY, DEFAULT_STRAND_CLUSTER_SIZE, STRAND_CLUSTER_POLICY, resolveStrandClusterSize, resolveRepairYardstick, controlClusterPolicy, strandClusterPolicy } from './cluster-size.js';
|
|
6
6
|
export { wrapStorageWithCache, disposeStorageCache } from './cached-storage.js';
|
|
7
|
-
export type { StrandConnectionOptions, SereusPluginResult, StrandTransactor, StrandOfflineOptions, StrandOfflineController, AppSchemaOutcome, } from './types.js';
|
|
7
|
+
export type { StrandConnectionOptions, SereusPluginResult, StrandTransactor, StrandOfflineOptions, StrandOfflineController, AppSchemaOutcome, AppSchemaWait, } from './types.js';
|
|
8
8
|
export type { SqlCommitDurability, CommitFullyHeld } from '@optimystic/quereus-plugin-optimystic/plugin';
|
|
9
9
|
export { OfflineCommitTimeoutError, QueuedEntriesBlockSchemaChangeError, EntryNotDiscardableError, UnknownEntryError, QueueDisposedError, OfflineJournalError, } from '@optimystic/quereus-plugin-optimystic/plugin';
|
|
10
10
|
export type { QueuedTransactionStatus, OfflineModeState, CommitOutlook } from '@optimystic/quereus-plugin-optimystic/plugin';
|