@fluidframework/container-runtime 2.0.0-internal.7.3.0 → 2.0.0-internal.8.0.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 +50 -0
- package/api-extractor-lint.json +13 -0
- package/api-extractor.json +9 -1
- package/api-report/container-runtime.api.md +123 -123
- package/dist/blobManager.d.ts +4 -4
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js.map +1 -1
- package/dist/container-runtime-alpha.d.ts +1444 -0
- package/dist/container-runtime-beta.d.ts +292 -0
- package/dist/container-runtime-public.d.ts +292 -0
- package/dist/container-runtime-untrimmed.d.ts +1792 -0
- package/dist/containerRuntime.d.ts +36 -66
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +68 -104
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStore.js +0 -12
- package/dist/dataStore.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 +15 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -6
- package/dist/index.js.map +1 -1
- package/dist/messageTypes.d.ts +15 -7
- package/dist/messageTypes.d.ts.map +1 -1
- package/dist/messageTypes.js +6 -1
- package/dist/messageTypes.js.map +1 -1
- package/dist/opLifecycle/definitions.d.ts +1 -1
- package/dist/opLifecycle/definitions.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 -0
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +1 -0
- package/dist/pendingStateManager.js.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 -13
- package/dist/summary/summarizer.d.ts.map +1 -1
- package/dist/summary/summarizer.js +1 -47
- 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/lib/blobManager.d.ts +4 -4
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js.map +1 -1
- package/lib/container-runtime-alpha.d.ts +1444 -0
- package/lib/container-runtime-beta.d.ts +292 -0
- package/lib/container-runtime-public.d.ts +292 -0
- package/lib/container-runtime-untrimmed.d.ts +1792 -0
- package/lib/containerRuntime.d.ts +36 -66
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +69 -104
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStore.js +0 -12
- package/lib/dataStore.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 +15 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +16 -2
- package/lib/index.js.map +1 -1
- package/lib/messageTypes.d.ts +15 -7
- package/lib/messageTypes.d.ts.map +1 -1
- package/lib/messageTypes.js +6 -1
- package/lib/messageTypes.js.map +1 -1
- package/lib/opLifecycle/definitions.d.ts +1 -1
- package/lib/opLifecycle/definitions.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 -0
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +1 -0
- package/lib/pendingStateManager.js.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 -13
- package/lib/summary/summarizer.d.ts.map +1 -1
- package/lib/summary/summarizer.js +1 -47
- 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 +46 -19
- package/src/blobManager.ts +5 -5
- package/src/containerRuntime.ts +93 -141
- package/src/dataStore.ts +1 -15
- 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 -2
- package/src/messageTypes.ts +19 -4
- package/src/opLifecycle/definitions.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +1 -0
- package/src/summary/orderedClientElection.ts +1 -1
- package/src/summary/runWhileConnectedCoordinator.ts +2 -2
- package/src/summary/summarizer.ts +2 -51
- 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
|
@@ -10,8 +10,9 @@ import { ReadAndParseBlob } from "@fluidframework/runtime-utils";
|
|
|
10
10
|
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
11
11
|
import { IContainerRuntimeMetadata, ICreateContainerMetadata, IRefreshSummaryResult } from "../summary";
|
|
12
12
|
import { RuntimeHeaderData } from "../containerRuntime";
|
|
13
|
+
import { ContainerRuntimeGCMessage } from "../messageTypes";
|
|
13
14
|
/**
|
|
14
|
-
* @
|
|
15
|
+
* @alpha
|
|
15
16
|
*/
|
|
16
17
|
export type GCVersion = number;
|
|
17
18
|
/** The stable/default version of GC Data */
|
|
@@ -19,25 +20,24 @@ export declare const stableGCVersion: GCVersion;
|
|
|
19
20
|
/** The next version of GC Data, to bump to in case we need to regenerate all GC Data across all files. */
|
|
20
21
|
export declare const nextGCVersion: GCVersion;
|
|
21
22
|
/**
|
|
22
|
-
* This undocumented GC Option (on ContainerRuntime Options) allows an app to disable
|
|
23
|
+
* This undocumented GC Option (on ContainerRuntime Options) allows an app to disable throwing an error when tombstone
|
|
24
|
+
* object is loaded (requested), merely logging a message instead.
|
|
23
25
|
*
|
|
24
|
-
*
|
|
25
|
-
* Otherwise, only enforce GC Tombstone if the passed in value matches the persisted value
|
|
26
|
+
* By default, attempting to load a Tombstoned object will result in an error.
|
|
26
27
|
*/
|
|
27
|
-
export declare const
|
|
28
|
+
export declare const gcDisableThrowOnTombstoneLoadOptionName = "gcDisableThrowOnTombstoneLoad";
|
|
28
29
|
/**
|
|
29
|
-
* This undocumented GC Option (on ContainerRuntime Options) allows
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
* This
|
|
30
|
+
* This undocumented GC Option (on ContainerRuntime Options) allows configuring which documents can have Sweep enabled.
|
|
31
|
+
* This provides a way to disable both Tombstone Enforcement and Sweep.
|
|
32
|
+
*
|
|
33
|
+
* If unset, Tombstone Enforcement + Sweep will operate as otherwise configured.
|
|
34
|
+
* Otherwise, the Sweep Phase will be disabled for documents where persisted value doesn't match what is passed into this session.
|
|
35
|
+
* This provides a way to disallow Sweep for old documents that may be too difficult for an app to repair,
|
|
36
|
+
* in case a bug is found that violates GC's assumptions.
|
|
35
37
|
*
|
|
36
|
-
*
|
|
37
|
-
* If 0 is passed in, Sweep will be enabled for any document with gcSweepGeneration OR gcTombstoneGeneration as 0.
|
|
38
|
-
* If any other number is passed in, Sweep will be enabled only for documents with the same value persisted.
|
|
38
|
+
* @see GCFeatureMatrix (gcGeneration)
|
|
39
39
|
*/
|
|
40
|
-
export declare const
|
|
40
|
+
export declare const gcGenerationOptionName = "gcGeneration";
|
|
41
41
|
/** Config key to turn GC on / off. */
|
|
42
42
|
export declare const runGCKey = "Fluid.GarbageCollection.RunGC";
|
|
43
43
|
/** Config key to turn GC sweep on / off. */
|
|
@@ -46,8 +46,6 @@ export declare const runSweepKey = "Fluid.GarbageCollection.RunSweep";
|
|
|
46
46
|
export declare const gcTestModeKey = "Fluid.GarbageCollection.GCTestMode";
|
|
47
47
|
/** Config key to expire a session after a set period of time. Defaults to true. */
|
|
48
48
|
export declare const runSessionExpiryKey = "Fluid.GarbageCollection.RunSessionExpiry";
|
|
49
|
-
/** Config key to turn GC sweep log off. */
|
|
50
|
-
export declare const disableSweepLogKey = "Fluid.GarbageCollection.DisableSweepLog";
|
|
51
49
|
/** Config key to disable the tombstone feature, i.e., tombstone information is not read / written into summary. */
|
|
52
50
|
export declare const disableTombstoneKey = "Fluid.GarbageCollection.DisableTombstone";
|
|
53
51
|
/** Config key to override throwing an error when tombstone object is loaded (requested). */
|
|
@@ -70,26 +68,29 @@ export declare const oneDayMs: number;
|
|
|
70
68
|
export declare const maxSnapshotCacheExpiryMs: number;
|
|
71
69
|
export declare const defaultInactiveTimeoutMs: number;
|
|
72
70
|
export declare const defaultSessionExpiryDurationMs: number;
|
|
71
|
+
export declare const defaultSweepGracePeriodMs: number;
|
|
73
72
|
/**
|
|
74
|
-
* @see IGCMetadata.gcFeatureMatrix
|
|
75
|
-
* @
|
|
73
|
+
* @see IGCMetadata.gcFeatureMatrix and @see gcGenerationOptionName
|
|
74
|
+
* @alpha
|
|
76
75
|
*/
|
|
77
|
-
export
|
|
76
|
+
export type GCFeatureMatrix = {
|
|
78
77
|
/**
|
|
79
|
-
* The
|
|
80
|
-
* Gives a way for an app to disqualify old files from GC
|
|
78
|
+
* The GC Generation value in effect when this file was created.
|
|
79
|
+
* Gives a way for an app to disqualify old files from GC Sweep.
|
|
81
80
|
* Provided via Container Runtime Options.
|
|
82
81
|
*/
|
|
83
|
-
|
|
82
|
+
gcGeneration?: number;
|
|
83
|
+
/** Deprecated property from legacy type. Will not be set concurrently with gcGeneration */
|
|
84
|
+
tombstoneGeneration?: undefined;
|
|
85
|
+
} | {
|
|
84
86
|
/**
|
|
85
|
-
* The
|
|
86
|
-
*
|
|
87
|
-
* Provided via Container Runtime Options.
|
|
87
|
+
* The Tombstone Generation value in effect when this file was created.
|
|
88
|
+
* Legacy - new containers would get gcGeneration instead (if anything)
|
|
88
89
|
*/
|
|
89
|
-
|
|
90
|
-
}
|
|
90
|
+
tombstoneGeneration: number;
|
|
91
|
+
};
|
|
91
92
|
/**
|
|
92
|
-
* @
|
|
93
|
+
* @alpha
|
|
93
94
|
*/
|
|
94
95
|
export interface IGCMetadata {
|
|
95
96
|
/**
|
|
@@ -117,7 +118,7 @@ export interface IGCMetadata {
|
|
|
117
118
|
* - True means sweep phase is enabled.
|
|
118
119
|
* - False means sweep phase is disabled. If GC is disabled as per gcFeature, sweep is also disabled.
|
|
119
120
|
*
|
|
120
|
-
* @deprecated use GCFeatureMatrix.
|
|
121
|
+
* @deprecated use GCFeatureMatrix.gcGeneration instead. @see GCFeatureMatrix.gcGeneration
|
|
121
122
|
*/
|
|
122
123
|
readonly sweepEnabled?: boolean;
|
|
123
124
|
/** If this is present, the session for this container will expire after this time and the container will close */
|
|
@@ -126,10 +127,10 @@ export interface IGCMetadata {
|
|
|
126
127
|
readonly sweepTimeoutMs?: number;
|
|
127
128
|
}
|
|
128
129
|
/**
|
|
129
|
-
* The statistics of the system state after a garbage collection run.
|
|
130
|
-
* @
|
|
130
|
+
* The statistics of the system state after a garbage collection mark phase run.
|
|
131
|
+
* @alpha
|
|
131
132
|
*/
|
|
132
|
-
export interface
|
|
133
|
+
export interface IMarkPhaseStats {
|
|
133
134
|
/** The number of nodes in the container. */
|
|
134
135
|
nodeCount: number;
|
|
135
136
|
/** The number of data stores in the container. */
|
|
@@ -149,9 +150,33 @@ export interface IGCStats {
|
|
|
149
150
|
/** The number of attachment blobs whose reference state updated since last GC run. */
|
|
150
151
|
updatedAttachmentBlobCount: number;
|
|
151
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* The statistics of the system state after a garbage collection sweep phase run.
|
|
155
|
+
* @alpha
|
|
156
|
+
*/
|
|
157
|
+
export interface ISweepPhaseStats {
|
|
158
|
+
/** The number of nodes in the lifetime of the container. */
|
|
159
|
+
lifetimeNodeCount: number;
|
|
160
|
+
/** The number of data stores in the lifetime of the container. */
|
|
161
|
+
lifetimeDataStoreCount: number;
|
|
162
|
+
/** The number of attachment blobs in the lifetime of the container. */
|
|
163
|
+
lifetimeAttachmentBlobCount: number;
|
|
164
|
+
/** The number of deleted nodes in the container. */
|
|
165
|
+
deletedNodeCount: number;
|
|
166
|
+
/** The number of deleted data stores in the container. */
|
|
167
|
+
deletedDataStoreCount: number;
|
|
168
|
+
/** The number of deleted attachment blobs in the container. */
|
|
169
|
+
deletedAttachmentBlobCount: number;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The statistics of the system state after a garbage collection run.
|
|
173
|
+
* @alpha
|
|
174
|
+
*/
|
|
175
|
+
export interface IGCStats extends IMarkPhaseStats, ISweepPhaseStats {
|
|
176
|
+
}
|
|
152
177
|
/**
|
|
153
178
|
* The types of GC nodes in the GC reference graph.
|
|
154
|
-
* @
|
|
179
|
+
* @alpha
|
|
155
180
|
*/
|
|
156
181
|
export declare const GCNodeType: {
|
|
157
182
|
DataStore: string;
|
|
@@ -160,9 +185,34 @@ export declare const GCNodeType: {
|
|
|
160
185
|
Other: string;
|
|
161
186
|
};
|
|
162
187
|
/**
|
|
163
|
-
* @
|
|
188
|
+
* @alpha
|
|
164
189
|
*/
|
|
165
190
|
export type GCNodeType = (typeof GCNodeType)[keyof typeof GCNodeType];
|
|
191
|
+
/**
|
|
192
|
+
* The type of a garbage collection message.
|
|
193
|
+
* @internal
|
|
194
|
+
*/
|
|
195
|
+
export declare const GarbageCollectionMessageType: {
|
|
196
|
+
/** Message sent directing GC to delete the given nodes */
|
|
197
|
+
readonly Sweep: "Sweep";
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* @internal
|
|
201
|
+
*/
|
|
202
|
+
export type GarbageCollectionMessageType = (typeof GarbageCollectionMessageType)[keyof typeof GarbageCollectionMessageType];
|
|
203
|
+
/**
|
|
204
|
+
* The garbage collection sweep message.
|
|
205
|
+
* @internal
|
|
206
|
+
*/
|
|
207
|
+
export interface ISweepMessage {
|
|
208
|
+
type: "Sweep";
|
|
209
|
+
deletedNodeIds: string[];
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Type for a message to be used for sending / received garbage collection messages.
|
|
213
|
+
* @internal
|
|
214
|
+
*/
|
|
215
|
+
export type GarbageCollectionMessage = ISweepMessage;
|
|
166
216
|
/**
|
|
167
217
|
* Defines the APIs for the runtime object to be passed to the garbage collector.
|
|
168
218
|
*/
|
|
@@ -172,17 +222,17 @@ export interface IGarbageCollectionRuntime {
|
|
|
172
222
|
/** Returns the garbage collection data of the runtime. */
|
|
173
223
|
getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;
|
|
174
224
|
/** After GC has run, called to notify the runtime of routes that are used in it. */
|
|
175
|
-
updateUsedRoutes(usedRoutes: string[]): void;
|
|
225
|
+
updateUsedRoutes(usedRoutes: readonly string[]): void;
|
|
176
226
|
/** After GC has run, called to notify the runtime of routes that are unused in it. */
|
|
177
|
-
updateUnusedRoutes(unusedRoutes: string[]): void;
|
|
227
|
+
updateUnusedRoutes(unusedRoutes: readonly string[]): void;
|
|
178
228
|
/**
|
|
179
229
|
* After GC has run and identified nodes that are sweep ready, called to delete the sweep ready nodes. The runtime
|
|
180
230
|
* should return the routes of nodes that were deleted.
|
|
181
231
|
* @param sweepReadyRoutes - The routes of nodes that are sweep ready and should be deleted.
|
|
182
232
|
*/
|
|
183
|
-
deleteSweepReadyNodes(sweepReadyRoutes: string[]): string[];
|
|
233
|
+
deleteSweepReadyNodes(sweepReadyRoutes: readonly string[]): readonly string[];
|
|
184
234
|
/** Called to notify the runtime of routes that are tombstones. */
|
|
185
|
-
updateTombstonedRoutes(tombstoneRoutes: string[]): void;
|
|
235
|
+
updateTombstonedRoutes(tombstoneRoutes: readonly string[]): void;
|
|
186
236
|
/** Returns a referenced timestamp to be used to track unreferenced nodes. */
|
|
187
237
|
getCurrentReferenceTimestampMs(): number | undefined;
|
|
188
238
|
/** Returns the type of the GC node. */
|
|
@@ -227,6 +277,8 @@ export interface IGarbageCollector {
|
|
|
227
277
|
nodeUpdated(nodePath: string, reason: "Loaded" | "Changed", timestampMs?: number, packagePath?: readonly string[], request?: IRequest, headerData?: RuntimeHeaderData): void;
|
|
228
278
|
/** Called when a reference is added to a node. Used to identify nodes that were referenced between summaries. */
|
|
229
279
|
addedOutboundReference(fromNodePath: string, toNodePath: string): void;
|
|
280
|
+
/** Called to process a garbage collection message. */
|
|
281
|
+
processMessage(message: ContainerRuntimeGCMessage, local: boolean): void;
|
|
230
282
|
/** Returns true if this node has been deleted by GC during sweep phase. */
|
|
231
283
|
isNodeDeleted(nodePath: string): boolean;
|
|
232
284
|
setConnectionState(connected: boolean, clientId?: string): void;
|
|
@@ -246,9 +298,10 @@ export interface IGarbageCollectorCreateParams {
|
|
|
246
298
|
readonly getLastSummaryTimestampMs: () => number | undefined;
|
|
247
299
|
readonly readAndParseBlob: ReadAndParseBlob;
|
|
248
300
|
readonly activeConnection: () => boolean;
|
|
301
|
+
readonly submitMessage: (message: ContainerRuntimeGCMessage) => void;
|
|
249
302
|
}
|
|
250
303
|
/**
|
|
251
|
-
* @
|
|
304
|
+
* @alpha
|
|
252
305
|
*/
|
|
253
306
|
export interface IGCRuntimeOptions {
|
|
254
307
|
/**
|
|
@@ -257,7 +310,7 @@ export interface IGCRuntimeOptions {
|
|
|
257
310
|
* GC has mark phase and sweep phase. In mark phase, unreferenced objects are identified
|
|
258
311
|
* and marked as such in the summary. This option enables the mark phase.
|
|
259
312
|
* In sweep phase, unreferenced objects are eventually deleted from the container if they meet certain conditions.
|
|
260
|
-
* Sweep phase can be enabled using the "
|
|
313
|
+
* Sweep phase can be enabled using the "enableGCSweep" option.
|
|
261
314
|
*
|
|
262
315
|
* Note: This setting is persisted in the container's summary and cannot be changed.
|
|
263
316
|
*/
|
|
@@ -267,6 +320,16 @@ export interface IGCRuntimeOptions {
|
|
|
267
320
|
* Can be used to disable running GC on containers where it is allowed via the gcAllowed option.
|
|
268
321
|
*/
|
|
269
322
|
disableGC?: boolean;
|
|
323
|
+
/**
|
|
324
|
+
* Flag that if true, will enable the full Sweep Phase of garbage collection for this session,
|
|
325
|
+
* where Tombstoned objects are permanently deleted from the container.
|
|
326
|
+
*
|
|
327
|
+
* IMPORTANT: This only applies if this document is allowed to run Sweep Phase.
|
|
328
|
+
*
|
|
329
|
+
* Current default behavior is for Sweep Phase not to delete Tombstoned objects,
|
|
330
|
+
* but merely to prevent them from being loaded.
|
|
331
|
+
*/
|
|
332
|
+
enableGCSweep?: true;
|
|
270
333
|
/**
|
|
271
334
|
* Flag that will bypass optimizations and generate GC data for all nodes irrespective of whether a node
|
|
272
335
|
* changed or not.
|
|
@@ -278,6 +341,12 @@ export interface IGCRuntimeOptions {
|
|
|
278
341
|
* Note: This setting is persisted in the container's summary and cannot be changed.
|
|
279
342
|
*/
|
|
280
343
|
sessionExpiryTimeoutMs?: number;
|
|
344
|
+
/**
|
|
345
|
+
* Delay between when Tombstone should run and when the object should be deleted.
|
|
346
|
+
* This grace period gives a chance to intervene to recover if needed, before Sweep deletes the object.
|
|
347
|
+
* If not present, a default (non-zero) value will be used.
|
|
348
|
+
*/
|
|
349
|
+
sweepGracePeriodMs?: number;
|
|
281
350
|
/**
|
|
282
351
|
* Allows additional GC options to be passed.
|
|
283
352
|
*/
|
|
@@ -315,15 +384,21 @@ export interface IGarbageCollectorConfigs {
|
|
|
315
384
|
readonly sessionExpiryTimeoutMs: number | undefined;
|
|
316
385
|
/** The time after which an unreferenced node is ready to be swept. */
|
|
317
386
|
readonly sweepTimeoutMs: number | undefined;
|
|
387
|
+
/**
|
|
388
|
+
* The delay between tombstone and sweep. Not persisted, so concurrent sessions may use different values.
|
|
389
|
+
* Sweep is implemented in an eventually-consistent way so this is acceptable.
|
|
390
|
+
*/
|
|
391
|
+
readonly sweepGracePeriodMs: number;
|
|
318
392
|
/** The time after which an unreferenced node is inactive. */
|
|
319
393
|
readonly inactiveTimeoutMs: number;
|
|
320
394
|
/** Tracks whether GC should run in test mode. In this mode, unreferenced objects are deleted immediately. */
|
|
321
395
|
readonly testMode: boolean;
|
|
322
396
|
/**
|
|
323
|
-
* Tracks whether GC should run in tombstone mode. In this mode,
|
|
397
|
+
* Tracks whether GC should run in tombstone mode. In this mode, objects are marked as tombstones as a step along the
|
|
398
|
+
* way before they are fully deleted.
|
|
324
399
|
* In interactive (non-summarizer) clients, tombstone objects behave as if they are deleted, i.e., access to them
|
|
325
|
-
* is not allowed. However, these objects can be accessed after referencing them first. It is used as a
|
|
326
|
-
* step
|
|
400
|
+
* is not allowed. However, these objects can be accessed after referencing them first. It is used as a "warning"
|
|
401
|
+
* step before sweep, where objects wrongly marked as unreferenced can be recovered.
|
|
327
402
|
*/
|
|
328
403
|
readonly tombstoneMode: boolean;
|
|
329
404
|
/** @see GCFeatureMatrix. */
|
|
@@ -334,8 +409,6 @@ export interface IGarbageCollectorConfigs {
|
|
|
334
409
|
readonly gcVersionInEffect: GCVersion;
|
|
335
410
|
/** It is easier for users to diagnose InactiveObject usage if we throw on load, which this option enables */
|
|
336
411
|
readonly throwOnInactiveLoad: boolean | undefined;
|
|
337
|
-
/** If false, loading or using a Tombstoned object should merely log, not fail */
|
|
338
|
-
readonly tombstoneEnforcementAllowed: boolean;
|
|
339
412
|
/** If true, throw an error when a tombstone data store is retrieved */
|
|
340
413
|
readonly throwOnTombstoneLoad: boolean;
|
|
341
414
|
/** If true, throw an error when a tombstone data store is used. */
|
|
@@ -347,6 +420,8 @@ export declare const UnreferencedState: {
|
|
|
347
420
|
readonly Active: "Active";
|
|
348
421
|
/** The node is inactive, i.e., it should not become referenced. */
|
|
349
422
|
readonly Inactive: "Inactive";
|
|
423
|
+
/** The node is ready to be tombstoned */
|
|
424
|
+
readonly TombstoneReady: "TombstoneReady";
|
|
350
425
|
/** The node is ready to be deleted by the sweep phase. */
|
|
351
426
|
readonly SweepReady: "SweepReady";
|
|
352
427
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gcDefinitions.d.ts","sourceRoot":"","sources":["../../src/gc/gcDefinitions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EACN,sBAAsB,EACtB,6BAA6B,EAC7B,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EACN,yBAAyB,EACzB,wBAAwB,EACxB,qBAAqB,EACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"gcDefinitions.d.ts","sourceRoot":"","sources":["../../src/gc/gcDefinitions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EACN,sBAAsB,EACtB,6BAA6B,EAC7B,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,E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esModule", { value: true });
|
|
7
|
-
exports.UnreferencedState = exports.GCNodeType = exports.defaultSessionExpiryDurationMs = exports.defaultInactiveTimeoutMs = exports.maxSnapshotCacheExpiryMs = exports.oneDayMs = exports.disableAttachmentBlobSweepKey = exports.disableDatastoreSweepKey = exports.gcVersionUpgradeToV4Key = exports.throwOnTombstoneUsageKey = exports.throwOnTombstoneLoadOverrideKey = exports.disableTombstoneKey = exports.
|
|
7
|
+
exports.UnreferencedState = exports.GarbageCollectionMessageType = exports.GCNodeType = exports.defaultSweepGracePeriodMs = exports.defaultSessionExpiryDurationMs = exports.defaultInactiveTimeoutMs = exports.maxSnapshotCacheExpiryMs = exports.oneDayMs = exports.disableAttachmentBlobSweepKey = exports.disableDatastoreSweepKey = exports.gcVersionUpgradeToV4Key = exports.throwOnTombstoneUsageKey = exports.throwOnTombstoneLoadOverrideKey = exports.disableTombstoneKey = exports.runSessionExpiryKey = exports.gcTestModeKey = exports.runSweepKey = exports.runGCKey = exports.gcGenerationOptionName = exports.gcDisableThrowOnTombstoneLoadOptionName = exports.nextGCVersion = exports.stableGCVersion = void 0;
|
|
8
8
|
/** The stable/default version of GC Data */
|
|
9
9
|
exports.stableGCVersion = 3;
|
|
10
10
|
/** The next version of GC Data, to bump to in case we need to regenerate all GC Data across all files. */
|
|
11
11
|
exports.nextGCVersion = 4;
|
|
12
12
|
/**
|
|
13
|
-
* This undocumented GC Option (on ContainerRuntime Options) allows an app to disable
|
|
13
|
+
* This undocumented GC Option (on ContainerRuntime Options) allows an app to disable throwing an error when tombstone
|
|
14
|
+
* object is loaded (requested), merely logging a message instead.
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
-
* Otherwise, only enforce GC Tombstone if the passed in value matches the persisted value
|
|
16
|
+
* By default, attempting to load a Tombstoned object will result in an error.
|
|
17
17
|
*/
|
|
18
|
-
exports.
|
|
18
|
+
exports.gcDisableThrowOnTombstoneLoadOptionName = "gcDisableThrowOnTombstoneLoad";
|
|
19
19
|
/**
|
|
20
|
-
* This undocumented GC Option (on ContainerRuntime Options) allows
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* This
|
|
20
|
+
* This undocumented GC Option (on ContainerRuntime Options) allows configuring which documents can have Sweep enabled.
|
|
21
|
+
* This provides a way to disable both Tombstone Enforcement and Sweep.
|
|
22
|
+
*
|
|
23
|
+
* If unset, Tombstone Enforcement + Sweep will operate as otherwise configured.
|
|
24
|
+
* Otherwise, the Sweep Phase will be disabled for documents where persisted value doesn't match what is passed into this session.
|
|
25
|
+
* This provides a way to disallow Sweep for old documents that may be too difficult for an app to repair,
|
|
26
|
+
* in case a bug is found that violates GC's assumptions.
|
|
26
27
|
*
|
|
27
|
-
*
|
|
28
|
-
* If 0 is passed in, Sweep will be enabled for any document with gcSweepGeneration OR gcTombstoneGeneration as 0.
|
|
29
|
-
* If any other number is passed in, Sweep will be enabled only for documents with the same value persisted.
|
|
28
|
+
* @see GCFeatureMatrix (gcGeneration)
|
|
30
29
|
*/
|
|
31
|
-
exports.
|
|
30
|
+
exports.gcGenerationOptionName = "gcGeneration";
|
|
32
31
|
/** Config key to turn GC on / off. */
|
|
33
32
|
exports.runGCKey = "Fluid.GarbageCollection.RunGC";
|
|
34
33
|
/** Config key to turn GC sweep on / off. */
|
|
@@ -37,8 +36,6 @@ exports.runSweepKey = "Fluid.GarbageCollection.RunSweep";
|
|
|
37
36
|
exports.gcTestModeKey = "Fluid.GarbageCollection.GCTestMode";
|
|
38
37
|
/** Config key to expire a session after a set period of time. Defaults to true. */
|
|
39
38
|
exports.runSessionExpiryKey = "Fluid.GarbageCollection.RunSessionExpiry";
|
|
40
|
-
/** Config key to turn GC sweep log off. */
|
|
41
|
-
exports.disableSweepLogKey = "Fluid.GarbageCollection.DisableSweepLog";
|
|
42
39
|
/** Config key to disable the tombstone feature, i.e., tombstone information is not read / written into summary. */
|
|
43
40
|
exports.disableTombstoneKey = "Fluid.GarbageCollection.DisableTombstone";
|
|
44
41
|
/** Config key to override throwing an error when tombstone object is loaded (requested). */
|
|
@@ -62,9 +59,10 @@ exports.oneDayMs = 1 * 24 * 60 * 60 * 1000;
|
|
|
62
59
|
exports.maxSnapshotCacheExpiryMs = 5 * exports.oneDayMs;
|
|
63
60
|
exports.defaultInactiveTimeoutMs = 7 * exports.oneDayMs; // 7 days
|
|
64
61
|
exports.defaultSessionExpiryDurationMs = 30 * exports.oneDayMs; // 30 days
|
|
62
|
+
exports.defaultSweepGracePeriodMs = 1 * exports.oneDayMs; // 1 day
|
|
65
63
|
/**
|
|
66
64
|
* The types of GC nodes in the GC reference graph.
|
|
67
|
-
* @
|
|
65
|
+
* @alpha
|
|
68
66
|
*/
|
|
69
67
|
exports.GCNodeType = {
|
|
70
68
|
// Nodes that are for data stores.
|
|
@@ -76,12 +74,22 @@ exports.GCNodeType = {
|
|
|
76
74
|
// Nodes that are neither of the above. For example, root node.
|
|
77
75
|
Other: "Other",
|
|
78
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* The type of a garbage collection message.
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
exports.GarbageCollectionMessageType = {
|
|
82
|
+
/** Message sent directing GC to delete the given nodes */
|
|
83
|
+
Sweep: "Sweep",
|
|
84
|
+
};
|
|
79
85
|
/** The state of node that is unreferenced. */
|
|
80
86
|
exports.UnreferencedState = {
|
|
81
87
|
/** The node is active, i.e., it can become referenced again. */
|
|
82
88
|
Active: "Active",
|
|
83
89
|
/** The node is inactive, i.e., it should not become referenced. */
|
|
84
90
|
Inactive: "Inactive",
|
|
91
|
+
/** The node is ready to be tombstoned */
|
|
92
|
+
TombstoneReady: "TombstoneReady",
|
|
85
93
|
/** The node is ready to be deleted by the sweep phase. */
|
|
86
94
|
SweepReady: "SweepReady",
|
|
87
95
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gcDefinitions.js","sourceRoot":"","sources":["../../src/gc/gcDefinitions.ts"],"names":[],"mappings":";AAAA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UAAU,GAAG;IACzB,kCAAkC;IAClC,SAAS,EAAE,WAAW;IACtB,8DAA8D;IAC9D,YAAY,EAAE,cAAc;IAC5B,6EAA6E;IAC7E,IAAI,EAAE,MAAM;IACZ,+DAA+D;IAC/D,KAAK,EAAE,OAAO;CACd,CAAC;AAgNF,8CAA8C;AACjC,QAAA,iBAAiB,GAAG;IAChC,gEAAgE;IAChE,MAAM,EAAE,QAAQ;IAChB,mEAAmE;IACnE,QAAQ,EAAE,UAAU;IACpB,0DAA0D;IAC1D,UAAU,EAAE,YAAY;CACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIGarbageCollectionData,\n\tIGarbageCollectionDetailsBase,\n\tISummarizeResult,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { ReadAndParseBlob } from \"@fluidframework/runtime-utils\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIContainerRuntimeMetadata,\n\tICreateContainerMetadata,\n\tIRefreshSummaryResult,\n} from \"../summary\";\nimport { RuntimeHeaderData } from \"../containerRuntime\";\n\n/**\n * @public\n */\nexport type GCVersion = number;\n\n/** The stable/default version of GC Data */\nexport const stableGCVersion: GCVersion = 3;\n/** The next version of GC Data, to bump to in case we need to regenerate all GC Data across all files. */\nexport const nextGCVersion: GCVersion = 4;\n\n/**\n * This undocumented GC Option (on ContainerRuntime Options) allows an app to disable enforcing GC on old documents by incrementing this value\n *\n * If unset, GC Tombstone phase will operate as otherwise configured\n * Otherwise, only enforce GC Tombstone if the passed in value matches the persisted value\n */\nexport const gcTombstoneGenerationOptionName = \"gcTombstoneGeneration\";\n\n/**\n * This undocumented GC Option (on ContainerRuntime Options) allows an app to enable throwing an error when tombstone\n * object is loaded (requested).\n */\nexport const gcThrowOnTombstoneLoadOptionName = \"gcThrowOnTombstoneLoad\";\n\n/**\n * This GC Option (on ContainerRuntime Options) allows an app to disable GC Sweep on old documents by incrementing this value.\n *\n * If unset altogether, Sweep will be disabled.\n * If 0 is passed in, Sweep will be enabled for any document with gcSweepGeneration OR gcTombstoneGeneration as 0.\n * If any other number is passed in, Sweep will be enabled only for documents with the same value persisted.\n */\nexport const gcSweepGenerationOptionName = \"gcSweepGeneration\";\n\n/** Config key to turn GC on / off. */\nexport const runGCKey = \"Fluid.GarbageCollection.RunGC\";\n/** Config key to turn GC sweep on / off. */\nexport const runSweepKey = \"Fluid.GarbageCollection.RunSweep\";\n/** Config key to turn GC test mode on / off. */\nexport const gcTestModeKey = \"Fluid.GarbageCollection.GCTestMode\";\n/** Config key to expire a session after a set period of time. Defaults to true. */\nexport const runSessionExpiryKey = \"Fluid.GarbageCollection.RunSessionExpiry\";\n/** Config key to turn GC sweep log off. */\nexport const disableSweepLogKey = \"Fluid.GarbageCollection.DisableSweepLog\";\n/** Config key to disable the tombstone feature, i.e., tombstone information is not read / written into summary. */\nexport const disableTombstoneKey = \"Fluid.GarbageCollection.DisableTombstone\";\n/** Config key to override throwing an error when tombstone object is loaded (requested). */\nexport const throwOnTombstoneLoadOverrideKey =\n\t\"Fluid.GarbageCollection.ThrowOnTombstoneLoadOverride\";\n/** Config key to enable throwing an error when tombstone object is used (e.g. outgoing or incoming ops). */\nexport const throwOnTombstoneUsageKey = \"Fluid.GarbageCollection.ThrowOnTombstoneUsage\";\n/** Config key to enable GC version upgrade. */\nexport const gcVersionUpgradeToV4Key = \"Fluid.GarbageCollection.GCVersionUpgradeToV4\";\n/** Config key to disable GC sweep for datastores. */\nexport const disableDatastoreSweepKey = \"Fluid.GarbageCollection.DisableDataStoreSweep\";\n/** Config key to disable GC sweep for attachment blobs. */\nexport const disableAttachmentBlobSweepKey = \"Fluid.GarbageCollection.DisableAttachmentBlobSweep\";\n\n// One day in milliseconds.\nexport const oneDayMs = 1 * 24 * 60 * 60 * 1000;\n\n/**\n * The maximum snapshot cache expiry in the driver. This is used to calculate the sweep timeout.\n * Sweep timeout = session expiry timeout + snapshot cache expiry timeout + a buffer.\n * The snapshot cache expiry timeout cannot be known precisely but the upper bound is 5 days, i.e., any snapshot\n * in cache will be invalidated before 5 days.\n */\nexport const maxSnapshotCacheExpiryMs = 5 * oneDayMs;\n\nexport const defaultInactiveTimeoutMs = 7 * oneDayMs; // 7 days\nexport const defaultSessionExpiryDurationMs = 30 * oneDayMs; // 30 days\n\n/**\n * @see IGCMetadata.gcFeatureMatrix\n * @public\n */\nexport interface GCFeatureMatrix {\n\t/**\n\t * The Tombstone Generation value in effect when this file was created.\n\t * Gives a way for an app to disqualify old files from GC Tombstone enforcement.\n\t * Provided via Container Runtime Options.\n\t */\n\ttombstoneGeneration?: number;\n\t/**\n\t * The Sweep Generation value in effect when this file was created.\n\t * Gives a way for an app to disqualify old files from GC Sweep.\n\t * Provided via Container Runtime Options.\n\t */\n\tsweepGeneration?: number;\n}\n\n/**\n * @public\n */\nexport interface IGCMetadata {\n\t/**\n\t * The version of the GC code that was run to generate the GC data that is written in the summary.\n\t * If the persisted value doesn't match the current value in the code, saved GC data will be discarded and regenerated from scratch.\n\t * Also, used to determine whether GC is enabled for this container or not:\n\t * - A value of 0 or undefined means GC is disabled.\n\t * - A value greater than 0 means GC is enabled.\n\t */\n\treadonly gcFeature?: GCVersion;\n\n\t/**\n\t * A collection of different numerical \"Generations\" for different features,\n\t * used to determine feature availability over time.\n\t * This info may come from multiple sources (FF code, config service, app via Container Runtime Options),\n\t * and pertains to aspects of the document that may be fixed for its lifetime.\n\t *\n\t * For each dimension, if the persisted value doesn't match the currently provided value,\n\t * then this file does not support the corresponding feature as currently implemented.\n\t *\n\t * Guidance is that if no value is provided at runtime, it should result in the current default behavior.\n\t */\n\treadonly gcFeatureMatrix?: GCFeatureMatrix;\n\t/**\n\t * Tells whether the GC sweep phase is enabled for this container.\n\t * - True means sweep phase is enabled.\n\t * - False means sweep phase is disabled. If GC is disabled as per gcFeature, sweep is also disabled.\n\t *\n\t * @deprecated use GCFeatureMatrix.sweepGeneration instead. @see GCFeatureMatrix.sweepGeneration\n\t */\n\treadonly sweepEnabled?: boolean;\n\t/** If this is present, the session for this container will expire after this time and the container will close */\n\treadonly sessionExpiryTimeoutMs?: number;\n\t/** How long to wait after an object is unreferenced before deleting it via GC Sweep */\n\treadonly sweepTimeoutMs?: number;\n}\n\n/**\n * The statistics of the system state after a garbage collection run.\n * @public\n */\nexport interface IGCStats {\n\t/** The number of nodes in the container. */\n\tnodeCount: number;\n\t/** The number of data stores in the container. */\n\tdataStoreCount: number;\n\t/** The number of attachment blobs in the container. */\n\tattachmentBlobCount: number;\n\t/** The number of unreferenced nodes in the container. */\n\tunrefNodeCount: number;\n\t/** The number of unreferenced data stores in the container. */\n\tunrefDataStoreCount: number;\n\t/** The number of unreferenced attachment blobs in the container. */\n\tunrefAttachmentBlobCount: number;\n\t/** The number of nodes whose reference state updated since last GC run. */\n\tupdatedNodeCount: number;\n\t/** The number of data stores whose reference state updated since last GC run. */\n\tupdatedDataStoreCount: number;\n\t/** The number of attachment blobs whose reference state updated since last GC run. */\n\tupdatedAttachmentBlobCount: number;\n}\n\n/**\n * The types of GC nodes in the GC reference graph.\n * @public\n */\nexport const GCNodeType = {\n\t// Nodes that are for data stores.\n\tDataStore: \"DataStore\",\n\t// Nodes that are within a data store. For example, DDS nodes.\n\tSubDataStore: \"SubDataStore\",\n\t// Nodes that are for attachment blobs, i.e., blobs uploaded via BlobManager.\n\tBlob: \"Blob\",\n\t// Nodes that are neither of the above. For example, root node.\n\tOther: \"Other\",\n};\n\n/**\n * @public\n */\nexport type GCNodeType = (typeof GCNodeType)[keyof typeof GCNodeType];\n\n/**\n * Defines the APIs for the runtime object to be passed to the garbage collector.\n */\nexport interface IGarbageCollectionRuntime {\n\t/** Before GC runs, called to notify the runtime to update any pending GC state. */\n\tupdateStateBeforeGC(): Promise<void>;\n\t/** Returns the garbage collection data of the runtime. */\n\tgetGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;\n\t/** After GC has run, called to notify the runtime of routes that are used in it. */\n\tupdateUsedRoutes(usedRoutes: string[]): void;\n\t/** After GC has run, called to notify the runtime of routes that are unused in it. */\n\tupdateUnusedRoutes(unusedRoutes: string[]): void;\n\t/**\n\t * After GC has run and identified nodes that are sweep ready, called to delete the sweep ready nodes. The runtime\n\t * should return the routes of nodes that were deleted.\n\t * @param sweepReadyRoutes - The routes of nodes that are sweep ready and should be deleted.\n\t */\n\tdeleteSweepReadyNodes(sweepReadyRoutes: string[]): string[];\n\t/** Called to notify the runtime of routes that are tombstones. */\n\tupdateTombstonedRoutes(tombstoneRoutes: string[]): void;\n\t/** Returns a referenced timestamp to be used to track unreferenced nodes. */\n\tgetCurrentReferenceTimestampMs(): number | undefined;\n\t/** Returns the type of the GC node. */\n\tgetNodeType(nodePath: string): GCNodeType;\n\t/** Called when the runtime should close because of an error. */\n\tcloseFn: (error?: ICriticalContainerError) => void;\n}\n\n/** Defines the contract for the garbage collector. */\nexport interface IGarbageCollector {\n\t/** Tells whether GC should run or not. */\n\treadonly shouldRunGC: boolean;\n\t/** Tells whether the GC state in summary needs to be reset in the next summary. */\n\treadonly summaryStateNeedsReset: boolean;\n\t/** The count of data stores whose GC state updated since the last summary. */\n\treadonly updatedDSCountSinceLastSummary: number;\n\t/** Tells whether tombstone feature is enabled and enforced. */\n\treadonly tombstoneEnforcementAllowed: boolean;\n\t/** Tells whether loading a tombstone object should fail or merely log. */\n\treadonly throwOnTombstoneLoad: boolean;\n\t/** Tells whether using a tombstone object should fail or merely log. */\n\treadonly throwOnTombstoneUsage: boolean;\n\t/** Initialize the state from the base snapshot after its creation. */\n\tinitializeBaseState(): Promise<void>;\n\t/** Run garbage collection and update the reference / used state of the system. */\n\tcollectGarbage(\n\t\toptions: {\n\t\t\tlogger?: ITelemetryLoggerExt;\n\t\t\trunSweep?: boolean;\n\t\t\tfullGC?: boolean;\n\t\t},\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<IGCStats | undefined>;\n\t/** Summarizes the GC data and returns it as a summary tree. */\n\tsummarize(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummarizeResult | undefined;\n\t/** Returns the garbage collector specific metadata to be written into the summary. */\n\tgetMetadata(): IGCMetadata;\n\t/** Returns the GC details generated from the base snapshot. */\n\tgetBaseGCDetails(): Promise<IGarbageCollectionDetailsBase>;\n\t/** Called when the latest summary of the system has been refreshed. */\n\trefreshLatestSummary(result: IRefreshSummaryResult): Promise<void>;\n\t/**\n\t * Called when a node with the given path is updated. If the node is inactive or tombstoned, this will log an error\n\t * or throw an error if failing on incorrect usage is configured.\n\t */\n\tnodeUpdated(\n\t\tnodePath: string,\n\t\treason: \"Loaded\" | \"Changed\",\n\t\ttimestampMs?: number,\n\t\tpackagePath?: readonly string[],\n\t\trequest?: IRequest,\n\t\theaderData?: RuntimeHeaderData,\n\t): void;\n\t/** Called when a reference is added to a node. Used to identify nodes that were referenced between summaries. */\n\taddedOutboundReference(fromNodePath: string, toNodePath: string): void;\n\t/** Returns true if this node has been deleted by GC during sweep phase. */\n\tisNodeDeleted(nodePath: string): boolean;\n\tsetConnectionState(connected: boolean, clientId?: string): void;\n\tdispose(): void;\n}\n\n/** Parameters necessary for creating a GarbageCollector. */\nexport interface IGarbageCollectorCreateParams {\n\treadonly runtime: IGarbageCollectionRuntime;\n\treadonly gcOptions: IGCRuntimeOptions;\n\treadonly baseLogger: ITelemetryLoggerExt;\n\treadonly existing: boolean;\n\treadonly metadata: IContainerRuntimeMetadata | undefined;\n\treadonly createContainerMetadata: ICreateContainerMetadata;\n\treadonly baseSnapshot: ISnapshotTree | undefined;\n\treadonly isSummarizerClient: boolean;\n\treadonly getNodePackagePath: (nodePath: string) => Promise<readonly string[] | undefined>;\n\treadonly getLastSummaryTimestampMs: () => number | undefined;\n\treadonly readAndParseBlob: ReadAndParseBlob;\n\treadonly activeConnection: () => boolean;\n}\n\n/**\n * @public\n */\nexport interface IGCRuntimeOptions {\n\t/**\n\t * Flag that if true, will enable running garbage collection (GC) for a new container.\n\t *\n\t * GC has mark phase and sweep phase. In mark phase, unreferenced objects are identified\n\t * and marked as such in the summary. This option enables the mark phase.\n\t * In sweep phase, unreferenced objects are eventually deleted from the container if they meet certain conditions.\n\t * Sweep phase can be enabled using the \"gcSweepGeneration\" option.\n\t *\n\t * Note: This setting is persisted in the container's summary and cannot be changed.\n\t */\n\tgcAllowed?: boolean;\n\n\t/**\n\t * Flag that if true, will disable garbage collection for the session.\n\t * Can be used to disable running GC on containers where it is allowed via the gcAllowed option.\n\t */\n\tdisableGC?: boolean;\n\n\t/**\n\t * Flag that will bypass optimizations and generate GC data for all nodes irrespective of whether a node\n\t * changed or not.\n\t */\n\trunFullGC?: boolean;\n\n\t/**\n\t * Maximum session duration for a new container. If not present, a default value will be used.\n\t *\n\t * Note: This setting is persisted in the container's summary and cannot be changed.\n\t */\n\tsessionExpiryTimeoutMs?: number;\n\n\t/**\n\t * Allows additional GC options to be passed.\n\t */\n\t[key: string]: any;\n}\n\n/**\n * The configurations for Garbage Collector that determines what runs and how.\n */\nexport interface IGarbageCollectorConfigs {\n\t/**\n\t * Tracks if GC is enabled for this document. This is specified during document creation and doesn't change\n\t * throughout its lifetime.\n\t */\n\treadonly gcEnabled: boolean;\n\t/**\n\t * Tracks if sweep phase is enabled for this document. This is specified during document creation and doesn't change\n\t * throughout its lifetime.\n\t */\n\treadonly sweepEnabled: boolean;\n\t/**\n\t * Tracks if GC should run or not. Even if GC is enabled for a document (see gcEnabled), it can be explicitly\n\t * disabled via runtime options or feature flags.\n\t */\n\treadonly shouldRunGC: boolean;\n\t/**\n\t * Tracks if sweep phase should run or not. Even if the sweep phase is enabled for a document (see sweepEnabled), it\n\t * can be explicitly disabled via feature flags. It also won't run if session expiry is not enabled.\n\t */\n\treadonly shouldRunSweep: boolean;\n\t/**\n\t * If true, bypass optimizations and generate GC data for all nodes irrespective of whether a node changed or not.\n\t */\n\treadonly runFullGC: boolean | undefined;\n\t/** The time in ms to expire a session for a client for gc. */\n\treadonly sessionExpiryTimeoutMs: number | undefined;\n\t/** The time after which an unreferenced node is ready to be swept. */\n\treadonly sweepTimeoutMs: number | undefined;\n\t/** The time after which an unreferenced node is inactive. */\n\treadonly inactiveTimeoutMs: number;\n\t/** Tracks whether GC should run in test mode. In this mode, unreferenced objects are deleted immediately. */\n\treadonly testMode: boolean;\n\t/**\n\t * Tracks whether GC should run in tombstone mode. In this mode, sweep ready objects are marked as tombstones.\n\t * In interactive (non-summarizer) clients, tombstone objects behave as if they are deleted, i.e., access to them\n\t * is not allowed. However, these objects can be accessed after referencing them first. It is used as a staging\n\t * step for sweep where accidental sweep ready objects can be recovered.\n\t */\n\treadonly tombstoneMode: boolean;\n\t/** @see GCFeatureMatrix. */\n\treadonly persistedGcFeatureMatrix: GCFeatureMatrix | undefined;\n\t/** The version of GC in the base snapshot. */\n\treadonly gcVersionInBaseSnapshot: GCVersion | undefined;\n\t/** The current version of GC data in the running code */\n\treadonly gcVersionInEffect: GCVersion;\n\t/** It is easier for users to diagnose InactiveObject usage if we throw on load, which this option enables */\n\treadonly throwOnInactiveLoad: boolean | undefined;\n\t/** If false, loading or using a Tombstoned object should merely log, not fail */\n\treadonly tombstoneEnforcementAllowed: boolean;\n\t/** If true, throw an error when a tombstone data store is retrieved */\n\treadonly throwOnTombstoneLoad: boolean;\n\t/** If true, throw an error when a tombstone data store is used. */\n\treadonly throwOnTombstoneUsage: boolean;\n}\n\n/** The state of node that is unreferenced. */\nexport const UnreferencedState = {\n\t/** The node is active, i.e., it can become referenced again. */\n\tActive: \"Active\",\n\t/** The node is inactive, i.e., it should not become referenced. */\n\tInactive: \"Inactive\",\n\t/** The node is ready to be deleted by the sweep phase. */\n\tSweepReady: \"SweepReady\",\n} as const;\nexport type UnreferencedState = (typeof UnreferencedState)[keyof typeof UnreferencedState];\n\n/**\n * Represents the result of a GC run.\n */\nexport interface IGCResult {\n\t/** The ids of nodes that are referenced in the referenced graph */\n\treferencedNodeIds: string[];\n\t/** The ids of nodes that are not-referenced or deleted in the referenced graph */\n\tdeletedNodeIds: string[];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"gcDefinitions.js","sourceRoot":"","sources":["../../src/gc/gcDefinitions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA0BH,4CAA4C;AAC/B,QAAA,eAAe,GAAc,CAAC,CAAC;AAC5C,0GAA0G;AAC7F,QAAA,aAAa,GAAc,CAAC,CAAC;AAE1C;;;;;GAKG;AACU,QAAA,uCAAuC,GAAG,+BAA+B,CAAC;AAEvF;;;;;;;;;;GAUG;AACU,QAAA,sBAAsB,GAAG,cAAc,CAAC;AAErD,sCAAsC;AACzB,QAAA,QAAQ,GAAG,+BAA+B,CAAC;AACxD,4CAA4C;AAC/B,QAAA,WAAW,GAAG,kCAAkC,CAAC;AAC9D,gDAAgD;AACnC,QAAA,aAAa,GAAG,oCAAoC,CAAC;AAClE,mFAAmF;AACtE,QAAA,mBAAmB,GAAG,0CAA0C,CAAC;AAC9E,mHAAmH;AACtG,QAAA,mBAAmB,GAAG,0CAA0C,CAAC;AAC9E,4FAA4F;AAC/E,QAAA,+BAA+B,GAC3C,sDAAsD,CAAC;AACxD,4GAA4G;AAC/F,QAAA,wBAAwB,GAAG,+CAA+C,CAAC;AACxF,+CAA+C;AAClC,QAAA,uBAAuB,GAAG,8CAA8C,CAAC;AACtF,qDAAqD;AACxC,QAAA,wBAAwB,GAAG,+CAA+C,CAAC;AACxF,2DAA2D;AAC9C,QAAA,6BAA6B,GAAG,oDAAoD,CAAC;AAElG,2BAA2B;AACd,QAAA,QAAQ,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhD;;;;;GAKG;AACU,QAAA,wBAAwB,GAAG,CAAC,GAAG,gBAAQ,CAAC;AAExC,QAAA,wBAAwB,GAAG,CAAC,GAAG,gBAAQ,CAAC,CAAC,SAAS;AAClD,QAAA,8BAA8B,GAAG,EAAE,GAAG,gBAAQ,CAAC,CAAC,UAAU;AAC1D,QAAA,yBAAyB,GAAG,CAAC,GAAG,gBAAQ,CAAC,CAAC,QAAQ;AAkH/D;;;GAGG;AACU,QAAA,UAAU,GAAG;IACzB,kCAAkC;IAClC,SAAS,EAAE,WAAW;IACtB,8DAA8D;IAC9D,YAAY,EAAE,cAAc;IAC5B,6EAA6E;IAC7E,IAAI,EAAE,MAAM;IACZ,+DAA+D;IAC/D,KAAK,EAAE,OAAO;CACd,CAAC;AAOF;;;GAGG;AACU,QAAA,4BAA4B,GAAG;IAC3C,0DAA0D;IAC1D,KAAK,EAAE,OAAO;CACL,CAAC;AA0PX,8CAA8C;AACjC,QAAA,iBAAiB,GAAG;IAChC,gEAAgE;IAChE,MAAM,EAAE,QAAQ;IAChB,mEAAmE;IACnE,QAAQ,EAAE,UAAU;IACpB,yCAAyC;IACzC,cAAc,EAAE,gBAAgB;IAChC,0DAA0D;IAC1D,UAAU,EAAE,YAAY;CACf,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIGarbageCollectionData,\n\tIGarbageCollectionDetailsBase,\n\tISummarizeResult,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { ReadAndParseBlob } from \"@fluidframework/runtime-utils\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport {\n\tIContainerRuntimeMetadata,\n\tICreateContainerMetadata,\n\tIRefreshSummaryResult,\n} from \"../summary\";\nimport { RuntimeHeaderData } from \"../containerRuntime\";\nimport { ContainerRuntimeGCMessage } from \"../messageTypes\";\n\n/**\n * @alpha\n */\nexport type GCVersion = number;\n\n/** The stable/default version of GC Data */\nexport const stableGCVersion: GCVersion = 3;\n/** The next version of GC Data, to bump to in case we need to regenerate all GC Data across all files. */\nexport const nextGCVersion: GCVersion = 4;\n\n/**\n * This undocumented GC Option (on ContainerRuntime Options) allows an app to disable throwing an error when tombstone\n * object is loaded (requested), merely logging a message instead.\n *\n * By default, attempting to load a Tombstoned object will result in an error.\n */\nexport const gcDisableThrowOnTombstoneLoadOptionName = \"gcDisableThrowOnTombstoneLoad\";\n\n/**\n * This undocumented GC Option (on ContainerRuntime Options) allows configuring which documents can have Sweep enabled.\n * This provides a way to disable both Tombstone Enforcement and Sweep.\n *\n * If unset, Tombstone Enforcement + Sweep will operate as otherwise configured.\n * Otherwise, the Sweep Phase will be disabled for documents where persisted value doesn't match what is passed into this session.\n * This provides a way to disallow Sweep for old documents that may be too difficult for an app to repair,\n * in case a bug is found that violates GC's assumptions.\n *\n * @see GCFeatureMatrix (gcGeneration)\n */\nexport const gcGenerationOptionName = \"gcGeneration\";\n\n/** Config key to turn GC on / off. */\nexport const runGCKey = \"Fluid.GarbageCollection.RunGC\";\n/** Config key to turn GC sweep on / off. */\nexport const runSweepKey = \"Fluid.GarbageCollection.RunSweep\";\n/** Config key to turn GC test mode on / off. */\nexport const gcTestModeKey = \"Fluid.GarbageCollection.GCTestMode\";\n/** Config key to expire a session after a set period of time. Defaults to true. */\nexport const runSessionExpiryKey = \"Fluid.GarbageCollection.RunSessionExpiry\";\n/** Config key to disable the tombstone feature, i.e., tombstone information is not read / written into summary. */\nexport const disableTombstoneKey = \"Fluid.GarbageCollection.DisableTombstone\";\n/** Config key to override throwing an error when tombstone object is loaded (requested). */\nexport const throwOnTombstoneLoadOverrideKey =\n\t\"Fluid.GarbageCollection.ThrowOnTombstoneLoadOverride\";\n/** Config key to enable throwing an error when tombstone object is used (e.g. outgoing or incoming ops). */\nexport const throwOnTombstoneUsageKey = \"Fluid.GarbageCollection.ThrowOnTombstoneUsage\";\n/** Config key to enable GC version upgrade. */\nexport const gcVersionUpgradeToV4Key = \"Fluid.GarbageCollection.GCVersionUpgradeToV4\";\n/** Config key to disable GC sweep for datastores. */\nexport const disableDatastoreSweepKey = \"Fluid.GarbageCollection.DisableDataStoreSweep\";\n/** Config key to disable GC sweep for attachment blobs. */\nexport const disableAttachmentBlobSweepKey = \"Fluid.GarbageCollection.DisableAttachmentBlobSweep\";\n\n// One day in milliseconds.\nexport const oneDayMs = 1 * 24 * 60 * 60 * 1000;\n\n/**\n * The maximum snapshot cache expiry in the driver. This is used to calculate the sweep timeout.\n * Sweep timeout = session expiry timeout + snapshot cache expiry timeout + a buffer.\n * The snapshot cache expiry timeout cannot be known precisely but the upper bound is 5 days, i.e., any snapshot\n * in cache will be invalidated before 5 days.\n */\nexport const maxSnapshotCacheExpiryMs = 5 * oneDayMs;\n\nexport const defaultInactiveTimeoutMs = 7 * oneDayMs; // 7 days\nexport const defaultSessionExpiryDurationMs = 30 * oneDayMs; // 30 days\nexport const defaultSweepGracePeriodMs = 1 * oneDayMs; // 1 day\n\n/**\n * @see IGCMetadata.gcFeatureMatrix and @see gcGenerationOptionName\n * @alpha\n */\nexport type GCFeatureMatrix =\n\t| {\n\t\t\t/**\n\t\t\t * The GC Generation value in effect when this file was created.\n\t\t\t * Gives a way for an app to disqualify old files from GC Sweep.\n\t\t\t * Provided via Container Runtime Options.\n\t\t\t */\n\t\t\tgcGeneration?: number;\n\t\t\t/** Deprecated property from legacy type. Will not be set concurrently with gcGeneration */\n\t\t\ttombstoneGeneration?: undefined;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * The Tombstone Generation value in effect when this file was created.\n\t\t\t * Legacy - new containers would get gcGeneration instead (if anything)\n\t\t\t */\n\t\t\ttombstoneGeneration: number;\n\t };\n\n/**\n * @alpha\n */\nexport interface IGCMetadata {\n\t/**\n\t * The version of the GC code that was run to generate the GC data that is written in the summary.\n\t * If the persisted value doesn't match the current value in the code, saved GC data will be discarded and regenerated from scratch.\n\t * Also, used to determine whether GC is enabled for this container or not:\n\t * - A value of 0 or undefined means GC is disabled.\n\t * - A value greater than 0 means GC is enabled.\n\t */\n\treadonly gcFeature?: GCVersion;\n\n\t/**\n\t * A collection of different numerical \"Generations\" for different features,\n\t * used to determine feature availability over time.\n\t * This info may come from multiple sources (FF code, config service, app via Container Runtime Options),\n\t * and pertains to aspects of the document that may be fixed for its lifetime.\n\t *\n\t * For each dimension, if the persisted value doesn't match the currently provided value,\n\t * then this file does not support the corresponding feature as currently implemented.\n\t *\n\t * Guidance is that if no value is provided at runtime, it should result in the current default behavior.\n\t */\n\treadonly gcFeatureMatrix?: GCFeatureMatrix;\n\t/**\n\t * Tells whether the GC sweep phase is enabled for this container.\n\t * - True means sweep phase is enabled.\n\t * - False means sweep phase is disabled. If GC is disabled as per gcFeature, sweep is also disabled.\n\t *\n\t * @deprecated use GCFeatureMatrix.gcGeneration instead. @see GCFeatureMatrix.gcGeneration\n\t */\n\treadonly sweepEnabled?: boolean;\n\t/** If this is present, the session for this container will expire after this time and the container will close */\n\treadonly sessionExpiryTimeoutMs?: number;\n\t/** How long to wait after an object is unreferenced before deleting it via GC Sweep */\n\treadonly sweepTimeoutMs?: number;\n}\n\n/**\n * The statistics of the system state after a garbage collection mark phase run.\n * @alpha\n */\nexport interface IMarkPhaseStats {\n\t/** The number of nodes in the container. */\n\tnodeCount: number;\n\t/** The number of data stores in the container. */\n\tdataStoreCount: number;\n\t/** The number of attachment blobs in the container. */\n\tattachmentBlobCount: number;\n\t/** The number of unreferenced nodes in the container. */\n\tunrefNodeCount: number;\n\t/** The number of unreferenced data stores in the container. */\n\tunrefDataStoreCount: number;\n\t/** The number of unreferenced attachment blobs in the container. */\n\tunrefAttachmentBlobCount: number;\n\t/** The number of nodes whose reference state updated since last GC run. */\n\tupdatedNodeCount: number;\n\t/** The number of data stores whose reference state updated since last GC run. */\n\tupdatedDataStoreCount: number;\n\t/** The number of attachment blobs whose reference state updated since last GC run. */\n\tupdatedAttachmentBlobCount: number;\n}\n\n/**\n * The statistics of the system state after a garbage collection sweep phase run.\n * @alpha\n */\nexport interface ISweepPhaseStats {\n\t/** The number of nodes in the lifetime of the container. */\n\tlifetimeNodeCount: number;\n\t/** The number of data stores in the lifetime of the container. */\n\tlifetimeDataStoreCount: number;\n\t/** The number of attachment blobs in the lifetime of the container. */\n\tlifetimeAttachmentBlobCount: number;\n\t/** The number of deleted nodes in the container. */\n\tdeletedNodeCount: number;\n\t/** The number of deleted data stores in the container. */\n\tdeletedDataStoreCount: number;\n\t/** The number of deleted attachment blobs in the container. */\n\tdeletedAttachmentBlobCount: number;\n}\n\n/**\n * The statistics of the system state after a garbage collection run.\n * @alpha\n */\nexport interface IGCStats extends IMarkPhaseStats, ISweepPhaseStats {}\n\n/**\n * The types of GC nodes in the GC reference graph.\n * @alpha\n */\nexport const GCNodeType = {\n\t// Nodes that are for data stores.\n\tDataStore: \"DataStore\",\n\t// Nodes that are within a data store. For example, DDS nodes.\n\tSubDataStore: \"SubDataStore\",\n\t// Nodes that are for attachment blobs, i.e., blobs uploaded via BlobManager.\n\tBlob: \"Blob\",\n\t// Nodes that are neither of the above. For example, root node.\n\tOther: \"Other\",\n};\n\n/**\n * @alpha\n */\nexport type GCNodeType = (typeof GCNodeType)[keyof typeof GCNodeType];\n\n/**\n * The type of a garbage collection message.\n * @internal\n */\nexport const GarbageCollectionMessageType = {\n\t/** Message sent directing GC to delete the given nodes */\n\tSweep: \"Sweep\",\n} as const;\n\n/**\n * @internal\n */\nexport type GarbageCollectionMessageType =\n\t(typeof GarbageCollectionMessageType)[keyof typeof GarbageCollectionMessageType];\n\n/**\n * The garbage collection sweep message.\n * @internal\n */\nexport interface ISweepMessage {\n\ttype: \"Sweep\";\n\t// The ids of nodes that are deleted.\n\tdeletedNodeIds: string[];\n}\n\n/**\n * Type for a message to be used for sending / received garbage collection messages.\n * @internal\n */\nexport type GarbageCollectionMessage = ISweepMessage;\n\n/**\n * Defines the APIs for the runtime object to be passed to the garbage collector.\n */\nexport interface IGarbageCollectionRuntime {\n\t/** Before GC runs, called to notify the runtime to update any pending GC state. */\n\tupdateStateBeforeGC(): Promise<void>;\n\t/** Returns the garbage collection data of the runtime. */\n\tgetGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;\n\t/** After GC has run, called to notify the runtime of routes that are used in it. */\n\tupdateUsedRoutes(usedRoutes: readonly string[]): void;\n\t/** After GC has run, called to notify the runtime of routes that are unused in it. */\n\tupdateUnusedRoutes(unusedRoutes: readonly string[]): void;\n\t/**\n\t * After GC has run and identified nodes that are sweep ready, called to delete the sweep ready nodes. The runtime\n\t * should return the routes of nodes that were deleted.\n\t * @param sweepReadyRoutes - The routes of nodes that are sweep ready and should be deleted.\n\t */\n\tdeleteSweepReadyNodes(sweepReadyRoutes: readonly string[]): readonly string[];\n\t/** Called to notify the runtime of routes that are tombstones. */\n\tupdateTombstonedRoutes(tombstoneRoutes: readonly string[]): void;\n\t/** Returns a referenced timestamp to be used to track unreferenced nodes. */\n\tgetCurrentReferenceTimestampMs(): number | undefined;\n\t/** Returns the type of the GC node. */\n\tgetNodeType(nodePath: string): GCNodeType;\n\t/** Called when the runtime should close because of an error. */\n\tcloseFn: (error?: ICriticalContainerError) => void;\n}\n\n/** Defines the contract for the garbage collector. */\nexport interface IGarbageCollector {\n\t/** Tells whether GC should run or not. */\n\treadonly shouldRunGC: boolean;\n\t/** Tells whether the GC state in summary needs to be reset in the next summary. */\n\treadonly summaryStateNeedsReset: boolean;\n\t/** The count of data stores whose GC state updated since the last summary. */\n\treadonly updatedDSCountSinceLastSummary: number;\n\t/** Tells whether tombstone feature is enabled and enforced. */\n\treadonly tombstoneEnforcementAllowed: boolean;\n\t/** Tells whether loading a tombstone object should fail or merely log. */\n\treadonly throwOnTombstoneLoad: boolean;\n\t/** Tells whether using a tombstone object should fail or merely log. */\n\treadonly throwOnTombstoneUsage: boolean;\n\t/** Initialize the state from the base snapshot after its creation. */\n\tinitializeBaseState(): Promise<void>;\n\t/** Run garbage collection and update the reference / used state of the system. */\n\tcollectGarbage(\n\t\toptions: {\n\t\t\tlogger?: ITelemetryLoggerExt;\n\t\t\trunSweep?: boolean;\n\t\t\tfullGC?: boolean;\n\t\t},\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<IGCStats | undefined>;\n\t/** Summarizes the GC data and returns it as a summary tree. */\n\tsummarize(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummarizeResult | undefined;\n\t/** Returns the garbage collector specific metadata to be written into the summary. */\n\tgetMetadata(): IGCMetadata;\n\t/** Returns the GC details generated from the base snapshot. */\n\tgetBaseGCDetails(): Promise<IGarbageCollectionDetailsBase>;\n\t/** Called when the latest summary of the system has been refreshed. */\n\trefreshLatestSummary(result: IRefreshSummaryResult): Promise<void>;\n\t/**\n\t * Called when a node with the given path is updated. If the node is inactive or tombstoned, this will log an error\n\t * or throw an error if failing on incorrect usage is configured.\n\t */\n\tnodeUpdated(\n\t\tnodePath: string,\n\t\treason: \"Loaded\" | \"Changed\",\n\t\ttimestampMs?: number,\n\t\tpackagePath?: readonly string[],\n\t\trequest?: IRequest,\n\t\theaderData?: RuntimeHeaderData,\n\t): void;\n\t/** Called when a reference is added to a node. Used to identify nodes that were referenced between summaries. */\n\taddedOutboundReference(fromNodePath: string, toNodePath: string): void;\n\t/** Called to process a garbage collection message. */\n\tprocessMessage(message: ContainerRuntimeGCMessage, local: boolean): void;\n\t/** Returns true if this node has been deleted by GC during sweep phase. */\n\tisNodeDeleted(nodePath: string): boolean;\n\tsetConnectionState(connected: boolean, clientId?: string): void;\n\tdispose(): void;\n}\n\n/** Parameters necessary for creating a GarbageCollector. */\nexport interface IGarbageCollectorCreateParams {\n\treadonly runtime: IGarbageCollectionRuntime;\n\treadonly gcOptions: IGCRuntimeOptions;\n\treadonly baseLogger: ITelemetryLoggerExt;\n\treadonly existing: boolean;\n\treadonly metadata: IContainerRuntimeMetadata | undefined;\n\treadonly createContainerMetadata: ICreateContainerMetadata;\n\treadonly baseSnapshot: ISnapshotTree | undefined;\n\treadonly isSummarizerClient: boolean;\n\treadonly getNodePackagePath: (nodePath: string) => Promise<readonly string[] | undefined>;\n\treadonly getLastSummaryTimestampMs: () => number | undefined;\n\treadonly readAndParseBlob: ReadAndParseBlob;\n\treadonly activeConnection: () => boolean;\n\treadonly submitMessage: (message: ContainerRuntimeGCMessage) => void;\n}\n\n/**\n * @alpha\n */\nexport interface IGCRuntimeOptions {\n\t/**\n\t * Flag that if true, will enable running garbage collection (GC) for a new container.\n\t *\n\t * GC has mark phase and sweep phase. In mark phase, unreferenced objects are identified\n\t * and marked as such in the summary. This option enables the mark phase.\n\t * In sweep phase, unreferenced objects are eventually deleted from the container if they meet certain conditions.\n\t * Sweep phase can be enabled using the \"enableGCSweep\" option.\n\t *\n\t * Note: This setting is persisted in the container's summary and cannot be changed.\n\t */\n\tgcAllowed?: boolean;\n\n\t/**\n\t * Flag that if true, will disable garbage collection for the session.\n\t * Can be used to disable running GC on containers where it is allowed via the gcAllowed option.\n\t */\n\tdisableGC?: boolean;\n\n\t/**\n\t * Flag that if true, will enable the full Sweep Phase of garbage collection for this session,\n\t * where Tombstoned objects are permanently deleted from the container.\n\t *\n\t * IMPORTANT: This only applies if this document is allowed to run Sweep Phase.\n\t *\n\t * Current default behavior is for Sweep Phase not to delete Tombstoned objects,\n\t * but merely to prevent them from being loaded.\n\t */\n\tenableGCSweep?: true;\n\n\t/**\n\t * Flag that will bypass optimizations and generate GC data for all nodes irrespective of whether a node\n\t * changed or not.\n\t */\n\trunFullGC?: boolean;\n\n\t/**\n\t * Maximum session duration for a new container. If not present, a default value will be used.\n\t *\n\t * Note: This setting is persisted in the container's summary and cannot be changed.\n\t */\n\tsessionExpiryTimeoutMs?: number;\n\n\t/**\n\t * Delay between when Tombstone should run and when the object should be deleted.\n\t * This grace period gives a chance to intervene to recover if needed, before Sweep deletes the object.\n\t * If not present, a default (non-zero) value will be used.\n\t */\n\tsweepGracePeriodMs?: number;\n\n\t/**\n\t * Allows additional GC options to be passed.\n\t */\n\t[key: string]: any;\n}\n\n/**\n * The configurations for Garbage Collector that determines what runs and how.\n */\nexport interface IGarbageCollectorConfigs {\n\t/**\n\t * Tracks if GC is enabled for this document. This is specified during document creation and doesn't change\n\t * throughout its lifetime.\n\t */\n\treadonly gcEnabled: boolean;\n\t/**\n\t * Tracks if sweep phase is enabled for this document. This is specified during document creation and doesn't change\n\t * throughout its lifetime.\n\t */\n\treadonly sweepEnabled: boolean;\n\t/**\n\t * Tracks if GC should run or not. Even if GC is enabled for a document (see gcEnabled), it can be explicitly\n\t * disabled via runtime options or feature flags.\n\t */\n\treadonly shouldRunGC: boolean;\n\t/**\n\t * Tracks if sweep phase should run or not. Even if the sweep phase is enabled for a document (see sweepEnabled), it\n\t * can be explicitly disabled via feature flags. It also won't run if session expiry is not enabled.\n\t */\n\treadonly shouldRunSweep: boolean;\n\t/**\n\t * If true, bypass optimizations and generate GC data for all nodes irrespective of whether a node changed or not.\n\t */\n\treadonly runFullGC: boolean | undefined;\n\t/** The time in ms to expire a session for a client for gc. */\n\treadonly sessionExpiryTimeoutMs: number | undefined;\n\t/** The time after which an unreferenced node is ready to be swept. */\n\treadonly sweepTimeoutMs: number | undefined;\n\t/**\n\t * The delay between tombstone and sweep. Not persisted, so concurrent sessions may use different values.\n\t * Sweep is implemented in an eventually-consistent way so this is acceptable.\n\t */\n\treadonly sweepGracePeriodMs: number;\n\t/** The time after which an unreferenced node is inactive. */\n\treadonly inactiveTimeoutMs: number;\n\t/** Tracks whether GC should run in test mode. In this mode, unreferenced objects are deleted immediately. */\n\treadonly testMode: boolean;\n\t/**\n\t * Tracks whether GC should run in tombstone mode. In this mode, objects are marked as tombstones as a step along the\n\t * way before they are fully deleted.\n\t * In interactive (non-summarizer) clients, tombstone objects behave as if they are deleted, i.e., access to them\n\t * is not allowed. However, these objects can be accessed after referencing them first. It is used as a \"warning\"\n\t * step before sweep, where objects wrongly marked as unreferenced can be recovered.\n\t */\n\treadonly tombstoneMode: boolean;\n\t/** @see GCFeatureMatrix. */\n\treadonly persistedGcFeatureMatrix: GCFeatureMatrix | undefined;\n\t/** The version of GC in the base snapshot. */\n\treadonly gcVersionInBaseSnapshot: GCVersion | undefined;\n\t/** The current version of GC data in the running code */\n\treadonly gcVersionInEffect: GCVersion;\n\t/** It is easier for users to diagnose InactiveObject usage if we throw on load, which this option enables */\n\treadonly throwOnInactiveLoad: boolean | undefined;\n\t/** If true, throw an error when a tombstone data store is retrieved */\n\treadonly throwOnTombstoneLoad: boolean;\n\t/** If true, throw an error when a tombstone data store is used. */\n\treadonly throwOnTombstoneUsage: boolean;\n}\n\n/** The state of node that is unreferenced. */\nexport const UnreferencedState = {\n\t/** The node is active, i.e., it can become referenced again. */\n\tActive: \"Active\",\n\t/** The node is inactive, i.e., it should not become referenced. */\n\tInactive: \"Inactive\",\n\t/** The node is ready to be tombstoned */\n\tTombstoneReady: \"TombstoneReady\",\n\t/** The node is ready to be deleted by the sweep phase. */\n\tSweepReady: \"SweepReady\",\n} as const;\nexport type UnreferencedState = (typeof UnreferencedState)[keyof typeof UnreferencedState];\n\n/**\n * Represents the result of a GC run.\n */\nexport interface IGCResult {\n\t/** The ids of nodes that are referenced in the referenced graph */\n\treferencedNodeIds: string[];\n\t/** The ids of nodes that are not-referenced or deleted in the referenced graph */\n\tdeletedNodeIds: string[];\n}\n"]}
|
package/dist/gc/gcHelpers.d.ts
CHANGED
|
@@ -8,36 +8,22 @@ import { GCFeatureMatrix, GCVersion, IGCMetadata } from "./gcDefinitions";
|
|
|
8
8
|
import { IGarbageCollectionSnapshotData, IGarbageCollectionState } from "./gcSummaryDefinitions";
|
|
9
9
|
export declare function getGCVersion(metadata?: IGCMetadata): GCVersion;
|
|
10
10
|
/**
|
|
11
|
-
* Indicates whether
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* In order to protect old documents that were created at a time when known bugs exist that violate GC's invariants
|
|
15
|
-
* such that enforcing GC Tombstone (Failing on Tombstone load/usage) would cause legitimate data loss,
|
|
16
|
-
* the container author may increment the generation value for Tombstone such that containers created
|
|
17
|
-
* with a different value will not be subjected to GC enforcement.
|
|
18
|
-
*
|
|
19
|
-
* If no generation is provided at runtime, this defaults to return true to maintain expected default behavior
|
|
20
|
-
*
|
|
21
|
-
* @param persistedGeneration - The persisted tombstoneGeneration value
|
|
22
|
-
* @param currentGeneration - The current app-provided tombstoneGeneration value
|
|
23
|
-
* @returns true if GC Tombstone enforcement (Fail on Tombstone load/usage) should be allowed for this document
|
|
24
|
-
*/
|
|
25
|
-
export declare function shouldAllowGcTombstoneEnforcement(persistedGeneration: number | undefined, currentGeneration: number | undefined): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Indicates whether Sweep is allowed for this document based on the GC Feature Matrix and current SweepGeneration
|
|
11
|
+
* Indicates whether Sweep is allowed for this document based on the persisted GC Feature Matrix and current gcGeneration.
|
|
12
|
+
* This applies to the entire Sweep Phase the same - both Tombstone Enforcement (i.e. should loading a Tombstone fail?) and Deletion.
|
|
28
13
|
*
|
|
29
14
|
* In order to protect old documents that were created at a time when known bugs exist that violate GC's invariants
|
|
30
15
|
* such that enforcing GC Sweep would cause legitimate data loss, the container author may increment the generation value for Sweep
|
|
31
16
|
* such that containers created with a different value will not be subjected to GC Sweep.
|
|
32
17
|
*
|
|
33
|
-
* If no generation is provided, Sweep will be
|
|
34
|
-
*
|
|
18
|
+
* If no generation is provided, Sweep will be enabled for all documents.
|
|
19
|
+
*
|
|
20
|
+
* For backwards compatibility, the current generation value is also compared against the persisted gcTombstoneGeneration if present.
|
|
35
21
|
*
|
|
36
|
-
* @param
|
|
37
|
-
* @param currentGeneration - The current app-provided
|
|
22
|
+
* @param featureMatrix - The GC Feature Matrix, containing the persisted generation value
|
|
23
|
+
* @param currentGeneration - The current app-provided gcGeneration value
|
|
38
24
|
* @returns true if GC Sweep should be allowed for this document
|
|
39
25
|
*/
|
|
40
|
-
export declare function shouldAllowGcSweep(
|
|
26
|
+
export declare function shouldAllowGcSweep(featureMatrix: GCFeatureMatrix, currentGeneration: number | undefined): boolean;
|
|
41
27
|
/**
|
|
42
28
|
* Sorts the given GC state as per the id of the GC nodes. It also sorts the outbound routes array of each node.
|
|
43
29
|
*/
|
|
@@ -49,11 +35,9 @@ export declare function concatGarbageCollectionStates(gcState1: IGarbageCollecti
|
|
|
49
35
|
/**
|
|
50
36
|
* Helper function that clones the GC data.
|
|
51
37
|
* @param gcData - The GC data to clone.
|
|
52
|
-
* @param filter - Optional function to filter out node ids not to be included in the cloned GC data. Returns
|
|
53
|
-
* true to filter out nodes.
|
|
54
38
|
* @returns a clone of the given GC data.
|
|
55
39
|
*/
|
|
56
|
-
export declare function cloneGCData(gcData: IGarbageCollectionData
|
|
40
|
+
export declare function cloneGCData(gcData: IGarbageCollectionData): IGarbageCollectionData;
|
|
57
41
|
/**
|
|
58
42
|
* Concatenates the given GC data and returns the concatenated GC data.
|
|
59
43
|
*/
|
|
@@ -75,4 +59,13 @@ export declare function unpackChildNodesGCDetails(gcDetails: IGarbageCollectionD
|
|
|
75
59
|
* @returns A new string without leading and trailing slashes.
|
|
76
60
|
*/
|
|
77
61
|
export declare function trimLeadingAndTrailingSlashes(str: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Utility to implement compat behaviors given an unknown message type
|
|
64
|
+
* The parameters are typed to support compile-time enforcement of handling all known types/behaviors
|
|
65
|
+
*
|
|
66
|
+
* @param _unknownGCMessageType - Typed as never to ensure all known types have been
|
|
67
|
+
* handled before calling this function (e.g. in a switch statement).
|
|
68
|
+
* @param compatBehavior - Typed redundantly with CompatModeBehavior to ensure handling is added when updating that type
|
|
69
|
+
*/
|
|
70
|
+
export declare function compatBehaviorAllowsGCMessageType(_unknownGCMessageType: never, compatBehavior: "Ignore" | "FailToProcess" | undefined): boolean;
|
|
78
71
|
//# sourceMappingURL=gcHelpers.d.ts.map
|