@fluidframework/container-runtime 2.0.0-internal.2.2.1 → 2.0.0-internal.2.3.1
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/.eslintrc.js +19 -8
- package/dist/batchTracker.d.ts +1 -2
- package/dist/batchTracker.d.ts.map +1 -1
- package/dist/batchTracker.js.map +1 -1
- package/dist/blobManager.d.ts +45 -34
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js +135 -102
- package/dist/blobManager.js.map +1 -1
- package/dist/containerRuntime.d.ts +54 -8
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +143 -72
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStoreContext.d.ts +1 -1
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +6 -8
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStores.d.ts +12 -9
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/dataStores.js +41 -35
- package/dist/dataStores.js.map +1 -1
- package/dist/garbageCollection.d.ts +41 -20
- package/dist/garbageCollection.d.ts.map +1 -1
- package/dist/garbageCollection.js +205 -150
- package/dist/garbageCollection.js.map +1 -1
- package/dist/garbageCollectionConstants.d.ts +7 -3
- package/dist/garbageCollectionConstants.d.ts.map +1 -1
- package/dist/garbageCollectionConstants.js +10 -8
- package/dist/garbageCollectionConstants.js.map +1 -1
- package/dist/garbageCollectionTombstoneUtils.d.ts +14 -0
- package/dist/garbageCollectionTombstoneUtils.d.ts.map +1 -0
- package/dist/garbageCollectionTombstoneUtils.js +23 -0
- package/dist/garbageCollectionTombstoneUtils.js.map +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/dist/opLifecycle/batchManager.d.ts +13 -1
- package/dist/opLifecycle/batchManager.d.ts.map +1 -1
- package/dist/opLifecycle/batchManager.js +35 -1
- package/dist/opLifecycle/batchManager.js.map +1 -1
- package/dist/opLifecycle/definitions.d.ts +25 -1
- package/dist/opLifecycle/definitions.d.ts.map +1 -1
- package/dist/opLifecycle/definitions.js.map +1 -1
- package/dist/opLifecycle/index.d.ts +2 -2
- package/dist/opLifecycle/index.d.ts.map +1 -1
- package/dist/opLifecycle/index.js +2 -1
- package/dist/opLifecycle/index.js.map +1 -1
- package/dist/opLifecycle/opCompressor.d.ts +1 -1
- package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
- package/dist/opLifecycle/opCompressor.js +24 -10
- package/dist/opLifecycle/opCompressor.js.map +1 -1
- package/dist/opLifecycle/opDecompressor.d.ts +2 -1
- package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
- package/dist/opLifecycle/opDecompressor.js +30 -17
- package/dist/opLifecycle/opDecompressor.js.map +1 -1
- package/dist/opLifecycle/opSplitter.d.ts +34 -2
- package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
- package/dist/opLifecycle/opSplitter.js +114 -5
- package/dist/opLifecycle/opSplitter.js.map +1 -1
- package/dist/opLifecycle/outbox.d.ts +5 -0
- package/dist/opLifecycle/outbox.d.ts.map +1 -1
- package/dist/opLifecycle/outbox.js +24 -14
- package/dist/opLifecycle/outbox.js.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.js +17 -2
- package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/runningSummarizer.d.ts.map +1 -1
- package/dist/runningSummarizer.js +0 -1
- package/dist/runningSummarizer.js.map +1 -1
- package/dist/scheduleManager.d.ts +0 -1
- package/dist/scheduleManager.d.ts.map +1 -1
- package/dist/scheduleManager.js +9 -20
- package/dist/scheduleManager.js.map +1 -1
- package/dist/summarizer.d.ts +0 -1
- package/dist/summarizer.d.ts.map +1 -1
- package/dist/summarizer.js +2 -1
- package/dist/summarizer.js.map +1 -1
- package/dist/summarizerTypes.d.ts +1 -0
- package/dist/summarizerTypes.d.ts.map +1 -1
- package/dist/summarizerTypes.js.map +1 -1
- package/dist/summaryFormat.d.ts.map +1 -1
- package/dist/summaryFormat.js +1 -2
- package/dist/summaryFormat.js.map +1 -1
- package/lib/batchTracker.d.ts +1 -2
- package/lib/batchTracker.d.ts.map +1 -1
- package/lib/batchTracker.js.map +1 -1
- package/lib/blobManager.d.ts +45 -34
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js +137 -104
- package/lib/blobManager.js.map +1 -1
- package/lib/containerRuntime.d.ts +54 -8
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +140 -69
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStoreContext.d.ts +1 -1
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +7 -9
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStores.d.ts +12 -9
- package/lib/dataStores.d.ts.map +1 -1
- package/lib/dataStores.js +44 -38
- package/lib/dataStores.js.map +1 -1
- package/lib/garbageCollection.d.ts +41 -20
- package/lib/garbageCollection.d.ts.map +1 -1
- package/lib/garbageCollection.js +201 -146
- package/lib/garbageCollection.js.map +1 -1
- package/lib/garbageCollectionConstants.d.ts +7 -3
- package/lib/garbageCollectionConstants.d.ts.map +1 -1
- package/lib/garbageCollectionConstants.js +9 -7
- package/lib/garbageCollectionConstants.js.map +1 -1
- package/lib/garbageCollectionTombstoneUtils.d.ts +14 -0
- package/lib/garbageCollectionTombstoneUtils.d.ts.map +1 -0
- package/lib/garbageCollectionTombstoneUtils.js +19 -0
- package/lib/garbageCollectionTombstoneUtils.js.map +1 -0
- package/lib/index.d.ts +1 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/lib/opLifecycle/batchManager.d.ts +13 -1
- package/lib/opLifecycle/batchManager.d.ts.map +1 -1
- package/lib/opLifecycle/batchManager.js +35 -1
- package/lib/opLifecycle/batchManager.js.map +1 -1
- package/lib/opLifecycle/definitions.d.ts +25 -1
- package/lib/opLifecycle/definitions.d.ts.map +1 -1
- package/lib/opLifecycle/definitions.js.map +1 -1
- package/lib/opLifecycle/index.d.ts +2 -2
- package/lib/opLifecycle/index.d.ts.map +1 -1
- package/lib/opLifecycle/index.js +1 -1
- package/lib/opLifecycle/index.js.map +1 -1
- package/lib/opLifecycle/opCompressor.d.ts +1 -1
- package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
- package/lib/opLifecycle/opCompressor.js +24 -10
- package/lib/opLifecycle/opCompressor.js.map +1 -1
- package/lib/opLifecycle/opDecompressor.d.ts +2 -1
- package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
- package/lib/opLifecycle/opDecompressor.js +30 -17
- package/lib/opLifecycle/opDecompressor.js.map +1 -1
- package/lib/opLifecycle/opSplitter.d.ts +34 -2
- package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
- package/lib/opLifecycle/opSplitter.js +112 -4
- package/lib/opLifecycle/opSplitter.js.map +1 -1
- package/lib/opLifecycle/outbox.d.ts +5 -0
- package/lib/opLifecycle/outbox.d.ts.map +1 -1
- package/lib/opLifecycle/outbox.js +24 -14
- package/lib/opLifecycle/outbox.js.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.js +17 -2
- package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/runningSummarizer.d.ts.map +1 -1
- package/lib/runningSummarizer.js +0 -1
- package/lib/runningSummarizer.js.map +1 -1
- package/lib/scheduleManager.d.ts +0 -1
- package/lib/scheduleManager.d.ts.map +1 -1
- package/lib/scheduleManager.js +9 -20
- package/lib/scheduleManager.js.map +1 -1
- package/lib/summarizer.d.ts +0 -1
- package/lib/summarizer.d.ts.map +1 -1
- package/lib/summarizer.js +2 -1
- package/lib/summarizer.js.map +1 -1
- package/lib/summarizerTypes.d.ts +1 -0
- package/lib/summarizerTypes.d.ts.map +1 -1
- package/lib/summarizerTypes.js.map +1 -1
- package/lib/summaryFormat.d.ts.map +1 -1
- package/lib/summaryFormat.js +1 -2
- package/lib/summaryFormat.js.map +1 -1
- package/package.json +20 -19
- package/src/batchTracker.ts +1 -1
- package/src/blobManager.ts +159 -111
- package/src/containerRuntime.ts +202 -73
- package/src/dataStoreContext.ts +15 -16
- package/src/dataStores.ts +61 -45
- package/src/garbageCollection.ts +258 -183
- package/src/garbageCollectionConstants.ts +10 -7
- package/src/garbageCollectionTombstoneUtils.ts +28 -0
- package/src/index.ts +2 -5
- package/src/opLifecycle/batchManager.ts +59 -1
- package/src/opLifecycle/definitions.ts +27 -1
- package/src/opLifecycle/index.ts +2 -1
- package/src/opLifecycle/opCompressor.ts +29 -12
- package/src/opLifecycle/opDecompressor.ts +39 -18
- package/src/opLifecycle/opSplitter.ts +141 -7
- package/src/opLifecycle/outbox.ts +32 -16
- package/src/opLifecycle/remoteMessageProcessor.ts +19 -3
- package/src/packageVersion.ts +1 -1
- package/src/runningSummarizer.ts +0 -1
- package/src/scheduleManager.ts +19 -30
- package/src/summarizer.ts +1 -1
- package/src/summarizerTypes.ts +1 -0
- package/src/summaryFormat.ts +1 -2
package/lib/blobManager.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blobManager.d.ts","sourceRoot":"","sources":["../src/blobManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAuB,yBAAyB,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAOrH,OAAO,E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AE,MAAM,KAAK,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,GAC1D,OAAO,CAAC,oBAAoB,CAAC;IAchC;;OAEG;IACH,OAAO,CAAC,IAAI;IAgBZ;;;;;OAKG;IACI,SAAS,CAAC,MAAM,GAAE,OAAe,GAAG,sBAAsB;IASjE;;;OAGG;IACI,kBAAkB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,IAAI;IAcvD;;;;OAIG;IACI,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,EAAE;IA0BjD,SAAS,CAAC,gBAAgB,CAAC,EAAE,iBAAiB,GAAG,qBAAqB;IAqBtE,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAa3C,eAAe,IAAI,aAAa;CAO1C"}
|
package/lib/blobManager.js
CHANGED
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { v4 as uuid } from "uuid";
|
|
6
6
|
import { createResponseError, generateHandleContextPath, responseToException, SummaryTreeBuilder, } from "@fluidframework/runtime-utils";
|
|
7
|
-
import { assert, bufferToString, Deferred, stringToBuffer } from "@fluidframework/common-utils";
|
|
7
|
+
import { assert, bufferToString, Deferred, stringToBuffer, TypedEventEmitter } from "@fluidframework/common-utils";
|
|
8
8
|
import { AttachState } from "@fluidframework/container-definitions";
|
|
9
9
|
import { ChildLogger, loggerToMonitoringContext, PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
10
10
|
import { Throttler, formExponentialFn } from "./throttler";
|
|
11
11
|
import { summarizerClientType } from "./summarizerClientElection";
|
|
12
|
-
import {
|
|
12
|
+
import { throwOnTombstoneLoadKey } from "./garbageCollectionConstants";
|
|
13
|
+
import { sendGCTombstoneEvent } from "./garbageCollectionTombstoneUtils";
|
|
13
14
|
/**
|
|
14
15
|
* This class represents blob (long string)
|
|
15
16
|
* This object is used only when creating (writing) new blob and serialization purposes.
|
|
@@ -61,26 +62,28 @@ var PendingBlobStatus;
|
|
|
61
62
|
PendingBlobStatus[PendingBlobStatus["OfflinePendingUpload"] = 2] = "OfflinePendingUpload";
|
|
62
63
|
PendingBlobStatus[PendingBlobStatus["OfflinePendingOp"] = 3] = "OfflinePendingOp";
|
|
63
64
|
})(PendingBlobStatus || (PendingBlobStatus = {}));
|
|
64
|
-
export class BlobManager {
|
|
65
|
+
export class BlobManager extends TypedEventEmitter {
|
|
65
66
|
constructor(routeContext, snapshot, getStorage,
|
|
66
67
|
/**
|
|
67
|
-
* Submit a BlobAttach op. When a blob is uploaded, there is a short grace period before which
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
68
|
+
* Submit a BlobAttach op. When a blob is uploaded, there is a short grace period before which the blob is
|
|
69
|
+
* deleted. The BlobAttach op notifies the server that blob is in use. The server will then not delete the
|
|
70
|
+
* the blob as long as it is listed as referenced in future summaries. The summarizing client will know to
|
|
71
|
+
* include the storage ID in the summary when it sees the op.
|
|
71
72
|
*
|
|
72
|
-
* The op
|
|
73
|
-
*
|
|
74
|
-
*
|
|
73
|
+
* The op will also include a local ID to inform all clients of the relation to the storage ID, without
|
|
74
|
+
* knowledge of which they cannot request the blob from storage. It's important that this op is sequenced
|
|
75
|
+
* before any ops that reference the local ID, otherwise, an invalid handle could be added to the document.
|
|
75
76
|
*/
|
|
76
77
|
sendBlobAttachOp,
|
|
77
78
|
// To be called when a blob node is requested. blobPath is the path of the blob's node in GC's graph. It's
|
|
78
79
|
// of the format `/<BlobManager.basePath>/<blobId>`.
|
|
79
|
-
|
|
80
|
+
blobRequested, addedBlobReference, runtime, stashedBlobs = {}) {
|
|
81
|
+
super();
|
|
80
82
|
this.routeContext = routeContext;
|
|
81
83
|
this.getStorage = getStorage;
|
|
82
84
|
this.sendBlobAttachOp = sendBlobAttachOp;
|
|
83
|
-
this.
|
|
85
|
+
this.blobRequested = blobRequested;
|
|
86
|
+
this.addedBlobReference = addedBlobReference;
|
|
84
87
|
this.runtime = runtime;
|
|
85
88
|
/**
|
|
86
89
|
* Blobs which have not been uploaded or for which we have not yet seen a BlobAttach op round-trip.
|
|
@@ -89,8 +92,9 @@ export class BlobManager {
|
|
|
89
92
|
*/
|
|
90
93
|
this.pendingBlobs = new Map();
|
|
91
94
|
/**
|
|
92
|
-
* Track ops in flight for online flow.
|
|
93
|
-
*
|
|
95
|
+
* Track ops in flight for online flow. This is used for optimizations where if we receive an ack for a storage ID,
|
|
96
|
+
* we can resolve all pending blobs with the same storage ID even though they may have different local IDs. That's
|
|
97
|
+
* because we know that the server will not delete the blob corresponding to that storage ID.
|
|
94
98
|
*/
|
|
95
99
|
this.opsInFlight = new Map();
|
|
96
100
|
this.retryThrottler = new CancellableThrottler(new Throttler(60 * 1000, // 60 sec delay window
|
|
@@ -98,14 +102,14 @@ export class BlobManager {
|
|
|
98
102
|
// throttling function increases exponentially (0ms, 40ms, 80ms, 160ms, etc)
|
|
99
103
|
formExponentialFn({ coefficient: 20, initialDelay: 0 })));
|
|
100
104
|
/**
|
|
101
|
-
* This stores
|
|
105
|
+
* This stores IDs of tombstoned blobs.
|
|
102
106
|
* Tombstone is a temporary feature that imitates a blob getting swept by garbage collection.
|
|
103
107
|
*/
|
|
104
108
|
this.tombstonedBlobs = new Set();
|
|
105
109
|
this.mc = loggerToMonitoringContext(ChildLogger.create(this.runtime.logger, "BlobManager"));
|
|
106
110
|
// Read the feature flag that tells whether to throw when a tombstone blob is requested.
|
|
107
|
-
this.
|
|
108
|
-
this.mc.config.getBoolean(
|
|
111
|
+
this.throwOnTombstoneLoad =
|
|
112
|
+
this.mc.config.getBoolean(throwOnTombstoneLoadKey) === true &&
|
|
109
113
|
this.runtime.clientDetails.type !== summarizerClientType;
|
|
110
114
|
this.runtime.on("disconnected", () => this.onDisconnected());
|
|
111
115
|
this.redirectTable = this.load(snapshot);
|
|
@@ -127,6 +131,10 @@ export class BlobManager {
|
|
|
127
131
|
get hasPendingOfflineUploads() {
|
|
128
132
|
return this.pendingOfflineUploads.length > 0;
|
|
129
133
|
}
|
|
134
|
+
get hasPendingBlobs() {
|
|
135
|
+
return (this.runtime.attachState !== AttachState.Attached && this.redirectTable.size > 0)
|
|
136
|
+
|| this.pendingBlobs.size > 0;
|
|
137
|
+
}
|
|
130
138
|
/**
|
|
131
139
|
* Upload blobs added while offline. This must be completed before connecting and resubmitting ops.
|
|
132
140
|
*/
|
|
@@ -175,12 +183,13 @@ export class BlobManager {
|
|
|
175
183
|
async getBlob(blobId) {
|
|
176
184
|
const request = { url: blobId };
|
|
177
185
|
if (this.tombstonedBlobs.has(blobId)) {
|
|
178
|
-
const error = responseToException(createResponseError(404, "Blob
|
|
179
|
-
this.mc
|
|
186
|
+
const error = responseToException(createResponseError(404, "Blob was deleted", request), request);
|
|
187
|
+
sendGCTombstoneEvent(this.mc, {
|
|
180
188
|
eventName: "GC_Tombstone_Blob_Requested",
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
189
|
+
category: this.throwOnTombstoneLoad ? "error" : "generic",
|
|
190
|
+
isSummarizerClient: this.runtime.clientDetails.type === summarizerClientType,
|
|
191
|
+
}, [BlobManager.basePath], error);
|
|
192
|
+
if (this.throwOnTombstoneLoad) {
|
|
184
193
|
throw error;
|
|
185
194
|
}
|
|
186
195
|
}
|
|
@@ -196,11 +205,12 @@ export class BlobManager {
|
|
|
196
205
|
storageId = blobId;
|
|
197
206
|
}
|
|
198
207
|
else {
|
|
199
|
-
|
|
200
|
-
assert(!!
|
|
208
|
+
const attachedStorageId = this.redirectTable.get(blobId);
|
|
209
|
+
assert(!!attachedStorageId, 0x11f /* "requesting unknown blobs" */);
|
|
210
|
+
storageId = attachedStorageId;
|
|
201
211
|
}
|
|
202
|
-
//
|
|
203
|
-
this.
|
|
212
|
+
// Let runtime know that the corresponding GC node was requested.
|
|
213
|
+
this.blobRequested(this.getBlobGCNodePath(blobId));
|
|
204
214
|
return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: "AttachmentReadBlob", id: storageId }, async () => {
|
|
205
215
|
return this.getStorage().readBlob(storageId);
|
|
206
216
|
}, { end: true, cancel: "error" });
|
|
@@ -213,7 +223,7 @@ export class BlobManager {
|
|
|
213
223
|
// Blobs created while the container is detached are stored in IDetachedBlobStorage.
|
|
214
224
|
// The 'IDocumentStorageService.createBlob()' call below will respond with a localId.
|
|
215
225
|
const response = await this.getStorage().createBlob(blob);
|
|
216
|
-
this.
|
|
226
|
+
this.setRedirection(response.id, undefined);
|
|
217
227
|
return this.getBlobHandle(response.id);
|
|
218
228
|
}
|
|
219
229
|
async createBlob(blob) {
|
|
@@ -226,8 +236,8 @@ export class BlobManager {
|
|
|
226
236
|
await new Promise((resolve) => this.runtime.once("attached", resolve));
|
|
227
237
|
}
|
|
228
238
|
assert(this.runtime.attachState === AttachState.Attached, 0x385 /* For clarity and paranoid defense against adding future attachment states */);
|
|
229
|
-
// Create a local ID for
|
|
230
|
-
//
|
|
239
|
+
// Create a local ID for the blob. After uploading it to storage and before returning it, a local ID to
|
|
240
|
+
// storage ID mapping is created.
|
|
231
241
|
const localId = uuid();
|
|
232
242
|
const pendingEntry = {
|
|
233
243
|
blob,
|
|
@@ -241,6 +251,26 @@ export class BlobManager {
|
|
|
241
251
|
async uploadBlob(localId, blob) {
|
|
242
252
|
return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: "createBlob" }, async () => this.getStorage().createBlob(blob), { end: true, cancel: this.runtime.connected ? "error" : "generic" }).then((response) => this.onUploadResolve(localId, response), async (err) => this.onUploadReject(localId, err));
|
|
243
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* Set up a mapping in the redirect table from fromId to toId. Also, notify the runtime that a reference is added
|
|
256
|
+
* which is required for GC.
|
|
257
|
+
*/
|
|
258
|
+
setRedirection(fromId, toId) {
|
|
259
|
+
this.redirectTable.set(fromId, toId);
|
|
260
|
+
// Notify runtime of a reference added if toId is not undefined. It can be undefined when a blob is uploaded in
|
|
261
|
+
// detached mode. In this case, the entry will be updated when the blob is updated.
|
|
262
|
+
if (toId !== undefined) {
|
|
263
|
+
this.addedBlobReference(this.getBlobGCNodePath(fromId), this.getBlobGCNodePath(toId));
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
deleteAndEmitsIfEmpty(id) {
|
|
267
|
+
if (this.pendingBlobs.has(id)) {
|
|
268
|
+
this.pendingBlobs.delete(id);
|
|
269
|
+
if (!this.hasPendingBlobs) {
|
|
270
|
+
this.emit("noPendingBlobs");
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
244
274
|
onUploadResolve(localId, response) {
|
|
245
275
|
var _a;
|
|
246
276
|
const entry = this.pendingBlobs.get(localId);
|
|
@@ -249,17 +279,24 @@ export class BlobManager {
|
|
|
249
279
|
entry.storageId = response.id;
|
|
250
280
|
if (this.runtime.connected) {
|
|
251
281
|
if (entry.status === PendingBlobStatus.OnlinePendingUpload) {
|
|
282
|
+
// Send a blob attach op. This serves two purposes:
|
|
283
|
+
// 1. If its a new blob, i.e., it isn't de-duped, the server will keep the blob alive if it sees this op
|
|
284
|
+
// until its storage ID is added to the next summary.
|
|
285
|
+
// 2. It will create a local ID to storage ID mapping in all clients which is needed to retrieve the
|
|
286
|
+
// blob from the server via the storage ID.
|
|
287
|
+
this.sendBlobAttachOp(localId, response.id);
|
|
252
288
|
if (this.storageIds.has(response.id)) {
|
|
253
|
-
//
|
|
254
|
-
//
|
|
255
|
-
|
|
256
|
-
this.
|
|
289
|
+
// The blob is de-duped. Set up a local ID to storage ID mapping and return the blob. Since this is
|
|
290
|
+
// an existing blob, we don't have to wait for the op to be ack'd since this step has already
|
|
291
|
+
// happened before and so, the server won't delete it.
|
|
292
|
+
this.setRedirection(localId, response.id);
|
|
293
|
+
entry.handleP.resolve(this.getBlobHandle(localId));
|
|
294
|
+
this.deleteAndEmitsIfEmpty(localId);
|
|
257
295
|
}
|
|
258
296
|
else {
|
|
259
|
-
//
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
297
|
+
// If there is already an op for this storage ID, append the local ID to the list. Once any op for
|
|
298
|
+
// this storage ID is ack'd, all pending blobs for it can be resolved since the op will keep the
|
|
299
|
+
// blob alive in storage.
|
|
263
300
|
this.opsInFlight.set(response.id, ((_a = this.opsInFlight.get(response.id)) !== null && _a !== void 0 ? _a : []).concat(localId));
|
|
264
301
|
entry.status = PendingBlobStatus.OnlinePendingOp;
|
|
265
302
|
}
|
|
@@ -300,15 +337,19 @@ export class BlobManager {
|
|
|
300
337
|
const entry = this.pendingBlobs.get(localId);
|
|
301
338
|
assert(!!entry, 0x389 /* No pending blob entry */);
|
|
302
339
|
assert([PendingBlobStatus.OnlinePendingUpload, PendingBlobStatus.OnlinePendingOp].includes(entry.status), 0x38a /* Blob must be in online flow to transition to offline flow */);
|
|
340
|
+
/**
|
|
341
|
+
* If we haven't already submitted a BlobAttach op for this entry, send it before returning the blob handle.
|
|
342
|
+
* This will make sure that the BlobAttach op is sequenced prior to any ops referencing the handle. Otherwise,
|
|
343
|
+
* an invalid handle could be added to the document.
|
|
344
|
+
* storageId may be undefined but since we are not connected we will have a chance to add it when reSubmit()
|
|
345
|
+
* is called on reconnection.
|
|
346
|
+
*/
|
|
347
|
+
if (entry.status !== PendingBlobStatus.OnlinePendingOp) {
|
|
348
|
+
this.sendBlobAttachOp(localId, entry.storageId);
|
|
349
|
+
}
|
|
303
350
|
entry.status = entry.status === PendingBlobStatus.OnlinePendingUpload
|
|
304
351
|
? PendingBlobStatus.OfflinePendingUpload
|
|
305
352
|
: PendingBlobStatus.OfflinePendingOp;
|
|
306
|
-
// Submit a BlobAttach op. It's important we submit this op now before returning the blob handle so the
|
|
307
|
-
// BlobAttach op is sequenced prior to any ops referencing the handle. Otherwise an invalid handle could be
|
|
308
|
-
// added to the document if the ops are not all successfully submitted upon reconnection.
|
|
309
|
-
// storageId may be undefined but since we are not connected we will have a chance to add it when reSubmit()
|
|
310
|
-
// is called
|
|
311
|
-
this.sendBlobAttachOp(entry.storageId, localId);
|
|
312
353
|
entry.handleP.resolve(this.getBlobHandle(localId));
|
|
313
354
|
}
|
|
314
355
|
/**
|
|
@@ -318,45 +359,52 @@ export class BlobManager {
|
|
|
318
359
|
*/
|
|
319
360
|
reSubmit(metadata) {
|
|
320
361
|
assert(!!metadata, 0x38b /* Resubmitted ops must have metadata */);
|
|
321
|
-
const {
|
|
362
|
+
const { localId, blobId } = metadata;
|
|
363
|
+
assert(localId !== undefined, 0x50d /* local ID not available on reSubmit */);
|
|
322
364
|
if (!blobId) {
|
|
323
|
-
assert(!!localId, 0x38c /* Submitted BlobAttach ops must have a blobId or localId */);
|
|
324
365
|
// We submitted this op while offline. The blob should have been uploaded by now.
|
|
325
366
|
const pendingEntry = this.pendingBlobs.get(localId);
|
|
326
367
|
assert((pendingEntry === null || pendingEntry === void 0 ? void 0 : pendingEntry.status) === PendingBlobStatus.OfflinePendingOp &&
|
|
327
368
|
!!(pendingEntry === null || pendingEntry === void 0 ? void 0 : pendingEntry.storageId), 0x38d /* blob must be uploaded before resubmitting BlobAttach op */);
|
|
328
|
-
return this.sendBlobAttachOp(pendingEntry.storageId
|
|
369
|
+
return this.sendBlobAttachOp(localId, pendingEntry.storageId);
|
|
329
370
|
}
|
|
330
|
-
return this.sendBlobAttachOp(
|
|
371
|
+
return this.sendBlobAttachOp(localId, blobId);
|
|
331
372
|
}
|
|
332
373
|
processBlobAttachOp(message, local) {
|
|
333
374
|
var _a, _b;
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
375
|
+
const localId = (_a = message.metadata) === null || _a === void 0 ? void 0 : _a.localId;
|
|
376
|
+
const blobId = (_b = message.metadata) === null || _b === void 0 ? void 0 : _b.blobId;
|
|
377
|
+
assert(blobId !== undefined, 0x12a /* "Missing blob id on metadata" */);
|
|
378
|
+
// Set up a mapping from local ID to storage ID. This is crucial since without this the blob cannot be
|
|
379
|
+
// requested from the server.
|
|
380
|
+
// Note: The check for undefined is needed for back-compat when localId was not part of the BlobAttach op that
|
|
381
|
+
// was sent when online.
|
|
382
|
+
if (localId !== undefined) {
|
|
383
|
+
this.setRedirection(localId, blobId);
|
|
337
384
|
}
|
|
338
385
|
// set identity (id -> id) entry
|
|
339
|
-
this.
|
|
386
|
+
this.setRedirection(blobId, blobId);
|
|
340
387
|
if (local) {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
388
|
+
assert(localId !== undefined, 0x50e /* local ID not present in blob attach message */);
|
|
389
|
+
const waitingBlobs = this.opsInFlight.get(blobId);
|
|
390
|
+
if (waitingBlobs !== undefined) {
|
|
391
|
+
// For each op corresponding to this storage ID that we are waiting for, resolve the pending blob.
|
|
392
|
+
// This is safe because the server will keep the blob alive and the op containing the local ID to
|
|
393
|
+
// storage ID is already in flight and any op containing this local ID will be sequenced after that.
|
|
394
|
+
waitingBlobs.forEach((pendingLocalId) => {
|
|
395
|
+
const pendingBlobEntry = this.pendingBlobs.get(pendingLocalId);
|
|
347
396
|
assert(pendingBlobEntry !== undefined, 0x38f);
|
|
348
397
|
// It's possible we transitioned to offline flow while waiting for this op.
|
|
349
398
|
if (pendingBlobEntry.status === PendingBlobStatus.OnlinePendingOp) {
|
|
350
|
-
|
|
351
|
-
|
|
399
|
+
this.setRedirection(pendingLocalId, blobId);
|
|
400
|
+
pendingBlobEntry.handleP.resolve(this.getBlobHandle(pendingLocalId));
|
|
401
|
+
this.deleteAndEmitsIfEmpty(pendingLocalId);
|
|
352
402
|
}
|
|
353
403
|
});
|
|
404
|
+
this.opsInFlight.delete(blobId);
|
|
354
405
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
assert(((_b = this.pendingBlobs.get(message.metadata.localId)) === null || _b === void 0 ? void 0 : _b.status) === PendingBlobStatus.OfflinePendingOp, 0x1f8 /* "local BlobAttach op with no pending blob" */);
|
|
358
|
-
this.pendingBlobs.delete(message.metadata.localId);
|
|
359
|
-
}
|
|
406
|
+
// For blobs that were transitioned to offline flow while waiting for this op, the entry should be deleted.
|
|
407
|
+
this.deleteAndEmitsIfEmpty(localId);
|
|
360
408
|
}
|
|
361
409
|
}
|
|
362
410
|
/**
|
|
@@ -405,65 +453,50 @@ export class BlobManager {
|
|
|
405
453
|
*/
|
|
406
454
|
getGCData(fullGC = false) {
|
|
407
455
|
const gcData = { gcNodes: {} };
|
|
408
|
-
/**
|
|
409
|
-
* The node path is of the format `/_blobs/blobId`. This path must match the path of the blob handle returned
|
|
410
|
-
* by the createBlob API because blobs are marked referenced by storing these handles in a referenced DDS.
|
|
411
|
-
*/
|
|
412
|
-
this.storageIds.forEach((blobId) => {
|
|
413
|
-
gcData.gcNodes[this.getBlobGCNodePath(blobId)] = [];
|
|
414
|
-
});
|
|
415
|
-
// For some blobs, the handle returned on creation is based off of the localId. So, these
|
|
416
|
-
// nodes can be referenced by storing the localId handle. When that happens, the corresponding storageId node
|
|
417
|
-
// must also be marked referenced. So, we add a route from the localId node to the storageId node.
|
|
418
|
-
// Note that because of de-duping, there can be multiple localIds that all redirect to the same storageId or
|
|
419
|
-
// a blob may be referenced via its storageId handle.
|
|
420
456
|
for (const [localId, storageId] of this.redirectTable) {
|
|
421
457
|
assert(!!storageId, 0x390 /* Must be attached to get GC data */);
|
|
422
|
-
// Add node for the localId and add a route to the storageId node. The storageId node will have been
|
|
423
|
-
// added above when adding nodes for this.blobIds.
|
|
424
458
|
gcData.gcNodes[this.getBlobGCNodePath(localId)] = [this.getBlobGCNodePath(storageId)];
|
|
425
459
|
}
|
|
426
460
|
return gcData;
|
|
427
461
|
}
|
|
428
462
|
/**
|
|
429
|
-
* This is called to update blobs whose routes are
|
|
430
|
-
* @param
|
|
463
|
+
* This is called to update blobs whose routes are unused. The unused blobs are deleted.
|
|
464
|
+
* @param unusedRoutes - The routes of the blob nodes that are unused.
|
|
431
465
|
*/
|
|
432
|
-
|
|
466
|
+
updateUnusedRoutes(unusedRoutes) {
|
|
433
467
|
// The routes or blob node paths are in the same format as returned in getGCData -
|
|
434
468
|
// `/<BlobManager.basePath>/<blobId>`.
|
|
435
|
-
for (const route of
|
|
469
|
+
for (const route of unusedRoutes) {
|
|
436
470
|
const pathParts = route.split("/");
|
|
437
|
-
assert(pathParts.length === 3 && pathParts[1] === BlobManager.basePath,
|
|
471
|
+
assert(pathParts.length === 3 && pathParts[1] === BlobManager.basePath, 0x2d5 /* "Invalid blob node id in unused routes." */);
|
|
438
472
|
const blobId = pathParts[2];
|
|
439
|
-
|
|
440
|
-
this.tombstonedBlobs.delete(blobId);
|
|
473
|
+
this.redirectTable.delete(blobId);
|
|
441
474
|
}
|
|
442
475
|
}
|
|
443
476
|
/**
|
|
444
|
-
* This is called to update blobs whose routes are
|
|
445
|
-
*
|
|
446
|
-
* @param
|
|
447
|
-
* @param tombstone - if true, the objects corresponding to unused routes are marked tombstones. Otherwise, they
|
|
448
|
-
* are deleted.
|
|
477
|
+
* This is called to update blobs whose routes are tombstones. Tombstoned blobs enable testing scenarios with
|
|
478
|
+
* accessing deleted content without actually deleting content from summaries.
|
|
479
|
+
* @param tombstonedRoutes - The routes of blob nodes that are tombstones.
|
|
449
480
|
*/
|
|
450
|
-
|
|
481
|
+
updateTombstonedRoutes(tombstonedRoutes) {
|
|
482
|
+
const tombstonedBlobsSet = new Set();
|
|
451
483
|
// The routes or blob node paths are in the same format as returned in getGCData -
|
|
452
484
|
// `/<BlobManager.basePath>/<blobId>`.
|
|
453
|
-
for (const route of
|
|
485
|
+
for (const route of tombstonedRoutes) {
|
|
454
486
|
const pathParts = route.split("/");
|
|
455
|
-
assert(pathParts.length === 3 && pathParts[1] === BlobManager.basePath,
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
// The unused blobId could be a localId. If so, remove it from the redirect table and continue. The
|
|
463
|
-
// corresponding storageId may still be used either directly or via other localIds.
|
|
464
|
-
this.redirectTable.delete(blobId);
|
|
487
|
+
assert(pathParts.length === 3 && pathParts[1] === BlobManager.basePath, 0x50f /* Invalid blob node id in tombstoned routes. */);
|
|
488
|
+
tombstonedBlobsSet.add(pathParts[2]);
|
|
489
|
+
}
|
|
490
|
+
// Remove blobs from the tombstone list that were tombstoned but aren't anymore as per the tombstoneRoutes.
|
|
491
|
+
for (const blobId of this.tombstonedBlobs) {
|
|
492
|
+
if (!tombstonedBlobsSet.has(blobId)) {
|
|
493
|
+
this.tombstonedBlobs.delete(blobId);
|
|
465
494
|
}
|
|
466
495
|
}
|
|
496
|
+
// Mark blobs that are now tombstoned by adding them to the tombstone list.
|
|
497
|
+
for (const blobId of tombstonedBlobsSet) {
|
|
498
|
+
this.tombstonedBlobs.add(blobId);
|
|
499
|
+
}
|
|
467
500
|
}
|
|
468
501
|
summarize(telemetryContext) {
|
|
469
502
|
// if storageIds is empty, it means we are detached and have only local IDs, or that there are no blobs attached
|
|
@@ -486,9 +519,9 @@ export class BlobManager {
|
|
|
486
519
|
assert(this.redirectTable.size === table.size, 0x391 /* Redirect table size must match BlobManager's local ID count */);
|
|
487
520
|
for (const [localId, storageId] of table) {
|
|
488
521
|
assert(this.redirectTable.has(localId), 0x254 /* "unrecognized id in redirect table" */);
|
|
489
|
-
this.
|
|
522
|
+
this.setRedirection(localId, storageId);
|
|
490
523
|
// set identity (id -> id) entry
|
|
491
|
-
this.
|
|
524
|
+
this.setRedirection(storageId, storageId);
|
|
492
525
|
}
|
|
493
526
|
}
|
|
494
527
|
getPendingBlobs() {
|