@fluidframework/container-runtime 2.0.0-dev.2.2.0.111723 → 2.0.0-dev.3.1.0.125672
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 +21 -10
- package/.mocharc.js +2 -2
- package/api-extractor.json +2 -2
- package/dist/batchTracker.d.ts +1 -2
- package/dist/batchTracker.d.ts.map +1 -1
- package/dist/batchTracker.js +2 -1
- package/dist/batchTracker.js.map +1 -1
- package/dist/blobManager.d.ts +62 -28
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js +256 -102
- package/dist/blobManager.js.map +1 -1
- package/dist/connectionTelemetry.d.ts.map +1 -1
- package/dist/connectionTelemetry.js +11 -9
- package/dist/connectionTelemetry.js.map +1 -1
- package/dist/containerHandleContext.d.ts.map +1 -1
- package/dist/containerHandleContext.js +3 -1
- package/dist/containerHandleContext.js.map +1 -1
- package/dist/containerRuntime.d.ts +110 -78
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +336 -331
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStore.d.ts.map +1 -1
- package/dist/dataStore.js +11 -9
- package/dist/dataStore.js.map +1 -1
- package/dist/dataStoreContext.d.ts +2 -1
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +40 -23
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStoreContexts.d.ts.map +1 -1
- package/dist/dataStoreContexts.js +7 -3
- package/dist/dataStoreContexts.js.map +1 -1
- package/dist/dataStoreRegistry.d.ts.map +1 -1
- package/dist/dataStoreRegistry.js +3 -1
- package/dist/dataStoreRegistry.js.map +1 -1
- package/dist/dataStores.d.ts +12 -9
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/dataStores.js +69 -46
- package/dist/dataStores.js.map +1 -1
- package/dist/deltaScheduler.d.ts.map +1 -1
- package/dist/deltaScheduler.js +8 -3
- package/dist/deltaScheduler.js.map +1 -1
- package/dist/garbageCollection.d.ts +57 -42
- package/dist/garbageCollection.d.ts.map +1 -1
- package/dist/garbageCollection.js +371 -239
- package/dist/garbageCollection.js.map +1 -1
- package/dist/garbageCollectionConstants.d.ts +23 -0
- package/dist/garbageCollectionConstants.d.ts.map +1 -0
- package/dist/garbageCollectionConstants.js +36 -0
- package/dist/garbageCollectionConstants.js.map +1 -0
- package/dist/garbageCollectionHelpers.d.ts +15 -0
- package/dist/garbageCollectionHelpers.d.ts.map +1 -0
- package/dist/garbageCollectionHelpers.js +27 -0
- package/dist/garbageCollectionHelpers.js.map +1 -0
- package/dist/gcSweepReadyUsageDetection.d.ts +5 -5
- package/dist/gcSweepReadyUsageDetection.d.ts.map +1 -1
- package/dist/gcSweepReadyUsageDetection.js +15 -11
- package/dist/gcSweepReadyUsageDetection.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -6
- package/dist/index.js.map +1 -1
- package/dist/opLifecycle/batchManager.d.ts +42 -0
- package/dist/opLifecycle/batchManager.d.ts.map +1 -0
- package/dist/opLifecycle/batchManager.js +124 -0
- package/dist/opLifecycle/batchManager.js.map +1 -0
- package/dist/opLifecycle/definitions.d.ts +64 -0
- package/dist/opLifecycle/definitions.d.ts.map +1 -0
- package/dist/opLifecycle/definitions.js +7 -0
- package/dist/opLifecycle/definitions.js.map +1 -0
- package/dist/opLifecycle/index.d.ts +12 -0
- package/dist/opLifecycle/index.d.ts.map +1 -0
- package/dist/opLifecycle/index.js +22 -0
- package/dist/opLifecycle/index.js.map +1 -0
- package/dist/{opCompressor.d.ts → opLifecycle/opCompressor.d.ts} +3 -3
- package/dist/opLifecycle/opCompressor.d.ts.map +1 -0
- package/dist/opLifecycle/opCompressor.js +67 -0
- package/dist/opLifecycle/opCompressor.js.map +1 -0
- package/dist/{opDecompressor.d.ts → opLifecycle/opDecompressor.d.ts} +2 -1
- package/dist/opLifecycle/opDecompressor.d.ts.map +1 -0
- package/dist/{opDecompressor.js → opLifecycle/opDecompressor.js} +37 -21
- package/dist/opLifecycle/opDecompressor.js.map +1 -0
- package/dist/opLifecycle/opSplitter.d.ts +49 -0
- package/dist/opLifecycle/opSplitter.d.ts.map +1 -0
- package/dist/opLifecycle/opSplitter.js +173 -0
- package/dist/opLifecycle/opSplitter.js.map +1 -0
- package/dist/opLifecycle/outbox.d.ts +52 -0
- package/dist/opLifecycle/outbox.d.ts.map +1 -0
- package/dist/opLifecycle/outbox.js +164 -0
- package/dist/opLifecycle/outbox.js.map +1 -0
- package/dist/opLifecycle/remoteMessageProcessor.d.ts +26 -0
- package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -0
- package/dist/opLifecycle/remoteMessageProcessor.js +96 -0
- package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -0
- package/dist/opProperties.d.ts.map +1 -1
- package/dist/opProperties.js +1 -3
- package/dist/opProperties.js.map +1 -1
- package/dist/orderedClientElection.d.ts.map +1 -1
- package/dist/orderedClientElection.js +10 -4
- package/dist/orderedClientElection.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/pendingStateManager.d.ts +4 -13
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +134 -161
- package/dist/pendingStateManager.js.map +1 -1
- package/dist/runWhileConnectedCoordinator.d.ts.map +1 -1
- package/dist/runWhileConnectedCoordinator.js.map +1 -1
- package/dist/runningSummarizer.d.ts.map +1 -1
- package/dist/runningSummarizer.js +34 -22
- 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 +11 -21
- package/dist/scheduleManager.js.map +1 -1
- package/dist/serializedSnapshotStorage.d.ts.map +1 -1
- package/dist/serializedSnapshotStorage.js +3 -1
- package/dist/serializedSnapshotStorage.js.map +1 -1
- package/dist/summarizer.d.ts +2 -3
- package/dist/summarizer.d.ts.map +1 -1
- package/dist/summarizer.js +39 -18
- package/dist/summarizer.js.map +1 -1
- package/dist/summarizerClientElection.d.ts +1 -2
- package/dist/summarizerClientElection.d.ts.map +1 -1
- package/dist/summarizerClientElection.js +3 -30
- package/dist/summarizerClientElection.js.map +1 -1
- package/dist/summarizerHandle.d.ts.map +1 -1
- package/dist/summarizerHandle.js.map +1 -1
- package/dist/summarizerHeuristics.d.ts.map +1 -1
- package/dist/summarizerHeuristics.js +6 -9
- package/dist/summarizerHeuristics.js.map +1 -1
- package/dist/summarizerTypes.d.ts +22 -25
- package/dist/summarizerTypes.d.ts.map +1 -1
- package/dist/summarizerTypes.js.map +1 -1
- package/dist/summaryCollection.d.ts.map +1 -1
- package/dist/summaryCollection.js +18 -8
- package/dist/summaryCollection.js.map +1 -1
- package/dist/summaryFormat.d.ts.map +1 -1
- package/dist/summaryFormat.js +18 -11
- package/dist/summaryFormat.js.map +1 -1
- package/dist/summaryGenerator.d.ts.map +1 -1
- package/dist/summaryGenerator.js +32 -14
- package/dist/summaryGenerator.js.map +1 -1
- package/dist/summaryManager.d.ts.map +1 -1
- package/dist/summaryManager.js +21 -9
- package/dist/summaryManager.js.map +1 -1
- package/dist/throttler.d.ts +2 -2
- package/dist/throttler.d.ts.map +1 -1
- package/dist/throttler.js +4 -4
- package/dist/throttler.js.map +1 -1
- package/garbageCollection.md +15 -2
- package/lib/batchTracker.d.ts +1 -2
- package/lib/batchTracker.d.ts.map +1 -1
- package/lib/batchTracker.js +2 -1
- package/lib/batchTracker.js.map +1 -1
- package/lib/blobManager.d.ts +62 -28
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js +259 -105
- package/lib/blobManager.js.map +1 -1
- package/lib/connectionTelemetry.d.ts.map +1 -1
- package/lib/connectionTelemetry.js +11 -9
- package/lib/connectionTelemetry.js.map +1 -1
- package/lib/containerHandleContext.d.ts.map +1 -1
- package/lib/containerHandleContext.js +3 -1
- package/lib/containerHandleContext.js.map +1 -1
- package/lib/containerRuntime.d.ts +110 -78
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +340 -334
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStore.d.ts.map +1 -1
- package/lib/dataStore.js +11 -9
- package/lib/dataStore.js.map +1 -1
- package/lib/dataStoreContext.d.ts +2 -1
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +41 -24
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStoreContexts.d.ts.map +1 -1
- package/lib/dataStoreContexts.js +7 -3
- package/lib/dataStoreContexts.js.map +1 -1
- package/lib/dataStoreRegistry.d.ts.map +1 -1
- package/lib/dataStoreRegistry.js +3 -1
- package/lib/dataStoreRegistry.js.map +1 -1
- package/lib/dataStores.d.ts +12 -9
- package/lib/dataStores.d.ts.map +1 -1
- package/lib/dataStores.js +75 -52
- package/lib/dataStores.js.map +1 -1
- package/lib/deltaScheduler.d.ts.map +1 -1
- package/lib/deltaScheduler.js +9 -4
- package/lib/deltaScheduler.js.map +1 -1
- package/lib/garbageCollection.d.ts +57 -42
- package/lib/garbageCollection.d.ts.map +1 -1
- package/lib/garbageCollection.js +364 -232
- package/lib/garbageCollection.js.map +1 -1
- package/lib/garbageCollectionConstants.d.ts +23 -0
- package/lib/garbageCollectionConstants.d.ts.map +1 -0
- package/lib/garbageCollectionConstants.js +33 -0
- package/lib/garbageCollectionConstants.js.map +1 -0
- package/lib/garbageCollectionHelpers.d.ts +15 -0
- package/lib/garbageCollectionHelpers.d.ts.map +1 -0
- package/lib/garbageCollectionHelpers.js +23 -0
- package/lib/garbageCollectionHelpers.js.map +1 -0
- package/lib/gcSweepReadyUsageDetection.d.ts +5 -5
- package/lib/gcSweepReadyUsageDetection.d.ts.map +1 -1
- package/lib/gcSweepReadyUsageDetection.js +15 -11
- package/lib/gcSweepReadyUsageDetection.js.map +1 -1
- package/lib/index.d.ts +4 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/opLifecycle/batchManager.d.ts +42 -0
- package/lib/opLifecycle/batchManager.d.ts.map +1 -0
- package/lib/opLifecycle/batchManager.js +120 -0
- package/lib/opLifecycle/batchManager.js.map +1 -0
- package/lib/opLifecycle/definitions.d.ts +64 -0
- package/lib/opLifecycle/definitions.d.ts.map +1 -0
- package/lib/opLifecycle/definitions.js +6 -0
- package/lib/opLifecycle/definitions.js.map +1 -0
- package/lib/opLifecycle/index.d.ts +12 -0
- package/lib/opLifecycle/index.d.ts.map +1 -0
- package/lib/opLifecycle/index.js +11 -0
- package/lib/opLifecycle/index.js.map +1 -0
- package/lib/{opCompressor.d.ts → opLifecycle/opCompressor.d.ts} +3 -3
- package/lib/opLifecycle/opCompressor.d.ts.map +1 -0
- package/lib/opLifecycle/opCompressor.js +63 -0
- package/lib/opLifecycle/opCompressor.js.map +1 -0
- package/lib/{opDecompressor.d.ts → opLifecycle/opDecompressor.d.ts} +2 -1
- package/lib/opLifecycle/opDecompressor.d.ts.map +1 -0
- package/lib/{opDecompressor.js → opLifecycle/opDecompressor.js} +37 -21
- package/lib/opLifecycle/opDecompressor.js.map +1 -0
- package/lib/opLifecycle/opSplitter.d.ts +49 -0
- package/lib/opLifecycle/opSplitter.d.ts.map +1 -0
- package/lib/opLifecycle/opSplitter.js +168 -0
- package/lib/opLifecycle/opSplitter.js.map +1 -0
- package/lib/opLifecycle/outbox.d.ts +52 -0
- package/lib/opLifecycle/outbox.d.ts.map +1 -0
- package/lib/opLifecycle/outbox.js +160 -0
- package/lib/opLifecycle/outbox.js.map +1 -0
- package/lib/opLifecycle/remoteMessageProcessor.d.ts +26 -0
- package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -0
- package/lib/opLifecycle/remoteMessageProcessor.js +91 -0
- package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -0
- package/lib/opProperties.d.ts.map +1 -1
- package/lib/opProperties.js +1 -3
- package/lib/opProperties.js.map +1 -1
- package/lib/orderedClientElection.d.ts.map +1 -1
- package/lib/orderedClientElection.js +10 -4
- package/lib/orderedClientElection.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/pendingStateManager.d.ts +4 -13
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +134 -161
- package/lib/pendingStateManager.js.map +1 -1
- package/lib/runWhileConnectedCoordinator.d.ts.map +1 -1
- package/lib/runWhileConnectedCoordinator.js.map +1 -1
- package/lib/runningSummarizer.d.ts.map +1 -1
- package/lib/runningSummarizer.js +35 -23
- 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 +11 -21
- package/lib/scheduleManager.js.map +1 -1
- package/lib/serializedSnapshotStorage.d.ts.map +1 -1
- package/lib/serializedSnapshotStorage.js +3 -1
- package/lib/serializedSnapshotStorage.js.map +1 -1
- package/lib/summarizer.d.ts +2 -3
- package/lib/summarizer.d.ts.map +1 -1
- package/lib/summarizer.js +39 -18
- package/lib/summarizer.js.map +1 -1
- package/lib/summarizerClientElection.d.ts +1 -2
- package/lib/summarizerClientElection.d.ts.map +1 -1
- package/lib/summarizerClientElection.js +3 -30
- package/lib/summarizerClientElection.js.map +1 -1
- package/lib/summarizerHandle.d.ts.map +1 -1
- package/lib/summarizerHandle.js.map +1 -1
- package/lib/summarizerHeuristics.d.ts.map +1 -1
- package/lib/summarizerHeuristics.js +6 -9
- package/lib/summarizerHeuristics.js.map +1 -1
- package/lib/summarizerTypes.d.ts +22 -25
- package/lib/summarizerTypes.d.ts.map +1 -1
- package/lib/summarizerTypes.js.map +1 -1
- package/lib/summaryCollection.d.ts.map +1 -1
- package/lib/summaryCollection.js +18 -8
- package/lib/summaryCollection.js.map +1 -1
- package/lib/summaryFormat.d.ts.map +1 -1
- package/lib/summaryFormat.js +20 -13
- package/lib/summaryFormat.js.map +1 -1
- package/lib/summaryGenerator.d.ts.map +1 -1
- package/lib/summaryGenerator.js +32 -14
- package/lib/summaryGenerator.js.map +1 -1
- package/lib/summaryManager.d.ts.map +1 -1
- package/lib/summaryManager.js +21 -9
- package/lib/summaryManager.js.map +1 -1
- package/lib/throttler.d.ts +2 -2
- package/lib/throttler.d.ts.map +1 -1
- package/lib/throttler.js +4 -4
- package/lib/throttler.js.map +1 -1
- package/package.json +28 -38
- package/prettier.config.cjs +1 -1
- package/src/batchTracker.ts +55 -50
- package/src/blobManager.ts +802 -541
- package/src/connectionTelemetry.ts +280 -249
- package/src/containerHandleContext.ts +27 -29
- package/src/containerRuntime.ts +3125 -2982
- package/src/dataStore.ts +172 -159
- package/src/dataStoreContext.ts +1049 -992
- package/src/dataStoreContexts.ts +178 -161
- package/src/dataStoreRegistry.ts +25 -20
- package/src/dataStores.ts +785 -711
- package/src/deltaScheduler.ts +158 -150
- package/src/garbageCollection.ts +1797 -1558
- package/src/garbageCollectionConstants.ts +38 -0
- package/src/garbageCollectionHelpers.ts +37 -0
- package/src/gcSweepReadyUsageDetection.ts +90 -84
- package/src/index.ts +68 -69
- package/src/opLifecycle/batchManager.ts +167 -0
- package/src/opLifecycle/definitions.ts +70 -0
- package/src/opLifecycle/index.ts +18 -0
- package/src/opLifecycle/opCompressor.ts +82 -0
- package/src/opLifecycle/opDecompressor.ts +124 -0
- package/src/opLifecycle/opSplitter.ts +238 -0
- package/src/opLifecycle/outbox.ts +228 -0
- package/src/opLifecycle/remoteMessageProcessor.ts +106 -0
- package/src/opProperties.ts +11 -9
- package/src/orderedClientElection.ts +489 -457
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +379 -381
- package/src/runWhileConnectedCoordinator.ts +78 -71
- package/src/runningSummarizer.ts +619 -582
- package/src/scheduleManager.ts +299 -280
- package/src/serializedSnapshotStorage.ts +116 -111
- package/src/summarizer.ts +417 -381
- package/src/summarizerClientElection.ts +107 -129
- package/src/summarizerHandle.ts +11 -9
- package/src/summarizerHeuristics.ts +183 -186
- package/src/summarizerTypes.ts +344 -333
- package/src/summaryCollection.ts +378 -349
- package/src/summaryFormat.ts +146 -127
- package/src/summaryGenerator.ts +464 -406
- package/src/summaryManager.ts +377 -348
- package/src/throttler.ts +131 -122
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +9 -13
- package/dist/batchManager.d.ts +0 -42
- package/dist/batchManager.d.ts.map +0 -1
- package/dist/batchManager.js +0 -83
- package/dist/batchManager.js.map +0 -1
- package/dist/opCompressor.d.ts.map +0 -1
- package/dist/opCompressor.js +0 -50
- package/dist/opCompressor.js.map +0 -1
- package/dist/opDecompressor.d.ts.map +0 -1
- package/dist/opDecompressor.js.map +0 -1
- package/lib/batchManager.d.ts +0 -42
- package/lib/batchManager.d.ts.map +0 -1
- package/lib/batchManager.js +0 -79
- package/lib/batchManager.js.map +0 -1
- package/lib/opCompressor.d.ts.map +0 -1
- package/lib/opCompressor.js +0 -46
- package/lib/opCompressor.js.map +0 -1
- package/lib/opDecompressor.d.ts.map +0 -1
- package/lib/opDecompressor.js.map +0 -1
- package/src/batchManager.ts +0 -108
- package/src/opCompressor.ts +0 -59
- package/src/opDecompressor.ts +0 -82
package/dist/blobManager.js
CHANGED
|
@@ -10,7 +10,11 @@ const runtime_utils_1 = require("@fluidframework/runtime-utils");
|
|
|
10
10
|
const common_utils_1 = require("@fluidframework/common-utils");
|
|
11
11
|
const container_definitions_1 = require("@fluidframework/container-definitions");
|
|
12
12
|
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
13
|
+
const containerRuntime_1 = require("./containerRuntime");
|
|
13
14
|
const throttler_1 = require("./throttler");
|
|
15
|
+
const summarizerClientElection_1 = require("./summarizerClientElection");
|
|
16
|
+
const garbageCollectionConstants_1 = require("./garbageCollectionConstants");
|
|
17
|
+
const garbageCollectionHelpers_1 = require("./garbageCollectionHelpers");
|
|
14
18
|
/**
|
|
15
19
|
* This class represents blob (long string)
|
|
16
20
|
* This object is used only when creating (writing) new blob and serialization purposes.
|
|
@@ -26,7 +30,9 @@ class BlobHandle {
|
|
|
26
30
|
this.attached = false;
|
|
27
31
|
this.absolutePath = (0, runtime_utils_1.generateHandleContextPath)(path, this.routeContext);
|
|
28
32
|
}
|
|
29
|
-
get IFluidHandle() {
|
|
33
|
+
get IFluidHandle() {
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
30
36
|
get isAttached() {
|
|
31
37
|
return this.attached;
|
|
32
38
|
}
|
|
@@ -63,27 +69,38 @@ var PendingBlobStatus;
|
|
|
63
69
|
PendingBlobStatus[PendingBlobStatus["OfflinePendingUpload"] = 2] = "OfflinePendingUpload";
|
|
64
70
|
PendingBlobStatus[PendingBlobStatus["OfflinePendingOp"] = 3] = "OfflinePendingOp";
|
|
65
71
|
})(PendingBlobStatus || (PendingBlobStatus = {}));
|
|
66
|
-
class BlobManager {
|
|
72
|
+
class BlobManager extends common_utils_1.TypedEventEmitter {
|
|
67
73
|
constructor(routeContext, snapshot, getStorage,
|
|
68
74
|
/**
|
|
69
|
-
* Submit a BlobAttach op. When a blob is uploaded, there is a short grace period before which
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
75
|
+
* Submit a BlobAttach op. When a blob is uploaded, there is a short grace period before which the blob is
|
|
76
|
+
* deleted. The BlobAttach op notifies the server that blob is in use. The server will then not delete the
|
|
77
|
+
* the blob as long as it is listed as referenced in future summaries. The summarizing client will know to
|
|
78
|
+
* include the storage ID in the summary when it sees the op.
|
|
73
79
|
*
|
|
74
|
-
* The op
|
|
75
|
-
*
|
|
76
|
-
*
|
|
80
|
+
* The op will also include a local ID to inform all clients of the relation to the storage ID, without
|
|
81
|
+
* knowledge of which they cannot request the blob from storage. It's important that this op is sequenced
|
|
82
|
+
* before any ops that reference the local ID, otherwise, an invalid handle could be added to the document.
|
|
77
83
|
*/
|
|
78
84
|
sendBlobAttachOp,
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
|
|
85
|
+
// Called when a blob node is requested. blobPath is the path of the blob's node in GC's graph.
|
|
86
|
+
// blobPath's format - `/<BlobManager.basePath>/<blobId>`.
|
|
87
|
+
blobRequested,
|
|
88
|
+
// Called when a reference is added to a blob. For instance, when creating a localId / storageId to storageId
|
|
89
|
+
// mapping in the redirect table.
|
|
90
|
+
// Node path formats - `/<BlobManager.basePath>/<blobId>`.
|
|
91
|
+
addedBlobReference,
|
|
92
|
+
// Called to check if a blob has been deleted by GC.
|
|
93
|
+
// blobPath's format - `/<BlobManager.basePath>/<blobId>`.
|
|
94
|
+
isBlobDeleted, runtime, stashedBlobs = {}, getCurrentReferenceTimestampMs) {
|
|
95
|
+
super();
|
|
82
96
|
this.routeContext = routeContext;
|
|
83
97
|
this.getStorage = getStorage;
|
|
84
98
|
this.sendBlobAttachOp = sendBlobAttachOp;
|
|
85
|
-
this.
|
|
99
|
+
this.blobRequested = blobRequested;
|
|
100
|
+
this.addedBlobReference = addedBlobReference;
|
|
101
|
+
this.isBlobDeleted = isBlobDeleted;
|
|
86
102
|
this.runtime = runtime;
|
|
103
|
+
this.getCurrentReferenceTimestampMs = getCurrentReferenceTimestampMs;
|
|
87
104
|
/**
|
|
88
105
|
* Blobs which have not been uploaded or for which we have not yet seen a BlobAttach op round-trip.
|
|
89
106
|
* Until we see the op round-trip, there is a possibility we may need to re-upload the blob, so
|
|
@@ -91,15 +108,25 @@ class BlobManager {
|
|
|
91
108
|
*/
|
|
92
109
|
this.pendingBlobs = new Map();
|
|
93
110
|
/**
|
|
94
|
-
* Track ops in flight for online flow.
|
|
95
|
-
*
|
|
111
|
+
* Track ops in flight for online flow. This is used for optimizations where if we receive an ack for a storage ID,
|
|
112
|
+
* we can resolve all pending blobs with the same storage ID even though they may have different local IDs. That's
|
|
113
|
+
* because we know that the server will not delete the blob corresponding to that storage ID.
|
|
96
114
|
*/
|
|
97
115
|
this.opsInFlight = new Map();
|
|
98
116
|
this.retryThrottler = new CancellableThrottler(new throttler_1.Throttler(60 * 1000, // 60 sec delay window
|
|
99
117
|
30 * 1000, // 30 sec max delay
|
|
100
118
|
// throttling function increases exponentially (0ms, 40ms, 80ms, 160ms, etc)
|
|
101
119
|
(0, throttler_1.formExponentialFn)({ coefficient: 20, initialDelay: 0 })));
|
|
102
|
-
|
|
120
|
+
/**
|
|
121
|
+
* This stores IDs of tombstoned blobs.
|
|
122
|
+
* Tombstone is a temporary feature that imitates a blob getting swept by garbage collection.
|
|
123
|
+
*/
|
|
124
|
+
this.tombstonedBlobs = new Set();
|
|
125
|
+
this.mc = (0, telemetry_utils_1.loggerToMonitoringContext)(telemetry_utils_1.ChildLogger.create(this.runtime.logger, "BlobManager"));
|
|
126
|
+
// Read the feature flag that tells whether to throw when a tombstone blob is requested.
|
|
127
|
+
this.throwOnTombstoneLoad =
|
|
128
|
+
this.mc.config.getBoolean(garbageCollectionConstants_1.throwOnTombstoneLoadKey) === true &&
|
|
129
|
+
this.runtime.clientDetails.type !== summarizerClientElection_1.summarizerClientType;
|
|
103
130
|
this.runtime.on("disconnected", () => this.onDisconnected());
|
|
104
131
|
this.redirectTable = this.load(snapshot);
|
|
105
132
|
// Begin uploading stashed blobs from previous container instance
|
|
@@ -114,19 +141,22 @@ class BlobManager {
|
|
|
114
141
|
});
|
|
115
142
|
}
|
|
116
143
|
get pendingOfflineUploads() {
|
|
117
|
-
return Array.from(this.pendingBlobs.values())
|
|
118
|
-
.filter((e) => e.status === PendingBlobStatus.OfflinePendingUpload);
|
|
144
|
+
return Array.from(this.pendingBlobs.values()).filter((e) => e.status === PendingBlobStatus.OfflinePendingUpload);
|
|
119
145
|
}
|
|
120
146
|
get hasPendingOfflineUploads() {
|
|
121
147
|
return this.pendingOfflineUploads.length > 0;
|
|
122
148
|
}
|
|
149
|
+
get hasPendingBlobs() {
|
|
150
|
+
return ((this.runtime.attachState !== container_definitions_1.AttachState.Attached && this.redirectTable.size > 0) ||
|
|
151
|
+
this.pendingBlobs.size > 0);
|
|
152
|
+
}
|
|
123
153
|
/**
|
|
124
154
|
* Upload blobs added while offline. This must be completed before connecting and resubmitting ops.
|
|
125
155
|
*/
|
|
126
156
|
async onConnected() {
|
|
127
157
|
this.retryThrottler.cancel();
|
|
128
158
|
const pendingUploads = this.pendingOfflineUploads.map(async (e) => e.uploadP);
|
|
129
|
-
await telemetry_utils_1.PerformanceEvent.timedExecAsync(this.logger, {
|
|
159
|
+
await telemetry_utils_1.PerformanceEvent.timedExecAsync(this.mc.logger, {
|
|
130
160
|
eventName: "BlobUploadOnConnected",
|
|
131
161
|
count: pendingUploads.length,
|
|
132
162
|
}, async () => Promise.all(pendingUploads), { start: true, end: true });
|
|
@@ -162,10 +192,14 @@ class BlobManager {
|
|
|
162
192
|
const undefinedValueInTable = ids.delete(undefined);
|
|
163
193
|
// For a detached container, entries are inserted into the redirect table with an undefined storage ID.
|
|
164
194
|
// For an attached container, entries are inserted w/storage ID after the BlobAttach op round-trips.
|
|
165
|
-
(0, common_utils_1.assert)(!undefinedValueInTable ||
|
|
195
|
+
(0, common_utils_1.assert)(!undefinedValueInTable ||
|
|
196
|
+
(this.runtime.attachState === container_definitions_1.AttachState.Detached && ids.size === 0), 0x382 /* 'redirectTable' must contain only undefined while detached / defined values while attached */);
|
|
166
197
|
return ids;
|
|
167
198
|
}
|
|
168
199
|
async getBlob(blobId) {
|
|
200
|
+
// Verify that the blob is valid, i.e., it has not been garbage collected. If it is, this will throw an error,
|
|
201
|
+
// failing the call.
|
|
202
|
+
this.verifyBlobValidity(blobId);
|
|
169
203
|
const pending = this.pendingBlobs.get(blobId);
|
|
170
204
|
if (pending) {
|
|
171
205
|
return pending.blob;
|
|
@@ -178,12 +212,13 @@ class BlobManager {
|
|
|
178
212
|
storageId = blobId;
|
|
179
213
|
}
|
|
180
214
|
else {
|
|
181
|
-
|
|
182
|
-
(0, common_utils_1.assert)(!!
|
|
215
|
+
const attachedStorageId = this.redirectTable.get(blobId);
|
|
216
|
+
(0, common_utils_1.assert)(!!attachedStorageId, 0x11f /* "requesting unknown blobs" */);
|
|
217
|
+
storageId = attachedStorageId;
|
|
183
218
|
}
|
|
184
|
-
//
|
|
185
|
-
this.
|
|
186
|
-
return telemetry_utils_1.PerformanceEvent.timedExecAsync(this.logger, { eventName: "AttachmentReadBlob", id: storageId }, async () => {
|
|
219
|
+
// Let runtime know that the corresponding GC node was requested.
|
|
220
|
+
this.blobRequested(this.getBlobGCNodePath(blobId));
|
|
221
|
+
return telemetry_utils_1.PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: "AttachmentReadBlob", id: storageId }, async () => {
|
|
187
222
|
return this.getStorage().readBlob(storageId);
|
|
188
223
|
}, { end: true, cancel: "error" });
|
|
189
224
|
}
|
|
@@ -195,7 +230,7 @@ class BlobManager {
|
|
|
195
230
|
// Blobs created while the container is detached are stored in IDetachedBlobStorage.
|
|
196
231
|
// The 'IDocumentStorageService.createBlob()' call below will respond with a localId.
|
|
197
232
|
const response = await this.getStorage().createBlob(blob);
|
|
198
|
-
this.
|
|
233
|
+
this.setRedirection(response.id, undefined);
|
|
199
234
|
return this.getBlobHandle(response.id);
|
|
200
235
|
}
|
|
201
236
|
async createBlob(blob) {
|
|
@@ -204,12 +239,12 @@ class BlobManager {
|
|
|
204
239
|
}
|
|
205
240
|
if (this.runtime.attachState === container_definitions_1.AttachState.Attaching) {
|
|
206
241
|
// blob upload is not supported in "Attaching" state
|
|
207
|
-
this.logger.sendTelemetryEvent({ eventName: "CreateBlobWhileAttaching" });
|
|
242
|
+
this.mc.logger.sendTelemetryEvent({ eventName: "CreateBlobWhileAttaching" });
|
|
208
243
|
await new Promise((resolve) => this.runtime.once("attached", resolve));
|
|
209
244
|
}
|
|
210
245
|
(0, common_utils_1.assert)(this.runtime.attachState === container_definitions_1.AttachState.Attached, 0x385 /* For clarity and paranoid defense against adding future attachment states */);
|
|
211
|
-
// Create a local ID for
|
|
212
|
-
//
|
|
246
|
+
// Create a local ID for the blob. After uploading it to storage and before returning it, a local ID to
|
|
247
|
+
// storage ID mapping is created.
|
|
213
248
|
const localId = (0, uuid_1.v4)();
|
|
214
249
|
const pendingEntry = {
|
|
215
250
|
blob,
|
|
@@ -221,7 +256,27 @@ class BlobManager {
|
|
|
221
256
|
return pendingEntry.handleP.promise;
|
|
222
257
|
}
|
|
223
258
|
async uploadBlob(localId, blob) {
|
|
224
|
-
return telemetry_utils_1.PerformanceEvent.timedExecAsync(this.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));
|
|
259
|
+
return telemetry_utils_1.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));
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Set up a mapping in the redirect table from fromId to toId. Also, notify the runtime that a reference is added
|
|
263
|
+
* which is required for GC.
|
|
264
|
+
*/
|
|
265
|
+
setRedirection(fromId, toId) {
|
|
266
|
+
this.redirectTable.set(fromId, toId);
|
|
267
|
+
// Notify runtime of a reference added if toId is not undefined. It can be undefined when a blob is uploaded in
|
|
268
|
+
// detached mode. In this case, the entry will be updated when the blob is updated.
|
|
269
|
+
if (toId !== undefined) {
|
|
270
|
+
this.addedBlobReference(this.getBlobGCNodePath(fromId), this.getBlobGCNodePath(toId));
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
deleteAndEmitsIfEmpty(id) {
|
|
274
|
+
if (this.pendingBlobs.has(id)) {
|
|
275
|
+
this.pendingBlobs.delete(id);
|
|
276
|
+
if (!this.hasPendingBlobs) {
|
|
277
|
+
this.emit("noPendingBlobs");
|
|
278
|
+
}
|
|
279
|
+
}
|
|
225
280
|
}
|
|
226
281
|
onUploadResolve(localId, response) {
|
|
227
282
|
var _a;
|
|
@@ -229,19 +284,30 @@ class BlobManager {
|
|
|
229
284
|
(0, common_utils_1.assert)((entry === null || entry === void 0 ? void 0 : entry.status) === PendingBlobStatus.OnlinePendingUpload ||
|
|
230
285
|
(entry === null || entry === void 0 ? void 0 : entry.status) === PendingBlobStatus.OfflinePendingUpload, 0x386 /* Must have pending blob entry for uploaded blob */);
|
|
231
286
|
entry.storageId = response.id;
|
|
287
|
+
entry.localUploadTime = Date.now();
|
|
288
|
+
entry.minTTLInSeconds = response.minTTLInSeconds;
|
|
289
|
+
entry.serverUploadTime = this.getCurrentReferenceTimestampMs();
|
|
232
290
|
if (this.runtime.connected) {
|
|
233
291
|
if (entry.status === PendingBlobStatus.OnlinePendingUpload) {
|
|
292
|
+
// Send a blob attach op. This serves two purposes:
|
|
293
|
+
// 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
|
|
294
|
+
// until its storage ID is added to the next summary.
|
|
295
|
+
// 2. It will create a local ID to storage ID mapping in all clients which is needed to retrieve the
|
|
296
|
+
// blob from the server via the storage ID.
|
|
297
|
+
this.logTimeInfo(entry, "sendBlobAttachResolveTTL");
|
|
298
|
+
this.sendBlobAttachOp(localId, response.id);
|
|
234
299
|
if (this.storageIds.has(response.id)) {
|
|
235
|
-
//
|
|
236
|
-
//
|
|
237
|
-
|
|
238
|
-
this.
|
|
300
|
+
// The blob is de-duped. Set up a local ID to storage ID mapping and return the blob. Since this is
|
|
301
|
+
// an existing blob, we don't have to wait for the op to be ack'd since this step has already
|
|
302
|
+
// happened before and so, the server won't delete it.
|
|
303
|
+
this.setRedirection(localId, response.id);
|
|
304
|
+
entry.handleP.resolve(this.getBlobHandle(localId));
|
|
305
|
+
this.deleteAndEmitsIfEmpty(localId);
|
|
239
306
|
}
|
|
240
307
|
else {
|
|
241
|
-
//
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
308
|
+
// If there is already an op for this storage ID, append the local ID to the list. Once any op for
|
|
309
|
+
// this storage ID is ack'd, all pending blobs for it can be resolved since the op will keep the
|
|
310
|
+
// blob alive in storage.
|
|
245
311
|
this.opsInFlight.set(response.id, ((_a = this.opsInFlight.get(response.id)) !== null && _a !== void 0 ? _a : []).concat(localId));
|
|
246
312
|
entry.status = PendingBlobStatus.OnlinePendingOp;
|
|
247
313
|
}
|
|
@@ -253,7 +319,7 @@ class BlobManager {
|
|
|
253
319
|
}
|
|
254
320
|
else {
|
|
255
321
|
// connected to storage but not ordering service?
|
|
256
|
-
this.logger.sendTelemetryEvent({ eventName: "BlobUploadSuccessWhileDisconnected" });
|
|
322
|
+
this.mc.logger.sendTelemetryEvent({ eventName: "BlobUploadSuccessWhileDisconnected" });
|
|
257
323
|
if (entry.status === PendingBlobStatus.OnlinePendingUpload) {
|
|
258
324
|
this.transitionToOffline(localId);
|
|
259
325
|
}
|
|
@@ -269,7 +335,9 @@ class BlobManager {
|
|
|
269
335
|
this.transitionToOffline(localId);
|
|
270
336
|
}
|
|
271
337
|
// we are probably not connected to storage but start another upload request in case we are
|
|
272
|
-
entry.uploadP = this.retryThrottler
|
|
338
|
+
entry.uploadP = this.retryThrottler
|
|
339
|
+
.getDelay()
|
|
340
|
+
.then(async () => this.uploadBlob(localId, entry.blob));
|
|
273
341
|
return entry.uploadP;
|
|
274
342
|
}
|
|
275
343
|
else {
|
|
@@ -282,15 +350,21 @@ class BlobManager {
|
|
|
282
350
|
const entry = this.pendingBlobs.get(localId);
|
|
283
351
|
(0, common_utils_1.assert)(!!entry, 0x389 /* No pending blob entry */);
|
|
284
352
|
(0, common_utils_1.assert)([PendingBlobStatus.OnlinePendingUpload, PendingBlobStatus.OnlinePendingOp].includes(entry.status), 0x38a /* Blob must be in online flow to transition to offline flow */);
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
353
|
+
/**
|
|
354
|
+
* If we haven't already submitted a BlobAttach op for this entry, send it before returning the blob handle.
|
|
355
|
+
* This will make sure that the BlobAttach op is sequenced prior to any ops referencing the handle. Otherwise,
|
|
356
|
+
* an invalid handle could be added to the document.
|
|
357
|
+
* storageId may be undefined but since we are not connected we will have a chance to add it when reSubmit()
|
|
358
|
+
* is called on reconnection.
|
|
359
|
+
*/
|
|
360
|
+
if (entry.status !== PendingBlobStatus.OnlinePendingOp) {
|
|
361
|
+
this.logTimeInfo(entry, "sendBlobAttachTransitionOfflineTTL");
|
|
362
|
+
this.sendBlobAttachOp(localId, entry.storageId);
|
|
363
|
+
}
|
|
364
|
+
entry.status =
|
|
365
|
+
entry.status === PendingBlobStatus.OnlinePendingUpload
|
|
366
|
+
? PendingBlobStatus.OfflinePendingUpload
|
|
367
|
+
: PendingBlobStatus.OfflinePendingOp;
|
|
294
368
|
entry.handleP.resolve(this.getBlobHandle(localId));
|
|
295
369
|
}
|
|
296
370
|
/**
|
|
@@ -300,45 +374,81 @@ class BlobManager {
|
|
|
300
374
|
*/
|
|
301
375
|
reSubmit(metadata) {
|
|
302
376
|
(0, common_utils_1.assert)(!!metadata, 0x38b /* Resubmitted ops must have metadata */);
|
|
303
|
-
const {
|
|
377
|
+
const { localId, blobId } = metadata;
|
|
378
|
+
(0, common_utils_1.assert)(localId !== undefined, 0x50d /* local ID not available on reSubmit */);
|
|
379
|
+
const pendingEntry = this.pendingBlobs.get(localId);
|
|
380
|
+
if (pendingEntry) {
|
|
381
|
+
this.logTimeInfo(pendingEntry, "sendBlobAttachResubmitTTL");
|
|
382
|
+
}
|
|
304
383
|
if (!blobId) {
|
|
305
|
-
(0, common_utils_1.assert)(!!localId, 0x38c /* Submitted BlobAttach ops must have a blobId or localId */);
|
|
306
384
|
// We submitted this op while offline. The blob should have been uploaded by now.
|
|
307
|
-
const pendingEntry = this.pendingBlobs.get(localId);
|
|
308
385
|
(0, common_utils_1.assert)((pendingEntry === null || pendingEntry === void 0 ? void 0 : pendingEntry.status) === PendingBlobStatus.OfflinePendingOp &&
|
|
309
386
|
!!(pendingEntry === null || pendingEntry === void 0 ? void 0 : pendingEntry.storageId), 0x38d /* blob must be uploaded before resubmitting BlobAttach op */);
|
|
310
|
-
return this.sendBlobAttachOp(pendingEntry.storageId
|
|
387
|
+
return this.sendBlobAttachOp(localId, pendingEntry.storageId);
|
|
311
388
|
}
|
|
312
|
-
return this.sendBlobAttachOp(
|
|
389
|
+
return this.sendBlobAttachOp(localId, blobId);
|
|
390
|
+
}
|
|
391
|
+
logTimeInfo(pendingEntry, eventName) {
|
|
392
|
+
var _a, _b;
|
|
393
|
+
let timeLapseSinceLocalUpload = 0;
|
|
394
|
+
let timeLapseSinceServerUpload = 0;
|
|
395
|
+
let expiredUsingLocalTime;
|
|
396
|
+
let expiredUsingServerTime;
|
|
397
|
+
if (pendingEntry.localUploadTime) {
|
|
398
|
+
timeLapseSinceLocalUpload = (Date.now() - pendingEntry.localUploadTime) / 1000;
|
|
399
|
+
expiredUsingLocalTime =
|
|
400
|
+
((_a = pendingEntry.minTTLInSeconds) !== null && _a !== void 0 ? _a : 0) - timeLapseSinceLocalUpload < 0 ? true : false;
|
|
401
|
+
}
|
|
402
|
+
if (pendingEntry.serverUploadTime) {
|
|
403
|
+
timeLapseSinceServerUpload = (Date.now() - pendingEntry.serverUploadTime) / 1000;
|
|
404
|
+
expiredUsingServerTime =
|
|
405
|
+
((_b = pendingEntry.minTTLInSeconds) !== null && _b !== void 0 ? _b : 0) - timeLapseSinceServerUpload < 0 ? true : false;
|
|
406
|
+
}
|
|
407
|
+
this.mc.logger.sendTelemetryEvent({
|
|
408
|
+
eventName,
|
|
409
|
+
entryStatus: pendingEntry.status,
|
|
410
|
+
timeLapseSinceLocalUpload,
|
|
411
|
+
timeLapseSinceServerUpload,
|
|
412
|
+
minTTLInSeconds: pendingEntry.minTTLInSeconds,
|
|
413
|
+
expiredUsingLocalTime,
|
|
414
|
+
expiredUsingServerTime,
|
|
415
|
+
});
|
|
313
416
|
}
|
|
314
417
|
processBlobAttachOp(message, local) {
|
|
315
418
|
var _a, _b;
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
419
|
+
const localId = (_a = message.metadata) === null || _a === void 0 ? void 0 : _a.localId;
|
|
420
|
+
const blobId = (_b = message.metadata) === null || _b === void 0 ? void 0 : _b.blobId;
|
|
421
|
+
(0, common_utils_1.assert)(blobId !== undefined, 0x12a /* "Missing blob id on metadata" */);
|
|
422
|
+
// Set up a mapping from local ID to storage ID. This is crucial since without this the blob cannot be
|
|
423
|
+
// requested from the server.
|
|
424
|
+
// Note: The check for undefined is needed for back-compat when localId was not part of the BlobAttach op that
|
|
425
|
+
// was sent when online.
|
|
426
|
+
if (localId !== undefined) {
|
|
427
|
+
this.setRedirection(localId, blobId);
|
|
319
428
|
}
|
|
320
429
|
// set identity (id -> id) entry
|
|
321
|
-
this.
|
|
430
|
+
this.setRedirection(blobId, blobId);
|
|
322
431
|
if (local) {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
432
|
+
(0, common_utils_1.assert)(localId !== undefined, 0x50e /* local ID not present in blob attach message */);
|
|
433
|
+
const waitingBlobs = this.opsInFlight.get(blobId);
|
|
434
|
+
if (waitingBlobs !== undefined) {
|
|
435
|
+
// For each op corresponding to this storage ID that we are waiting for, resolve the pending blob.
|
|
436
|
+
// This is safe because the server will keep the blob alive and the op containing the local ID to
|
|
437
|
+
// storage ID is already in flight and any op containing this local ID will be sequenced after that.
|
|
438
|
+
waitingBlobs.forEach((pendingLocalId) => {
|
|
439
|
+
const pendingBlobEntry = this.pendingBlobs.get(pendingLocalId);
|
|
440
|
+
(0, common_utils_1.assert)(pendingBlobEntry !== undefined, 0x38f /* local online BlobAttach op with no pending blob entry */);
|
|
330
441
|
// It's possible we transitioned to offline flow while waiting for this op.
|
|
331
442
|
if (pendingBlobEntry.status === PendingBlobStatus.OnlinePendingOp) {
|
|
332
|
-
|
|
333
|
-
|
|
443
|
+
this.setRedirection(pendingLocalId, blobId);
|
|
444
|
+
pendingBlobEntry.handleP.resolve(this.getBlobHandle(pendingLocalId));
|
|
445
|
+
this.deleteAndEmitsIfEmpty(pendingLocalId);
|
|
334
446
|
}
|
|
335
447
|
});
|
|
448
|
+
this.opsInFlight.delete(blobId);
|
|
336
449
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
(0, common_utils_1.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" */);
|
|
340
|
-
this.pendingBlobs.delete(message.metadata.localId);
|
|
341
|
-
}
|
|
450
|
+
// For blobs that were transitioned to offline flow while waiting for this op, the entry should be deleted.
|
|
451
|
+
this.deleteAndEmitsIfEmpty(localId);
|
|
342
452
|
}
|
|
343
453
|
}
|
|
344
454
|
/**
|
|
@@ -357,7 +467,8 @@ class BlobManager {
|
|
|
357
467
|
redirectTable = await tryFetchBlob(tableId);
|
|
358
468
|
}
|
|
359
469
|
const ids = Object.entries(blobsTree.blobs)
|
|
360
|
-
.filter(([k, _]) => k !== this.redirectTableBlobName)
|
|
470
|
+
.filter(([k, _]) => k !== this.redirectTableBlobName)
|
|
471
|
+
.map(([_, v]) => v);
|
|
361
472
|
return { ids, redirectTable };
|
|
362
473
|
}
|
|
363
474
|
/**
|
|
@@ -365,7 +476,7 @@ class BlobManager {
|
|
|
365
476
|
*/
|
|
366
477
|
load(snapshot) {
|
|
367
478
|
var _a, _b, _c;
|
|
368
|
-
this.logger.sendTelemetryEvent({
|
|
479
|
+
this.mc.logger.sendTelemetryEvent({
|
|
369
480
|
eventName: "AttachmentBlobsLoaded",
|
|
370
481
|
count: (_b = (_a = snapshot.ids) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
|
|
371
482
|
redirectTable: (_c = snapshot.redirectTable) === null || _c === void 0 ? void 0 : _c.length,
|
|
@@ -387,49 +498,93 @@ class BlobManager {
|
|
|
387
498
|
*/
|
|
388
499
|
getGCData(fullGC = false) {
|
|
389
500
|
const gcData = { gcNodes: {} };
|
|
390
|
-
/**
|
|
391
|
-
* The node path is of the format `/_blobs/blobId`. This path must match the path of the blob handle returned
|
|
392
|
-
* by the createBlob API because blobs are marked referenced by storing these handles in a referenced DDS.
|
|
393
|
-
*/
|
|
394
|
-
this.storageIds.forEach((blobId) => {
|
|
395
|
-
gcData.gcNodes[this.getBlobGCNodePath(blobId)] = [];
|
|
396
|
-
});
|
|
397
|
-
// For some blobs, the handle returned on creation is based off of the localId. So, these
|
|
398
|
-
// nodes can be referenced by storing the localId handle. When that happens, the corresponding storageId node
|
|
399
|
-
// must also be marked referenced. So, we add a route from the localId node to the storageId node.
|
|
400
|
-
// Note that because of de-duping, there can be multiple localIds that all redirect to the same storageId or
|
|
401
|
-
// a blob may be referenced via its storageId handle.
|
|
402
501
|
for (const [localId, storageId] of this.redirectTable) {
|
|
403
502
|
(0, common_utils_1.assert)(!!storageId, 0x390 /* Must be attached to get GC data */);
|
|
404
|
-
// Add node for the localId and add a route to the storageId node. The storageId node will have been
|
|
405
|
-
// added above when adding nodes for this.blobIds.
|
|
406
503
|
gcData.gcNodes[this.getBlobGCNodePath(localId)] = [this.getBlobGCNodePath(storageId)];
|
|
407
504
|
}
|
|
408
505
|
return gcData;
|
|
409
506
|
}
|
|
410
507
|
/**
|
|
411
|
-
*
|
|
412
|
-
* @param unusedRoutes -
|
|
508
|
+
* This is called to update blobs whose routes are unused. The unused blobs are deleted.
|
|
509
|
+
* @param unusedRoutes - The routes of the blob nodes that are unused.
|
|
413
510
|
*/
|
|
414
|
-
|
|
415
|
-
var _a;
|
|
511
|
+
updateUnusedRoutes(unusedRoutes) {
|
|
416
512
|
// The routes or blob node paths are in the same format as returned in getGCData -
|
|
417
513
|
// `/<BlobManager.basePath>/<blobId>`.
|
|
418
514
|
for (const route of unusedRoutes) {
|
|
419
515
|
const pathParts = route.split("/");
|
|
420
516
|
(0, common_utils_1.assert)(pathParts.length === 3 && pathParts[1] === BlobManager.basePath, 0x2d5 /* "Invalid blob node id in unused routes." */);
|
|
421
517
|
const blobId = pathParts[2];
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
518
|
+
this.redirectTable.delete(blobId);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* This is called to update blobs whose routes are tombstones. Tombstoned blobs enable testing scenarios with
|
|
523
|
+
* accessing deleted content without actually deleting content from summaries.
|
|
524
|
+
* @param tombstonedRoutes - The routes of blob nodes that are tombstones.
|
|
525
|
+
*/
|
|
526
|
+
updateTombstonedRoutes(tombstonedRoutes) {
|
|
527
|
+
const tombstonedBlobsSet = new Set();
|
|
528
|
+
// The routes or blob node paths are in the same format as returned in getGCData -
|
|
529
|
+
// `/<BlobManager.basePath>/<blobId>`.
|
|
530
|
+
for (const route of tombstonedRoutes) {
|
|
531
|
+
const pathParts = route.split("/");
|
|
532
|
+
(0, common_utils_1.assert)(pathParts.length === 3 && pathParts[1] === BlobManager.basePath, 0x50f /* Invalid blob node id in tombstoned routes. */);
|
|
533
|
+
tombstonedBlobsSet.add(pathParts[2]);
|
|
534
|
+
}
|
|
535
|
+
// Remove blobs from the tombstone list that were tombstoned but aren't anymore as per the tombstoneRoutes.
|
|
536
|
+
for (const blobId of this.tombstonedBlobs) {
|
|
537
|
+
if (!tombstonedBlobsSet.has(blobId)) {
|
|
538
|
+
this.tombstonedBlobs.delete(blobId);
|
|
427
539
|
}
|
|
428
540
|
}
|
|
541
|
+
// Mark blobs that are now tombstoned by adding them to the tombstone list.
|
|
542
|
+
for (const blobId of tombstonedBlobsSet) {
|
|
543
|
+
this.tombstonedBlobs.add(blobId);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Verifies that the blob with given id is valid, i.e., it has not been garbage collected. If the blob is GC'd,
|
|
548
|
+
* log an error and throw if necessary.
|
|
549
|
+
*/
|
|
550
|
+
verifyBlobValidity(blobId) {
|
|
551
|
+
/**
|
|
552
|
+
* A blob can be in one of the following states:
|
|
553
|
+
* 1. "deleted" - It has been deleted by garbage collection sweep phase.
|
|
554
|
+
* 2. "tombstoned" - It is ready for deletion but sweep phase isn't enabled and tombstone feature is enabled.
|
|
555
|
+
* 3. "valid" - It has not been deleted or tombstoned.
|
|
556
|
+
*/
|
|
557
|
+
let state = "valid";
|
|
558
|
+
if (this.isBlobDeleted(this.getBlobGCNodePath(blobId))) {
|
|
559
|
+
state = "deleted";
|
|
560
|
+
}
|
|
561
|
+
else if (this.tombstonedBlobs.has(blobId)) {
|
|
562
|
+
state = "tombstoned";
|
|
563
|
+
}
|
|
564
|
+
if (state === "valid") {
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
// If the blob is deleted or throw on tombstone load is enabled, throw an error which will fail any attempt
|
|
568
|
+
// to load the blob.
|
|
569
|
+
const shouldFail = state === "deleted" || this.throwOnTombstoneLoad;
|
|
570
|
+
const request = { url: blobId };
|
|
571
|
+
const error = (0, runtime_utils_1.responseToException)((0, runtime_utils_1.createResponseError)(404, "Blob was deleted", request, state === "tombstoned" ? { [containerRuntime_1.TombstoneResponseHeaderKey]: true } : undefined), request);
|
|
572
|
+
(0, garbageCollectionHelpers_1.sendGCUnexpectedUsageEvent)(this.mc, {
|
|
573
|
+
eventName: state === "tombstoned"
|
|
574
|
+
? "GC_Tombstone_Blob_Requested"
|
|
575
|
+
: "GC_Deleted_Blob_Requested",
|
|
576
|
+
category: shouldFail ? "error" : "generic",
|
|
577
|
+
isSummarizerClient: this.runtime.clientDetails.type === summarizerClientElection_1.summarizerClientType,
|
|
578
|
+
}, [BlobManager.basePath], error);
|
|
579
|
+
if (shouldFail) {
|
|
580
|
+
throw error;
|
|
581
|
+
}
|
|
429
582
|
}
|
|
430
583
|
summarize(telemetryContext) {
|
|
431
584
|
// if storageIds is empty, it means we are detached and have only local IDs, or that there are no blobs attached
|
|
432
|
-
const blobIds = this.storageIds.size > 0
|
|
585
|
+
const blobIds = this.storageIds.size > 0
|
|
586
|
+
? Array.from(this.storageIds)
|
|
587
|
+
: Array.from(this.redirectTable.keys());
|
|
433
588
|
const builder = new runtime_utils_1.SummaryTreeBuilder();
|
|
434
589
|
blobIds.forEach((blobId) => {
|
|
435
590
|
builder.addAttachment(blobId);
|
|
@@ -438,8 +593,7 @@ class BlobManager {
|
|
|
438
593
|
if (this.redirectTable.size > blobIds.length) {
|
|
439
594
|
builder.addBlob(BlobManager.redirectTableBlobName,
|
|
440
595
|
// filter out identity entries
|
|
441
|
-
JSON.stringify(Array.from(this.redirectTable.entries())
|
|
442
|
-
.filter(([localId, storageId]) => localId !== storageId)));
|
|
596
|
+
JSON.stringify(Array.from(this.redirectTable.entries()).filter(([localId, storageId]) => localId !== storageId)));
|
|
443
597
|
}
|
|
444
598
|
return builder.getSummaryTree();
|
|
445
599
|
}
|
|
@@ -448,9 +602,9 @@ class BlobManager {
|
|
|
448
602
|
(0, common_utils_1.assert)(this.redirectTable.size === table.size, 0x391 /* Redirect table size must match BlobManager's local ID count */);
|
|
449
603
|
for (const [localId, storageId] of table) {
|
|
450
604
|
(0, common_utils_1.assert)(this.redirectTable.has(localId), 0x254 /* "unrecognized id in redirect table" */);
|
|
451
|
-
this.
|
|
605
|
+
this.setRedirection(localId, storageId);
|
|
452
606
|
// set identity (id -> id) entry
|
|
453
|
-
this.
|
|
607
|
+
this.setRedirection(storageId, storageId);
|
|
454
608
|
}
|
|
455
609
|
}
|
|
456
610
|
getPendingBlobs() {
|