@fluidframework/container-runtime 2.0.0-internal.7.2.2 → 2.0.0-internal.7.4.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/CHANGELOG.md +22 -0
- package/README.md +1 -2
- package/api-extractor-lint.json +13 -0
- package/api-extractor.json +9 -1
- package/api-report/container-runtime.api.md +124 -107
- package/dist/batchTracker.d.ts +1 -0
- package/dist/batchTracker.d.ts.map +1 -1
- package/dist/blobManager.d.ts +4 -4
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js.map +1 -1
- package/dist/connectionTelemetry.js +1 -1
- package/dist/connectionTelemetry.js.map +1 -1
- package/dist/container-runtime-alpha.d.ts +1473 -0
- package/dist/container-runtime-beta.d.ts +300 -0
- package/dist/container-runtime-public.d.ts +300 -0
- package/dist/container-runtime-untrimmed.d.ts +1836 -0
- package/dist/containerRuntime.d.ts +34 -40
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +79 -67
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStoreRegistry.d.ts +1 -1
- package/dist/dataStoreRegistry.js +1 -1
- package/dist/dataStoreRegistry.js.map +1 -1
- package/dist/dataStores.d.ts +10 -15
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/dataStores.js +77 -40
- package/dist/dataStores.js.map +1 -1
- package/dist/gc/garbageCollection.d.ts +41 -13
- package/dist/gc/garbageCollection.d.ts.map +1 -1
- package/dist/gc/garbageCollection.js +215 -78
- package/dist/gc/garbageCollection.js.map +1 -1
- package/dist/gc/gcConfigs.d.ts.map +1 -1
- package/dist/gc/gcConfigs.js +34 -37
- package/dist/gc/gcConfigs.js.map +1 -1
- package/dist/gc/gcDefinitions.d.ts +121 -46
- package/dist/gc/gcDefinitions.d.ts.map +1 -1
- package/dist/gc/gcDefinitions.js +26 -18
- package/dist/gc/gcDefinitions.js.map +1 -1
- package/dist/gc/gcHelpers.d.ts +18 -25
- package/dist/gc/gcHelpers.d.ts.map +1 -1
- package/dist/gc/gcHelpers.js +29 -45
- package/dist/gc/gcHelpers.js.map +1 -1
- package/dist/gc/gcTelemetry.d.ts +0 -5
- package/dist/gc/gcTelemetry.d.ts.map +1 -1
- package/dist/gc/gcTelemetry.js +14 -42
- package/dist/gc/gcTelemetry.js.map +1 -1
- package/dist/gc/gcUnreferencedStateTracker.d.ts +11 -5
- package/dist/gc/gcUnreferencedStateTracker.d.ts.map +1 -1
- package/dist/gc/gcUnreferencedStateTracker.js +43 -19
- package/dist/gc/gcUnreferencedStateTracker.js.map +1 -1
- package/dist/gc/index.d.ts +1 -1
- package/dist/gc/index.d.ts.map +1 -1
- package/dist/gc/index.js +4 -5
- package/dist/gc/index.js.map +1 -1
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -5
- package/dist/index.js.map +1 -1
- package/dist/messageTypes.d.ts +16 -11
- package/dist/messageTypes.d.ts.map +1 -1
- package/dist/messageTypes.js +6 -1
- package/dist/messageTypes.js.map +1 -1
- package/dist/metadata.d.ts +6 -0
- package/dist/metadata.d.ts.map +1 -1
- package/dist/metadata.js.map +1 -1
- package/dist/opLifecycle/definitions.d.ts +1 -1
- package/dist/opLifecycle/definitions.js.map +1 -1
- package/dist/opLifecycle/opGroupingManager.d.ts.map +1 -1
- package/dist/opLifecycle/opGroupingManager.js +10 -1
- package/dist/opLifecycle/opGroupingManager.js.map +1 -1
- package/dist/opLifecycle/outbox.d.ts +2 -0
- package/dist/opLifecycle/outbox.d.ts.map +1 -1
- package/dist/opLifecycle/outbox.js +21 -0
- package/dist/opLifecycle/outbox.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 +1 -1
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +2 -11
- package/dist/pendingStateManager.js.map +1 -1
- package/dist/scheduleManager.d.ts +1 -0
- package/dist/scheduleManager.d.ts.map +1 -1
- package/dist/summary/orderedClientElection.d.ts +1 -1
- package/dist/summary/orderedClientElection.js.map +1 -1
- package/dist/summary/runWhileConnectedCoordinator.d.ts +2 -2
- package/dist/summary/runWhileConnectedCoordinator.js +1 -1
- package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
- package/dist/summary/summarizer.d.ts +1 -1
- package/dist/summary/summarizer.js +1 -1
- package/dist/summary/summarizer.js.map +1 -1
- package/dist/summary/summarizerTypes.d.ts +30 -30
- package/dist/summary/summarizerTypes.js.map +1 -1
- package/dist/summary/summaryCollection.d.ts +10 -10
- package/dist/summary/summaryCollection.js +1 -1
- package/dist/summary/summaryCollection.js.map +1 -1
- package/dist/summary/summaryFormat.d.ts +3 -3
- package/dist/summary/summaryFormat.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/batchTracker.d.ts +1 -0
- package/lib/batchTracker.d.ts.map +1 -1
- package/lib/blobManager.d.ts +4 -4
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js.map +1 -1
- package/lib/connectionTelemetry.js +1 -1
- package/lib/connectionTelemetry.js.map +1 -1
- package/lib/container-runtime-alpha.d.ts +1473 -0
- package/lib/container-runtime-beta.d.ts +300 -0
- package/lib/container-runtime-public.d.ts +300 -0
- package/lib/container-runtime-untrimmed.d.ts +1836 -0
- package/lib/containerRuntime.d.ts +34 -40
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +81 -69
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStoreRegistry.d.ts +1 -1
- package/lib/dataStoreRegistry.js +1 -1
- package/lib/dataStoreRegistry.js.map +1 -1
- package/lib/dataStores.d.ts +10 -15
- package/lib/dataStores.d.ts.map +1 -1
- package/lib/dataStores.js +80 -43
- package/lib/dataStores.js.map +1 -1
- package/lib/gc/garbageCollection.d.ts +41 -13
- package/lib/gc/garbageCollection.d.ts.map +1 -1
- package/lib/gc/garbageCollection.js +217 -80
- package/lib/gc/garbageCollection.js.map +1 -1
- package/lib/gc/gcConfigs.d.ts.map +1 -1
- package/lib/gc/gcConfigs.js +37 -40
- package/lib/gc/gcConfigs.js.map +1 -1
- package/lib/gc/gcDefinitions.d.ts +121 -46
- package/lib/gc/gcDefinitions.d.ts.map +1 -1
- package/lib/gc/gcDefinitions.js +25 -17
- package/lib/gc/gcDefinitions.js.map +1 -1
- package/lib/gc/gcHelpers.d.ts +18 -25
- package/lib/gc/gcHelpers.d.ts.map +1 -1
- package/lib/gc/gcHelpers.js +27 -43
- package/lib/gc/gcHelpers.js.map +1 -1
- package/lib/gc/gcTelemetry.d.ts +0 -5
- package/lib/gc/gcTelemetry.d.ts.map +1 -1
- package/lib/gc/gcTelemetry.js +15 -43
- package/lib/gc/gcTelemetry.js.map +1 -1
- package/lib/gc/gcUnreferencedStateTracker.d.ts +11 -5
- package/lib/gc/gcUnreferencedStateTracker.d.ts.map +1 -1
- package/lib/gc/gcUnreferencedStateTracker.js +43 -19
- package/lib/gc/gcUnreferencedStateTracker.js.map +1 -1
- package/lib/gc/index.d.ts +1 -1
- package/lib/gc/index.d.ts.map +1 -1
- package/lib/gc/index.js +1 -1
- package/lib/gc/index.js.map +1 -1
- package/lib/index.d.ts +14 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +15 -1
- package/lib/index.js.map +1 -1
- package/lib/messageTypes.d.ts +16 -11
- package/lib/messageTypes.d.ts.map +1 -1
- package/lib/messageTypes.js +6 -1
- package/lib/messageTypes.js.map +1 -1
- package/lib/metadata.d.ts +6 -0
- package/lib/metadata.d.ts.map +1 -1
- package/lib/metadata.js.map +1 -1
- package/lib/opLifecycle/definitions.d.ts +1 -1
- package/lib/opLifecycle/definitions.js.map +1 -1
- package/lib/opLifecycle/opGroupingManager.d.ts.map +1 -1
- package/lib/opLifecycle/opGroupingManager.js +10 -1
- package/lib/opLifecycle/opGroupingManager.js.map +1 -1
- package/lib/opLifecycle/outbox.d.ts +2 -0
- package/lib/opLifecycle/outbox.d.ts.map +1 -1
- package/lib/opLifecycle/outbox.js +21 -0
- package/lib/opLifecycle/outbox.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 +1 -1
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +2 -11
- package/lib/pendingStateManager.js.map +1 -1
- package/lib/scheduleManager.d.ts +1 -0
- package/lib/scheduleManager.d.ts.map +1 -1
- package/lib/summary/orderedClientElection.d.ts +1 -1
- package/lib/summary/orderedClientElection.js.map +1 -1
- package/lib/summary/runWhileConnectedCoordinator.d.ts +2 -2
- package/lib/summary/runWhileConnectedCoordinator.js +1 -1
- package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
- package/lib/summary/summarizer.d.ts +1 -1
- package/lib/summary/summarizer.js +1 -1
- package/lib/summary/summarizer.js.map +1 -1
- package/lib/summary/summarizerTypes.d.ts +30 -30
- package/lib/summary/summarizerTypes.js.map +1 -1
- package/lib/summary/summaryCollection.d.ts +10 -10
- package/lib/summary/summaryCollection.js +1 -1
- package/lib/summary/summaryCollection.js.map +1 -1
- package/lib/summary/summaryFormat.d.ts +3 -3
- package/lib/summary/summaryFormat.js.map +1 -1
- package/package.json +56 -29
- package/src/blobManager.ts +5 -5
- package/src/connectionTelemetry.ts +1 -1
- package/src/containerRuntime.ts +113 -90
- package/src/dataStoreRegistry.ts +1 -1
- package/src/dataStores.ts +140 -69
- package/src/gc/garbageCollection.md +14 -15
- package/src/gc/garbageCollection.ts +256 -96
- package/src/gc/gcConfigs.ts +50 -52
- package/src/gc/gcDefinitions.ts +137 -52
- package/src/gc/gcHelpers.ts +31 -52
- package/src/gc/gcTelemetry.ts +16 -57
- package/src/gc/gcUnreferencedStateTracker.ts +61 -22
- package/src/gc/index.ts +6 -4
- package/src/index.ts +19 -1
- package/src/messageTypes.ts +21 -11
- package/src/metadata.ts +7 -0
- package/src/opLifecycle/definitions.ts +1 -1
- package/src/opLifecycle/opGroupingManager.ts +10 -1
- package/src/opLifecycle/outbox.ts +34 -0
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +3 -13
- package/src/summary/orderedClientElection.ts +1 -1
- package/src/summary/runWhileConnectedCoordinator.ts +2 -2
- package/src/summary/summarizer.ts +1 -1
- package/src/summary/summarizerTypes.ts +30 -30
- package/src/summary/summaryCollection.ts +10 -10
- package/src/summary/summaryFormat.ts +3 -3
- package/dist/id-compressor/appendOnlySortedMap.d.ts +0 -124
- package/dist/id-compressor/appendOnlySortedMap.d.ts.map +0 -1
- package/dist/id-compressor/appendOnlySortedMap.js +0 -318
- package/dist/id-compressor/appendOnlySortedMap.js.map +0 -1
- package/dist/id-compressor/finalSpace.d.ts +0 -29
- package/dist/id-compressor/finalSpace.d.ts.map +0 -1
- package/dist/id-compressor/finalSpace.js +0 -62
- package/dist/id-compressor/finalSpace.js.map +0 -1
- package/dist/id-compressor/idCompressor.d.ts +0 -54
- package/dist/id-compressor/idCompressor.d.ts.map +0 -1
- package/dist/id-compressor/idCompressor.js +0 -495
- package/dist/id-compressor/idCompressor.js.map +0 -1
- package/dist/id-compressor/identifiers.d.ts +0 -32
- package/dist/id-compressor/identifiers.d.ts.map +0 -1
- package/dist/id-compressor/identifiers.js +0 -15
- package/dist/id-compressor/identifiers.js.map +0 -1
- package/dist/id-compressor/index.d.ts +0 -13
- package/dist/id-compressor/index.d.ts.map +0 -1
- package/dist/id-compressor/index.js +0 -32
- package/dist/id-compressor/index.js.map +0 -1
- package/dist/id-compressor/persistanceUtilities.d.ts +0 -22
- package/dist/id-compressor/persistanceUtilities.d.ts.map +0 -1
- package/dist/id-compressor/persistanceUtilities.js +0 -43
- package/dist/id-compressor/persistanceUtilities.js.map +0 -1
- package/dist/id-compressor/sessionSpaceNormalizer.d.ts +0 -46
- package/dist/id-compressor/sessionSpaceNormalizer.d.ts.map +0 -1
- package/dist/id-compressor/sessionSpaceNormalizer.js +0 -80
- package/dist/id-compressor/sessionSpaceNormalizer.js.map +0 -1
- package/dist/id-compressor/sessions.d.ts +0 -115
- package/dist/id-compressor/sessions.d.ts.map +0 -1
- package/dist/id-compressor/sessions.js +0 -305
- package/dist/id-compressor/sessions.js.map +0 -1
- package/dist/id-compressor/utilities.d.ts +0 -52
- package/dist/id-compressor/utilities.d.ts.map +0 -1
- package/dist/id-compressor/utilities.js +0 -169
- package/dist/id-compressor/utilities.js.map +0 -1
- package/lib/id-compressor/appendOnlySortedMap.d.ts +0 -124
- package/lib/id-compressor/appendOnlySortedMap.d.ts.map +0 -1
- package/lib/id-compressor/appendOnlySortedMap.js +0 -314
- package/lib/id-compressor/appendOnlySortedMap.js.map +0 -1
- package/lib/id-compressor/finalSpace.d.ts +0 -29
- package/lib/id-compressor/finalSpace.d.ts.map +0 -1
- package/lib/id-compressor/finalSpace.js +0 -58
- package/lib/id-compressor/finalSpace.js.map +0 -1
- package/lib/id-compressor/idCompressor.d.ts +0 -54
- package/lib/id-compressor/idCompressor.d.ts.map +0 -1
- package/lib/id-compressor/idCompressor.js +0 -491
- package/lib/id-compressor/idCompressor.js.map +0 -1
- package/lib/id-compressor/identifiers.d.ts +0 -32
- package/lib/id-compressor/identifiers.d.ts.map +0 -1
- package/lib/id-compressor/identifiers.js +0 -11
- package/lib/id-compressor/identifiers.js.map +0 -1
- package/lib/id-compressor/index.d.ts +0 -13
- package/lib/id-compressor/index.d.ts.map +0 -1
- package/lib/id-compressor/index.js +0 -13
- package/lib/id-compressor/index.js.map +0 -1
- package/lib/id-compressor/persistanceUtilities.d.ts +0 -22
- package/lib/id-compressor/persistanceUtilities.d.ts.map +0 -1
- package/lib/id-compressor/persistanceUtilities.js +0 -34
- package/lib/id-compressor/persistanceUtilities.js.map +0 -1
- package/lib/id-compressor/sessionSpaceNormalizer.d.ts +0 -46
- package/lib/id-compressor/sessionSpaceNormalizer.d.ts.map +0 -1
- package/lib/id-compressor/sessionSpaceNormalizer.js +0 -76
- package/lib/id-compressor/sessionSpaceNormalizer.js.map +0 -1
- package/lib/id-compressor/sessions.d.ts +0 -115
- package/lib/id-compressor/sessions.d.ts.map +0 -1
- package/lib/id-compressor/sessions.js +0 -290
- package/lib/id-compressor/sessions.js.map +0 -1
- package/lib/id-compressor/utilities.d.ts +0 -52
- package/lib/id-compressor/utilities.d.ts.map +0 -1
- package/lib/id-compressor/utilities.js +0 -151
- package/lib/id-compressor/utilities.js.map +0 -1
- package/src/id-compressor/README.md +0 -3
- package/src/id-compressor/appendOnlySortedMap.ts +0 -366
- package/src/id-compressor/finalSpace.ts +0 -67
- package/src/id-compressor/idCompressor.ts +0 -630
- package/src/id-compressor/identifiers.ts +0 -42
- package/src/id-compressor/index.ts +0 -26
- package/src/id-compressor/persistanceUtilities.ts +0 -58
- package/src/id-compressor/sessionSpaceNormalizer.ts +0 -83
- package/src/id-compressor/sessions.ts +0 -405
- package/src/id-compressor/utilities.ts +0 -190
package/src/gc/gcConfigs.ts
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
MonitoringContext,
|
|
8
|
+
UsageError,
|
|
9
|
+
validatePrecondition,
|
|
10
|
+
} from "@fluidframework/telemetry-utils";
|
|
7
11
|
import { IContainerRuntimeMetadata } from "../summary";
|
|
8
12
|
import {
|
|
9
13
|
nextGCVersion,
|
|
@@ -11,9 +15,7 @@ import {
|
|
|
11
15
|
defaultSessionExpiryDurationMs,
|
|
12
16
|
disableTombstoneKey,
|
|
13
17
|
GCFeatureMatrix,
|
|
14
|
-
gcSweepGenerationOptionName,
|
|
15
18
|
gcTestModeKey,
|
|
16
|
-
gcTombstoneGenerationOptionName,
|
|
17
19
|
GCVersion,
|
|
18
20
|
gcVersionUpgradeToV4Key,
|
|
19
21
|
IGarbageCollectorConfigs,
|
|
@@ -26,9 +28,11 @@ import {
|
|
|
26
28
|
stableGCVersion,
|
|
27
29
|
throwOnTombstoneLoadOverrideKey,
|
|
28
30
|
throwOnTombstoneUsageKey,
|
|
29
|
-
|
|
31
|
+
gcDisableThrowOnTombstoneLoadOptionName,
|
|
32
|
+
defaultSweepGracePeriodMs,
|
|
33
|
+
gcGenerationOptionName,
|
|
30
34
|
} from "./gcDefinitions";
|
|
31
|
-
import { getGCVersion, shouldAllowGcSweep
|
|
35
|
+
import { getGCVersion, shouldAllowGcSweep } from "./gcHelpers";
|
|
32
36
|
|
|
33
37
|
/**
|
|
34
38
|
* Generates configurations for the Garbage Collector that it uses to determine what to run and how.
|
|
@@ -71,14 +75,6 @@ export function generateGCConfigs(
|
|
|
71
75
|
createParams.metadata?.sweepTimeoutMs ?? computeSweepTimeout(sessionExpiryTimeoutMs); // Backfill old documents that didn't persist this
|
|
72
76
|
persistedGcFeatureMatrix = createParams.metadata?.gcFeatureMatrix;
|
|
73
77
|
} else {
|
|
74
|
-
const tombstoneGeneration = createParams.gcOptions[gcTombstoneGenerationOptionName];
|
|
75
|
-
const sweepGeneration = createParams.gcOptions[gcSweepGenerationOptionName];
|
|
76
|
-
|
|
77
|
-
// Sweep should not be enabled (via sweepGeneration value) without enabling GC mark phase.
|
|
78
|
-
if (sweepGeneration !== undefined && createParams.gcOptions.gcAllowed === false) {
|
|
79
|
-
throw new UsageError("GC sweep phase cannot be enabled without enabling GC mark phase");
|
|
80
|
-
}
|
|
81
|
-
|
|
82
78
|
// This Test Override only applies for new containers
|
|
83
79
|
const testOverrideSweepTimeoutMs = mc.config.getNumber(
|
|
84
80
|
"Fluid.GarbageCollection.TestOverride.SweepTimeoutMs",
|
|
@@ -95,18 +91,18 @@ export function generateGCConfigs(
|
|
|
95
91
|
}
|
|
96
92
|
sweepTimeoutMs = testOverrideSweepTimeoutMs ?? computeSweepTimeout(sessionExpiryTimeoutMs);
|
|
97
93
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
sweepGeneration,
|
|
102
|
-
};
|
|
94
|
+
const gcGeneration = createParams.gcOptions[gcGenerationOptionName];
|
|
95
|
+
if (gcGeneration !== undefined) {
|
|
96
|
+
persistedGcFeatureMatrix = { gcGeneration };
|
|
103
97
|
}
|
|
104
98
|
}
|
|
105
99
|
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
100
|
+
// The persisted GC generation must indicate Sweep is allowed for this document,
|
|
101
|
+
// according to the GC Generation option provided this session.
|
|
102
|
+
// Note that if no generation option is provided, Sweep is allowed for any document.
|
|
103
|
+
const sweepAllowed = shouldAllowGcSweep(
|
|
104
|
+
persistedGcFeatureMatrix ?? {} /* featureMatrix */,
|
|
105
|
+
createParams.gcOptions[gcGenerationOptionName] /* currentGeneration */,
|
|
110
106
|
);
|
|
111
107
|
|
|
112
108
|
// If version upgrade is not enabled, fall back to the stable GC version.
|
|
@@ -123,27 +119,30 @@ export function generateGCConfigs(
|
|
|
123
119
|
* Whether GC should run or not. The following conditions have to be met to run sweep:
|
|
124
120
|
* 1. GC should be enabled for this container.
|
|
125
121
|
* 2. GC should not be disabled via disableGC GC option.
|
|
126
|
-
* 3. The current GC version should be greater
|
|
127
|
-
*
|
|
122
|
+
* 3. The current GC version should be greater or equal to the GC version in the base snapshot.
|
|
123
|
+
*
|
|
124
|
+
* These conditions can be overridden via the RunGC feature flag.
|
|
128
125
|
*/
|
|
129
126
|
const shouldRunGC =
|
|
130
127
|
mc.config.getBoolean(runGCKey) ??
|
|
131
128
|
(gcEnabled && !createParams.gcOptions.disableGC && isGCVersionUpToDate);
|
|
132
129
|
|
|
133
130
|
/**
|
|
134
|
-
* Whether sweep should run or not.
|
|
131
|
+
* Whether sweep should run or not. This refers to whether Tombstones should fail on load and whether
|
|
132
|
+
* sweep-ready nodes should be deleted.
|
|
135
133
|
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* feature flag.
|
|
134
|
+
* Assuming overall GC is enabled and sweepTimeout is provided, the following conditions have to be met to run sweep:
|
|
135
|
+
*
|
|
136
|
+
* 1. Sweep should be enabled for this container.
|
|
137
|
+
* 2. Sweep should be enabled for this session.
|
|
138
|
+
*
|
|
139
|
+
* These conditions can be overridden via the RunSweep feature flag.
|
|
142
140
|
*/
|
|
143
141
|
const shouldRunSweep =
|
|
144
|
-
shouldRunGC
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
!shouldRunGC || sweepTimeoutMs === undefined
|
|
143
|
+
? false
|
|
144
|
+
: mc.config.getBoolean(runSweepKey) ??
|
|
145
|
+
(sweepAllowed && createParams.gcOptions.enableGCSweep === true);
|
|
147
146
|
|
|
148
147
|
// Override inactive timeout if test config or gc options to override it is set.
|
|
149
148
|
const inactiveTimeoutMs =
|
|
@@ -159,46 +158,45 @@ export function generateGCConfigs(
|
|
|
159
158
|
// Whether we are running in test mode. In this mode, unreferenced nodes are immediately deleted.
|
|
160
159
|
const testMode =
|
|
161
160
|
mc.config.getBoolean(gcTestModeKey) ?? createParams.gcOptions.runGCInTestMode === true;
|
|
162
|
-
// Whether we are running in tombstone mode.
|
|
163
|
-
//
|
|
164
|
-
const tombstoneMode =
|
|
161
|
+
// Whether we are running in tombstone mode. If disabled, tombstone data will not be written to or read from snapshots,
|
|
162
|
+
// and objects will not be marked as tombstoned even if they pass to the "TombstoneReady" state during the session.
|
|
163
|
+
const tombstoneMode = mc.config.getBoolean(disableTombstoneKey) !== true;
|
|
165
164
|
const runFullGC = createParams.gcOptions.runFullGC;
|
|
166
165
|
|
|
166
|
+
const sweepGracePeriodMs =
|
|
167
|
+
createParams.gcOptions.sweepGracePeriodMs ?? defaultSweepGracePeriodMs;
|
|
168
|
+
validatePrecondition(sweepGracePeriodMs >= 0, "sweepGracePeriodMs must be non-negative", {
|
|
169
|
+
sweepGracePeriodMs,
|
|
170
|
+
});
|
|
171
|
+
|
|
167
172
|
const throwOnInactiveLoad: boolean | undefined = createParams.gcOptions.throwOnInactiveLoad;
|
|
168
|
-
const tombstoneEnforcementAllowed = shouldAllowGcTombstoneEnforcement(
|
|
169
|
-
createParams.metadata?.gcFeatureMatrix?.tombstoneGeneration /* persisted */,
|
|
170
|
-
createParams.gcOptions[gcTombstoneGenerationOptionName] /* current */,
|
|
171
|
-
);
|
|
172
173
|
|
|
173
174
|
const throwOnTombstoneLoadConfig =
|
|
174
175
|
mc.config.getBoolean(throwOnTombstoneLoadOverrideKey) ??
|
|
175
|
-
createParams.gcOptions[
|
|
176
|
-
false;
|
|
176
|
+
createParams.gcOptions[gcDisableThrowOnTombstoneLoadOptionName] !== true;
|
|
177
177
|
const throwOnTombstoneLoad =
|
|
178
|
-
throwOnTombstoneLoadConfig &&
|
|
179
|
-
tombstoneEnforcementAllowed &&
|
|
180
|
-
!createParams.isSummarizerClient;
|
|
178
|
+
throwOnTombstoneLoadConfig && sweepAllowed && !createParams.isSummarizerClient;
|
|
181
179
|
const throwOnTombstoneUsage =
|
|
182
180
|
mc.config.getBoolean(throwOnTombstoneUsageKey) === true &&
|
|
183
|
-
|
|
181
|
+
sweepAllowed &&
|
|
184
182
|
!createParams.isSummarizerClient;
|
|
185
183
|
|
|
186
184
|
return {
|
|
187
|
-
gcEnabled,
|
|
188
|
-
sweepEnabled,
|
|
189
|
-
shouldRunGC,
|
|
190
|
-
shouldRunSweep,
|
|
185
|
+
gcEnabled, // For this document
|
|
186
|
+
sweepEnabled: sweepAllowed, // For this document (based on current GC Generation option)
|
|
187
|
+
shouldRunGC, // For this session
|
|
188
|
+
shouldRunSweep, // For this session
|
|
191
189
|
runFullGC,
|
|
192
190
|
testMode,
|
|
193
191
|
tombstoneMode,
|
|
194
192
|
sessionExpiryTimeoutMs,
|
|
195
193
|
sweepTimeoutMs,
|
|
194
|
+
sweepGracePeriodMs,
|
|
196
195
|
inactiveTimeoutMs,
|
|
197
196
|
persistedGcFeatureMatrix,
|
|
198
197
|
gcVersionInBaseSnapshot,
|
|
199
198
|
gcVersionInEffect,
|
|
200
199
|
throwOnInactiveLoad,
|
|
201
|
-
tombstoneEnforcementAllowed,
|
|
202
200
|
throwOnTombstoneLoad,
|
|
203
201
|
throwOnTombstoneUsage,
|
|
204
202
|
};
|
package/src/gc/gcDefinitions.ts
CHANGED
|
@@ -20,9 +20,10 @@ import {
|
|
|
20
20
|
IRefreshSummaryResult,
|
|
21
21
|
} from "../summary";
|
|
22
22
|
import { RuntimeHeaderData } from "../containerRuntime";
|
|
23
|
+
import { ContainerRuntimeGCMessage } from "../messageTypes";
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
|
-
* @
|
|
26
|
+
* @alpha
|
|
26
27
|
*/
|
|
27
28
|
export type GCVersion = number;
|
|
28
29
|
|
|
@@ -32,27 +33,25 @@ export const stableGCVersion: GCVersion = 3;
|
|
|
32
33
|
export const nextGCVersion: GCVersion = 4;
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
|
-
* This undocumented GC Option (on ContainerRuntime Options) allows an app to disable
|
|
36
|
+
* This undocumented GC Option (on ContainerRuntime Options) allows an app to disable throwing an error when tombstone
|
|
37
|
+
* object is loaded (requested), merely logging a message instead.
|
|
36
38
|
*
|
|
37
|
-
*
|
|
38
|
-
* Otherwise, only enforce GC Tombstone if the passed in value matches the persisted value
|
|
39
|
+
* By default, attempting to load a Tombstoned object will result in an error.
|
|
39
40
|
*/
|
|
40
|
-
export const
|
|
41
|
+
export const gcDisableThrowOnTombstoneLoadOptionName = "gcDisableThrowOnTombstoneLoad";
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
|
-
* This undocumented GC Option (on ContainerRuntime Options) allows
|
|
44
|
-
*
|
|
45
|
-
*/
|
|
46
|
-
export const gcThrowOnTombstoneLoadOptionName = "gcThrowOnTombstoneLoad";
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* This GC Option (on ContainerRuntime Options) allows an app to disable GC Sweep on old documents by incrementing this value.
|
|
44
|
+
* This undocumented GC Option (on ContainerRuntime Options) allows configuring which documents can have Sweep enabled.
|
|
45
|
+
* This provides a way to disable both Tombstone Enforcement and Sweep.
|
|
50
46
|
*
|
|
51
|
-
* If unset
|
|
52
|
-
*
|
|
53
|
-
*
|
|
47
|
+
* If unset, Tombstone Enforcement + Sweep will operate as otherwise configured.
|
|
48
|
+
* Otherwise, the Sweep Phase will be disabled for documents where persisted value doesn't match what is passed into this session.
|
|
49
|
+
* This provides a way to disallow Sweep for old documents that may be too difficult for an app to repair,
|
|
50
|
+
* in case a bug is found that violates GC's assumptions.
|
|
51
|
+
*
|
|
52
|
+
* @see GCFeatureMatrix (gcGeneration)
|
|
54
53
|
*/
|
|
55
|
-
export const
|
|
54
|
+
export const gcGenerationOptionName = "gcGeneration";
|
|
56
55
|
|
|
57
56
|
/** Config key to turn GC on / off. */
|
|
58
57
|
export const runGCKey = "Fluid.GarbageCollection.RunGC";
|
|
@@ -62,8 +61,6 @@ export const runSweepKey = "Fluid.GarbageCollection.RunSweep";
|
|
|
62
61
|
export const gcTestModeKey = "Fluid.GarbageCollection.GCTestMode";
|
|
63
62
|
/** Config key to expire a session after a set period of time. Defaults to true. */
|
|
64
63
|
export const runSessionExpiryKey = "Fluid.GarbageCollection.RunSessionExpiry";
|
|
65
|
-
/** Config key to turn GC sweep log off. */
|
|
66
|
-
export const disableSweepLogKey = "Fluid.GarbageCollection.DisableSweepLog";
|
|
67
64
|
/** Config key to disable the tombstone feature, i.e., tombstone information is not read / written into summary. */
|
|
68
65
|
export const disableTombstoneKey = "Fluid.GarbageCollection.DisableTombstone";
|
|
69
66
|
/** Config key to override throwing an error when tombstone object is loaded (requested). */
|
|
@@ -91,28 +88,33 @@ export const maxSnapshotCacheExpiryMs = 5 * oneDayMs;
|
|
|
91
88
|
|
|
92
89
|
export const defaultInactiveTimeoutMs = 7 * oneDayMs; // 7 days
|
|
93
90
|
export const defaultSessionExpiryDurationMs = 30 * oneDayMs; // 30 days
|
|
91
|
+
export const defaultSweepGracePeriodMs = 1 * oneDayMs; // 1 day
|
|
94
92
|
|
|
95
93
|
/**
|
|
96
|
-
* @see IGCMetadata.gcFeatureMatrix
|
|
97
|
-
* @
|
|
94
|
+
* @see IGCMetadata.gcFeatureMatrix and @see gcGenerationOptionName
|
|
95
|
+
* @alpha
|
|
98
96
|
*/
|
|
99
|
-
export
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
97
|
+
export type GCFeatureMatrix =
|
|
98
|
+
| {
|
|
99
|
+
/**
|
|
100
|
+
* The GC Generation value in effect when this file was created.
|
|
101
|
+
* Gives a way for an app to disqualify old files from GC Sweep.
|
|
102
|
+
* Provided via Container Runtime Options.
|
|
103
|
+
*/
|
|
104
|
+
gcGeneration?: number;
|
|
105
|
+
/** Deprecated property from legacy type. Will not be set concurrently with gcGeneration */
|
|
106
|
+
tombstoneGeneration?: undefined;
|
|
107
|
+
}
|
|
108
|
+
| {
|
|
109
|
+
/**
|
|
110
|
+
* The Tombstone Generation value in effect when this file was created.
|
|
111
|
+
* Legacy - new containers would get gcGeneration instead (if anything)
|
|
112
|
+
*/
|
|
113
|
+
tombstoneGeneration: number;
|
|
114
|
+
};
|
|
113
115
|
|
|
114
116
|
/**
|
|
115
|
-
* @
|
|
117
|
+
* @alpha
|
|
116
118
|
*/
|
|
117
119
|
export interface IGCMetadata {
|
|
118
120
|
/**
|
|
@@ -141,7 +143,7 @@ export interface IGCMetadata {
|
|
|
141
143
|
* - True means sweep phase is enabled.
|
|
142
144
|
* - False means sweep phase is disabled. If GC is disabled as per gcFeature, sweep is also disabled.
|
|
143
145
|
*
|
|
144
|
-
* @deprecated use GCFeatureMatrix.
|
|
146
|
+
* @deprecated use GCFeatureMatrix.gcGeneration instead. @see GCFeatureMatrix.gcGeneration
|
|
145
147
|
*/
|
|
146
148
|
readonly sweepEnabled?: boolean;
|
|
147
149
|
/** If this is present, the session for this container will expire after this time and the container will close */
|
|
@@ -151,10 +153,10 @@ export interface IGCMetadata {
|
|
|
151
153
|
}
|
|
152
154
|
|
|
153
155
|
/**
|
|
154
|
-
* The statistics of the system state after a garbage collection run.
|
|
155
|
-
* @
|
|
156
|
+
* The statistics of the system state after a garbage collection mark phase run.
|
|
157
|
+
* @alpha
|
|
156
158
|
*/
|
|
157
|
-
export interface
|
|
159
|
+
export interface IMarkPhaseStats {
|
|
158
160
|
/** The number of nodes in the container. */
|
|
159
161
|
nodeCount: number;
|
|
160
162
|
/** The number of data stores in the container. */
|
|
@@ -175,9 +177,34 @@ export interface IGCStats {
|
|
|
175
177
|
updatedAttachmentBlobCount: number;
|
|
176
178
|
}
|
|
177
179
|
|
|
180
|
+
/**
|
|
181
|
+
* The statistics of the system state after a garbage collection sweep phase run.
|
|
182
|
+
* @alpha
|
|
183
|
+
*/
|
|
184
|
+
export interface ISweepPhaseStats {
|
|
185
|
+
/** The number of nodes in the lifetime of the container. */
|
|
186
|
+
lifetimeNodeCount: number;
|
|
187
|
+
/** The number of data stores in the lifetime of the container. */
|
|
188
|
+
lifetimeDataStoreCount: number;
|
|
189
|
+
/** The number of attachment blobs in the lifetime of the container. */
|
|
190
|
+
lifetimeAttachmentBlobCount: number;
|
|
191
|
+
/** The number of deleted nodes in the container. */
|
|
192
|
+
deletedNodeCount: number;
|
|
193
|
+
/** The number of deleted data stores in the container. */
|
|
194
|
+
deletedDataStoreCount: number;
|
|
195
|
+
/** The number of deleted attachment blobs in the container. */
|
|
196
|
+
deletedAttachmentBlobCount: number;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* The statistics of the system state after a garbage collection run.
|
|
201
|
+
* @alpha
|
|
202
|
+
*/
|
|
203
|
+
export interface IGCStats extends IMarkPhaseStats, ISweepPhaseStats {}
|
|
204
|
+
|
|
178
205
|
/**
|
|
179
206
|
* The types of GC nodes in the GC reference graph.
|
|
180
|
-
* @
|
|
207
|
+
* @alpha
|
|
181
208
|
*/
|
|
182
209
|
export const GCNodeType = {
|
|
183
210
|
// Nodes that are for data stores.
|
|
@@ -191,10 +218,41 @@ export const GCNodeType = {
|
|
|
191
218
|
};
|
|
192
219
|
|
|
193
220
|
/**
|
|
194
|
-
* @
|
|
221
|
+
* @alpha
|
|
195
222
|
*/
|
|
196
223
|
export type GCNodeType = (typeof GCNodeType)[keyof typeof GCNodeType];
|
|
197
224
|
|
|
225
|
+
/**
|
|
226
|
+
* The type of a garbage collection message.
|
|
227
|
+
* @internal
|
|
228
|
+
*/
|
|
229
|
+
export const GarbageCollectionMessageType = {
|
|
230
|
+
/** Message sent directing GC to delete the given nodes */
|
|
231
|
+
Sweep: "Sweep",
|
|
232
|
+
} as const;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* @internal
|
|
236
|
+
*/
|
|
237
|
+
export type GarbageCollectionMessageType =
|
|
238
|
+
(typeof GarbageCollectionMessageType)[keyof typeof GarbageCollectionMessageType];
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* The garbage collection sweep message.
|
|
242
|
+
* @internal
|
|
243
|
+
*/
|
|
244
|
+
export interface ISweepMessage {
|
|
245
|
+
type: "Sweep";
|
|
246
|
+
// The ids of nodes that are deleted.
|
|
247
|
+
deletedNodeIds: string[];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Type for a message to be used for sending / received garbage collection messages.
|
|
252
|
+
* @internal
|
|
253
|
+
*/
|
|
254
|
+
export type GarbageCollectionMessage = ISweepMessage;
|
|
255
|
+
|
|
198
256
|
/**
|
|
199
257
|
* Defines the APIs for the runtime object to be passed to the garbage collector.
|
|
200
258
|
*/
|
|
@@ -204,17 +262,17 @@ export interface IGarbageCollectionRuntime {
|
|
|
204
262
|
/** Returns the garbage collection data of the runtime. */
|
|
205
263
|
getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;
|
|
206
264
|
/** After GC has run, called to notify the runtime of routes that are used in it. */
|
|
207
|
-
updateUsedRoutes(usedRoutes: string[]): void;
|
|
265
|
+
updateUsedRoutes(usedRoutes: readonly string[]): void;
|
|
208
266
|
/** After GC has run, called to notify the runtime of routes that are unused in it. */
|
|
209
|
-
updateUnusedRoutes(unusedRoutes: string[]): void;
|
|
267
|
+
updateUnusedRoutes(unusedRoutes: readonly string[]): void;
|
|
210
268
|
/**
|
|
211
269
|
* After GC has run and identified nodes that are sweep ready, called to delete the sweep ready nodes. The runtime
|
|
212
270
|
* should return the routes of nodes that were deleted.
|
|
213
271
|
* @param sweepReadyRoutes - The routes of nodes that are sweep ready and should be deleted.
|
|
214
272
|
*/
|
|
215
|
-
deleteSweepReadyNodes(sweepReadyRoutes: string[]): string[];
|
|
273
|
+
deleteSweepReadyNodes(sweepReadyRoutes: readonly string[]): readonly string[];
|
|
216
274
|
/** Called to notify the runtime of routes that are tombstones. */
|
|
217
|
-
updateTombstonedRoutes(tombstoneRoutes: string[]): void;
|
|
275
|
+
updateTombstonedRoutes(tombstoneRoutes: readonly string[]): void;
|
|
218
276
|
/** Returns a referenced timestamp to be used to track unreferenced nodes. */
|
|
219
277
|
getCurrentReferenceTimestampMs(): number | undefined;
|
|
220
278
|
/** Returns the type of the GC node. */
|
|
@@ -274,6 +332,8 @@ export interface IGarbageCollector {
|
|
|
274
332
|
): void;
|
|
275
333
|
/** Called when a reference is added to a node. Used to identify nodes that were referenced between summaries. */
|
|
276
334
|
addedOutboundReference(fromNodePath: string, toNodePath: string): void;
|
|
335
|
+
/** Called to process a garbage collection message. */
|
|
336
|
+
processMessage(message: ContainerRuntimeGCMessage, local: boolean): void;
|
|
277
337
|
/** Returns true if this node has been deleted by GC during sweep phase. */
|
|
278
338
|
isNodeDeleted(nodePath: string): boolean;
|
|
279
339
|
setConnectionState(connected: boolean, clientId?: string): void;
|
|
@@ -294,10 +354,11 @@ export interface IGarbageCollectorCreateParams {
|
|
|
294
354
|
readonly getLastSummaryTimestampMs: () => number | undefined;
|
|
295
355
|
readonly readAndParseBlob: ReadAndParseBlob;
|
|
296
356
|
readonly activeConnection: () => boolean;
|
|
357
|
+
readonly submitMessage: (message: ContainerRuntimeGCMessage) => void;
|
|
297
358
|
}
|
|
298
359
|
|
|
299
360
|
/**
|
|
300
|
-
* @
|
|
361
|
+
* @alpha
|
|
301
362
|
*/
|
|
302
363
|
export interface IGCRuntimeOptions {
|
|
303
364
|
/**
|
|
@@ -306,7 +367,7 @@ export interface IGCRuntimeOptions {
|
|
|
306
367
|
* GC has mark phase and sweep phase. In mark phase, unreferenced objects are identified
|
|
307
368
|
* and marked as such in the summary. This option enables the mark phase.
|
|
308
369
|
* In sweep phase, unreferenced objects are eventually deleted from the container if they meet certain conditions.
|
|
309
|
-
* Sweep phase can be enabled using the "
|
|
370
|
+
* Sweep phase can be enabled using the "enableGCSweep" option.
|
|
310
371
|
*
|
|
311
372
|
* Note: This setting is persisted in the container's summary and cannot be changed.
|
|
312
373
|
*/
|
|
@@ -318,6 +379,17 @@ export interface IGCRuntimeOptions {
|
|
|
318
379
|
*/
|
|
319
380
|
disableGC?: boolean;
|
|
320
381
|
|
|
382
|
+
/**
|
|
383
|
+
* Flag that if true, will enable the full Sweep Phase of garbage collection for this session,
|
|
384
|
+
* where Tombstoned objects are permanently deleted from the container.
|
|
385
|
+
*
|
|
386
|
+
* IMPORTANT: This only applies if this document is allowed to run Sweep Phase.
|
|
387
|
+
*
|
|
388
|
+
* Current default behavior is for Sweep Phase not to delete Tombstoned objects,
|
|
389
|
+
* but merely to prevent them from being loaded.
|
|
390
|
+
*/
|
|
391
|
+
enableGCSweep?: true;
|
|
392
|
+
|
|
321
393
|
/**
|
|
322
394
|
* Flag that will bypass optimizations and generate GC data for all nodes irrespective of whether a node
|
|
323
395
|
* changed or not.
|
|
@@ -331,6 +403,13 @@ export interface IGCRuntimeOptions {
|
|
|
331
403
|
*/
|
|
332
404
|
sessionExpiryTimeoutMs?: number;
|
|
333
405
|
|
|
406
|
+
/**
|
|
407
|
+
* Delay between when Tombstone should run and when the object should be deleted.
|
|
408
|
+
* This grace period gives a chance to intervene to recover if needed, before Sweep deletes the object.
|
|
409
|
+
* If not present, a default (non-zero) value will be used.
|
|
410
|
+
*/
|
|
411
|
+
sweepGracePeriodMs?: number;
|
|
412
|
+
|
|
334
413
|
/**
|
|
335
414
|
* Allows additional GC options to be passed.
|
|
336
415
|
*/
|
|
@@ -369,15 +448,21 @@ export interface IGarbageCollectorConfigs {
|
|
|
369
448
|
readonly sessionExpiryTimeoutMs: number | undefined;
|
|
370
449
|
/** The time after which an unreferenced node is ready to be swept. */
|
|
371
450
|
readonly sweepTimeoutMs: number | undefined;
|
|
451
|
+
/**
|
|
452
|
+
* The delay between tombstone and sweep. Not persisted, so concurrent sessions may use different values.
|
|
453
|
+
* Sweep is implemented in an eventually-consistent way so this is acceptable.
|
|
454
|
+
*/
|
|
455
|
+
readonly sweepGracePeriodMs: number;
|
|
372
456
|
/** The time after which an unreferenced node is inactive. */
|
|
373
457
|
readonly inactiveTimeoutMs: number;
|
|
374
458
|
/** Tracks whether GC should run in test mode. In this mode, unreferenced objects are deleted immediately. */
|
|
375
459
|
readonly testMode: boolean;
|
|
376
460
|
/**
|
|
377
|
-
* Tracks whether GC should run in tombstone mode. In this mode,
|
|
461
|
+
* Tracks whether GC should run in tombstone mode. In this mode, objects are marked as tombstones as a step along the
|
|
462
|
+
* way before they are fully deleted.
|
|
378
463
|
* In interactive (non-summarizer) clients, tombstone objects behave as if they are deleted, i.e., access to them
|
|
379
|
-
* is not allowed. However, these objects can be accessed after referencing them first. It is used as a
|
|
380
|
-
* step
|
|
464
|
+
* is not allowed. However, these objects can be accessed after referencing them first. It is used as a "warning"
|
|
465
|
+
* step before sweep, where objects wrongly marked as unreferenced can be recovered.
|
|
381
466
|
*/
|
|
382
467
|
readonly tombstoneMode: boolean;
|
|
383
468
|
/** @see GCFeatureMatrix. */
|
|
@@ -388,8 +473,6 @@ export interface IGarbageCollectorConfigs {
|
|
|
388
473
|
readonly gcVersionInEffect: GCVersion;
|
|
389
474
|
/** It is easier for users to diagnose InactiveObject usage if we throw on load, which this option enables */
|
|
390
475
|
readonly throwOnInactiveLoad: boolean | undefined;
|
|
391
|
-
/** If false, loading or using a Tombstoned object should merely log, not fail */
|
|
392
|
-
readonly tombstoneEnforcementAllowed: boolean;
|
|
393
476
|
/** If true, throw an error when a tombstone data store is retrieved */
|
|
394
477
|
readonly throwOnTombstoneLoad: boolean;
|
|
395
478
|
/** If true, throw an error when a tombstone data store is used. */
|
|
@@ -402,6 +485,8 @@ export const UnreferencedState = {
|
|
|
402
485
|
Active: "Active",
|
|
403
486
|
/** The node is inactive, i.e., it should not become referenced. */
|
|
404
487
|
Inactive: "Inactive",
|
|
488
|
+
/** The node is ready to be tombstoned */
|
|
489
|
+
TombstoneReady: "TombstoneReady",
|
|
405
490
|
/** The node is ready to be deleted by the sweep phase. */
|
|
406
491
|
SweepReady: "SweepReady",
|
|
407
492
|
} as const;
|
package/src/gc/gcHelpers.ts
CHANGED
|
@@ -28,64 +28,34 @@ export function getGCVersion(metadata?: IGCMetadata): GCVersion {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* Indicates whether
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* In order to protect old documents that were created at a time when known bugs exist that violate GC's invariants
|
|
35
|
-
* such that enforcing GC Tombstone (Failing on Tombstone load/usage) would cause legitimate data loss,
|
|
36
|
-
* the container author may increment the generation value for Tombstone such that containers created
|
|
37
|
-
* with a different value will not be subjected to GC enforcement.
|
|
38
|
-
*
|
|
39
|
-
* If no generation is provided at runtime, this defaults to return true to maintain expected default behavior
|
|
40
|
-
*
|
|
41
|
-
* @param persistedGeneration - The persisted tombstoneGeneration value
|
|
42
|
-
* @param currentGeneration - The current app-provided tombstoneGeneration value
|
|
43
|
-
* @returns true if GC Tombstone enforcement (Fail on Tombstone load/usage) should be allowed for this document
|
|
44
|
-
*/
|
|
45
|
-
export function shouldAllowGcTombstoneEnforcement(
|
|
46
|
-
persistedGeneration: number | undefined,
|
|
47
|
-
currentGeneration: number | undefined,
|
|
48
|
-
): boolean {
|
|
49
|
-
// If no Generation value is provided for this session, then we should default to letting Tombstone feature behave as intended.
|
|
50
|
-
if (currentGeneration === undefined) {
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
return persistedGeneration === currentGeneration;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Indicates whether Sweep is allowed for this document based on the GC Feature Matrix and current SweepGeneration
|
|
31
|
+
* Indicates whether Sweep is allowed for this document based on the persisted GC Feature Matrix and current gcGeneration.
|
|
32
|
+
* This applies to the entire Sweep Phase the same - both Tombstone Enforcement (i.e. should loading a Tombstone fail?) and Deletion.
|
|
58
33
|
*
|
|
59
34
|
* In order to protect old documents that were created at a time when known bugs exist that violate GC's invariants
|
|
60
35
|
* such that enforcing GC Sweep would cause legitimate data loss, the container author may increment the generation value for Sweep
|
|
61
36
|
* such that containers created with a different value will not be subjected to GC Sweep.
|
|
62
37
|
*
|
|
63
|
-
* If no generation is provided, Sweep will be
|
|
64
|
-
*
|
|
38
|
+
* If no generation is provided, Sweep will be enabled for all documents.
|
|
39
|
+
*
|
|
40
|
+
* For backwards compatibility, the current generation value is also compared against the persisted gcTombstoneGeneration if present.
|
|
65
41
|
*
|
|
66
|
-
* @param
|
|
67
|
-
* @param currentGeneration - The current app-provided
|
|
42
|
+
* @param featureMatrix - The GC Feature Matrix, containing the persisted generation value
|
|
43
|
+
* @param currentGeneration - The current app-provided gcGeneration value
|
|
68
44
|
* @returns true if GC Sweep should be allowed for this document
|
|
69
45
|
*/
|
|
70
46
|
export function shouldAllowGcSweep(
|
|
71
|
-
|
|
47
|
+
featureMatrix: GCFeatureMatrix,
|
|
72
48
|
currentGeneration: number | undefined,
|
|
73
49
|
): boolean {
|
|
74
|
-
// If no Generation value is provided for this session, default to
|
|
50
|
+
// If no Generation value is provided for this session, default to true
|
|
75
51
|
if (currentGeneration === undefined) {
|
|
76
|
-
return
|
|
52
|
+
return true;
|
|
77
53
|
}
|
|
78
54
|
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
if (currentGeneration === 0) {
|
|
82
|
-
return (
|
|
83
|
-
persistedGenerations.sweepGeneration === 0 ||
|
|
84
|
-
persistedGenerations.tombstoneGeneration === 0
|
|
85
|
-
);
|
|
86
|
-
}
|
|
55
|
+
// tombstoneGeneration is the predecessor and needs to be supported for back-compat reasons
|
|
56
|
+
const targetGeneration = featureMatrix.tombstoneGeneration ?? featureMatrix.gcGeneration;
|
|
87
57
|
|
|
88
|
-
return
|
|
58
|
+
return currentGeneration === targetGeneration;
|
|
89
59
|
}
|
|
90
60
|
|
|
91
61
|
/**
|
|
@@ -151,19 +121,12 @@ export function concatGarbageCollectionStates(
|
|
|
151
121
|
/**
|
|
152
122
|
* Helper function that clones the GC data.
|
|
153
123
|
* @param gcData - The GC data to clone.
|
|
154
|
-
* @param filter - Optional function to filter out node ids not to be included in the cloned GC data. Returns
|
|
155
|
-
* true to filter out nodes.
|
|
156
124
|
* @returns a clone of the given GC data.
|
|
157
125
|
*/
|
|
158
|
-
export function cloneGCData(
|
|
159
|
-
gcData: IGarbageCollectionData,
|
|
160
|
-
filter?: (id: string) => boolean,
|
|
161
|
-
): IGarbageCollectionData {
|
|
126
|
+
export function cloneGCData(gcData: IGarbageCollectionData): IGarbageCollectionData {
|
|
162
127
|
const clonedGCNodes: { [id: string]: string[] } = {};
|
|
163
128
|
for (const [id, outboundRoutes] of Object.entries(gcData.gcNodes)) {
|
|
164
|
-
|
|
165
|
-
clonedGCNodes[id] = Array.from(outboundRoutes);
|
|
166
|
-
}
|
|
129
|
+
clonedGCNodes[id] = Array.from(outboundRoutes);
|
|
167
130
|
}
|
|
168
131
|
return {
|
|
169
132
|
gcNodes: clonedGCNodes,
|
|
@@ -303,3 +266,19 @@ export function unpackChildNodesGCDetails(gcDetails: IGarbageCollectionDetailsBa
|
|
|
303
266
|
export function trimLeadingAndTrailingSlashes(str: string) {
|
|
304
267
|
return str.replace(/^\/+|\/+$/g, "");
|
|
305
268
|
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Utility to implement compat behaviors given an unknown message type
|
|
272
|
+
* The parameters are typed to support compile-time enforcement of handling all known types/behaviors
|
|
273
|
+
*
|
|
274
|
+
* @param _unknownGCMessageType - Typed as never to ensure all known types have been
|
|
275
|
+
* handled before calling this function (e.g. in a switch statement).
|
|
276
|
+
* @param compatBehavior - Typed redundantly with CompatModeBehavior to ensure handling is added when updating that type
|
|
277
|
+
*/
|
|
278
|
+
export function compatBehaviorAllowsGCMessageType(
|
|
279
|
+
_unknownGCMessageType: never,
|
|
280
|
+
compatBehavior: "Ignore" | "FailToProcess" | undefined,
|
|
281
|
+
): boolean {
|
|
282
|
+
// undefined defaults to same behavior as "FailToProcess"
|
|
283
|
+
return compatBehavior === "Ignore";
|
|
284
|
+
}
|