Skip to content

Commit

Permalink
[v2int/4.1] Set default GC version to 2 instead of 3 (#15317)
Browse files Browse the repository at this point in the history
  • Loading branch information
markfields authored Apr 27, 2023
1 parent 855d45a commit b66de6d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
4 changes: 1 addition & 3 deletions packages/runtime/container-runtime/src/gc/gcConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ export function generateGCConfigs(

// If version upgrade is not enabled, fall back to the stable GC version.
const gcVersionInEffect =
mc.config.getBoolean(gcVersionUpgradeToV3Key) === false
? stableGCVersion
: currentGCVersion;
mc.config.getBoolean(gcVersionUpgradeToV3Key) === true ? currentGCVersion : stableGCVersion;

return {
gcEnabled,
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/container-runtime/src/gc/gcDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
export type GCVersion = number;

/** The stable version of garbage collection in production. */
export const stableGCVersion: GCVersion = 1;
export const stableGCVersion: GCVersion = 2;
/** The current version of garbage collection. */
export const currentGCVersion: GCVersion = 3;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {
oneDayMs,
GCVersion,
disableSweepLogKey,
currentGCVersion,
stableGCVersion,
} from "../../gc";
import {
dataStoreAttributesBlobName,
Expand Down Expand Up @@ -147,7 +147,7 @@ describe("Garbage Collection Tests", () => {
metadata = {
...metadata,
...gcMetadata,
gcFeature: gcMetadata.gcFeature ?? currentGCVersion,
gcFeature: gcMetadata.gcFeature ?? stableGCVersion,
summaryFormatVersion: 1,
message: undefined,
};
Expand Down Expand Up @@ -787,7 +787,7 @@ describe("Garbage Collection Tests", () => {
const gcMetadata: IGCMetadata = {
gcFeature,
};
const { snapshotTree, gcBlobsMap } = getSnapshotWithGCVersion(currentGCVersion);
const { snapshotTree, gcBlobsMap } = getSnapshotWithGCVersion(gcFeature);
return createGarbageCollector(
{ baseSnapshot: snapshotTree },
gcBlobsMap,
Expand All @@ -796,7 +796,7 @@ describe("Garbage Collection Tests", () => {
}

it("reads all GC data from base snapshot when GC version does not change", async () => {
const garbageCollector = createGCOverride(currentGCVersion);
const garbageCollector = createGCOverride(stableGCVersion);

// GC state, tombstone state and deleted nodes should all be read from base snapshot.
const baseSnapshotData = await garbageCollector.baseSnapshotDataP;
Expand Down Expand Up @@ -833,7 +833,7 @@ describe("Garbage Collection Tests", () => {
});

it("discards GC state and tombstone state in base snapshot when GC version changes", async () => {
const garbageCollector = createGCOverride(currentGCVersion + 1);
const garbageCollector = createGCOverride(stableGCVersion + 1);

// GC state and tombstone state should be discarded but deleted nodes should be read from base snapshot.
const baseSnapshotData = await garbageCollector.baseSnapshotDataP;
Expand Down Expand Up @@ -870,11 +870,11 @@ describe("Garbage Collection Tests", () => {
});

it("reads all GC data from when refreshing from snapshot with same GC version", async () => {
const garbageCollector = createGCOverride(currentGCVersion);
const garbageCollector = createGCOverride(stableGCVersion);
await garbageCollector.initializeBaseState();

// Get a snapshot with the current GC version and refresh latest summary state from it.
const { snapshotTree, gcBlobsMap } = getSnapshotWithGCVersion(currentGCVersion);
const { snapshotTree, gcBlobsMap } = getSnapshotWithGCVersion(stableGCVersion);
const refreshSummaryResult: RefreshSummaryResult = {
latestSummaryUpdated: true,
wasSummaryTracked: false, // Indicates that state has to be updated from the snapshot in the result.
Expand Down Expand Up @@ -910,11 +910,11 @@ describe("Garbage Collection Tests", () => {
});

it("discards all GC data from when refreshing from snapshot with different GC version", async () => {
const garbageCollector = createGCOverride(currentGCVersion);
const garbageCollector = createGCOverride(stableGCVersion);
await garbageCollector.initializeBaseState();

// Get a snapshot with different GC version from current and refresh latest summary state from it.
const { snapshotTree, gcBlobsMap } = getSnapshotWithGCVersion(currentGCVersion + 1);
const { snapshotTree, gcBlobsMap } = getSnapshotWithGCVersion(stableGCVersion + 1);
const refreshSummaryResult: RefreshSummaryResult = {
latestSummaryUpdated: true,
wasSummaryTracked: false, // Indicates that state has to be updated from the snapshot in the result.
Expand Down
10 changes: 5 additions & 5 deletions packages/runtime/container-runtime/src/test/gc/gcConfigs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ describe("Garbage Collection configurations", () => {
const expectedOutputMetadata: IGCMetadata = {
...inputMetadata,
sweepEnabled: false, // Hardcoded, not used
gcFeature: currentGCVersion,
gcFeature: stableGCVersion,
};
assert.deepEqual(
outputMetadata,
Expand Down Expand Up @@ -314,7 +314,7 @@ describe("Garbage Collection configurations", () => {
assert(gc.configs.sweepTimeoutMs !== undefined, "sweepTimeoutMs incorrect");
assert.equal(
gc.summaryStateTracker.latestSummaryGCVersion,
currentGCVersion,
stableGCVersion,
"latestSummaryGCVersion incorrect",
);
});
Expand Down Expand Up @@ -407,7 +407,7 @@ describe("Garbage Collection configurations", () => {
it("Metadata Roundtrip", () => {
const expectedMetadata: IGCMetadata = {
sweepEnabled: false, // hardcoded, not used
gcFeature: currentGCVersion,
gcFeature: stableGCVersion,
sessionExpiryTimeoutMs: defaultSessionExpiryDurationMs,
sweepTimeoutMs: defaultSessionExpiryDurationMs + 6 * oneDayMs,
gcFeatureMatrix: { tombstoneGeneration: 2, sweepGeneration: 2 },
Expand Down Expand Up @@ -444,7 +444,7 @@ describe("Garbage Collection configurations", () => {
it("Metadata Roundtrip with only sweepGeneration", () => {
const expectedMetadata: IGCMetadata = {
sweepEnabled: false, // hardcoded, not used
gcFeature: currentGCVersion,
gcFeature: stableGCVersion,
sessionExpiryTimeoutMs: defaultSessionExpiryDurationMs,
sweepTimeoutMs: defaultSessionExpiryDurationMs + 6 * oneDayMs,
gcFeatureMatrix: { sweepGeneration: 2, tombstoneGeneration: undefined },
Expand Down Expand Up @@ -625,7 +625,7 @@ describe("Garbage Collection configurations", () => {

const expectedMetadata: IGCMetadata = {
sweepEnabled: false,
gcFeature: currentGCVersion,
gcFeature: stableGCVersion,
sessionExpiryTimeoutMs: defaultSessionExpiryDurationMs,
sweepTimeoutMs: expectedSweepTimeoutMs,
gcFeatureMatrix: undefined,
Expand Down
12 changes: 11 additions & 1 deletion packages/tools/replay-tool/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
IResolvedUrl,
} from "@fluidframework/driver-definitions";
import { IFileSnapshot } from "@fluidframework/replay-driver";
import { TelemetryLogger } from "@fluidframework/telemetry-utils";
import { ConfigTypes, IConfigProviderBase, TelemetryLogger } from "@fluidframework/telemetry-utils";
import { getNormalizedSnapshot, ISnapshotNormalizerConfig } from "@fluidframework/tool-utils";
import stringify from "json-stable-stringify";
import { FluidObject } from "@fluidframework/core-interfaces";
Expand Down Expand Up @@ -166,6 +166,15 @@ export async function loadContainer(
new ReplayRuntimeFactory(runtimeOptions, dataStoreRegistries),
);

// Add a config provider to the Loader to enable / disable features.
const settings: Record<string, ConfigTypes> = {};
const configProvider: IConfigProviderBase = {
getRawConfig: (name: string): ConfigTypes => settings[name],
};
// Enable GCVersionUpgradeToV3 feature. This is for the snapshot tests which are already using GC version 3
// but the default version was changed to 2. Once the default is 3, this will be removed.
settings["Fluid.GarbageCollection.GCVersionUpgradeToV3"] = true;

// Load the Fluid document while forcing summarizeProtocolTree option
const loader = new Loader({
urlResolver,
Expand All @@ -175,6 +184,7 @@ export async function loadContainer(
? { ...loaderOptions, summarizeProtocolTree: true }
: { summarizeProtocolTree: true },
logger,
configProvider,
});

return loader.resolve({ url: resolved.url });
Expand Down

0 comments on commit b66de6d

Please sign in to comment.