@fluidframework/container-runtime 2.60.0 → 2.61.0-355054

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.
Files changed (40) hide show
  1. package/.mocharc.cjs +1 -2
  2. package/container-runtime.test-files.tar +0 -0
  3. package/dist/blobManager/blobManager.d.ts +21 -15
  4. package/dist/blobManager/blobManager.d.ts.map +1 -1
  5. package/dist/blobManager/blobManager.js +105 -102
  6. package/dist/blobManager/blobManager.js.map +1 -1
  7. package/dist/blobManager/blobManagerSnapSum.d.ts +4 -4
  8. package/dist/blobManager/blobManagerSnapSum.d.ts.map +1 -1
  9. package/dist/blobManager/blobManagerSnapSum.js +30 -33
  10. package/dist/blobManager/blobManagerSnapSum.js.map +1 -1
  11. package/dist/containerRuntime.js +1 -1
  12. package/dist/containerRuntime.js.map +1 -1
  13. package/dist/legacy.d.ts +2 -1
  14. package/dist/packageVersion.d.ts +1 -1
  15. package/dist/packageVersion.d.ts.map +1 -1
  16. package/dist/packageVersion.js +1 -1
  17. package/dist/packageVersion.js.map +1 -1
  18. package/internal.d.ts +1 -1
  19. package/legacy.d.ts +1 -1
  20. package/lib/blobManager/blobManager.d.ts +21 -15
  21. package/lib/blobManager/blobManager.d.ts.map +1 -1
  22. package/lib/blobManager/blobManager.js +105 -102
  23. package/lib/blobManager/blobManager.js.map +1 -1
  24. package/lib/blobManager/blobManagerSnapSum.d.ts +4 -4
  25. package/lib/blobManager/blobManagerSnapSum.d.ts.map +1 -1
  26. package/lib/blobManager/blobManagerSnapSum.js +26 -29
  27. package/lib/blobManager/blobManagerSnapSum.js.map +1 -1
  28. package/lib/containerRuntime.js +1 -1
  29. package/lib/containerRuntime.js.map +1 -1
  30. package/lib/legacy.d.ts +2 -1
  31. package/lib/packageVersion.d.ts +1 -1
  32. package/lib/packageVersion.d.ts.map +1 -1
  33. package/lib/packageVersion.js +1 -1
  34. package/lib/packageVersion.js.map +1 -1
  35. package/lib/tsdoc-metadata.json +1 -1
  36. package/package.json +26 -26
  37. package/src/blobManager/blobManager.ts +118 -121
  38. package/src/blobManager/blobManagerSnapSum.ts +31 -53
  39. package/src/containerRuntime.ts +1 -1
  40. package/src/packageVersion.ts +1 -1
@@ -3,11 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import {
7
- AttachState,
8
- type IContainerContext,
9
- } from "@fluidframework/container-definitions/internal";
10
- import { assert } from "@fluidframework/core-utils/internal";
6
+ import type { IContainerContext } from "@fluidframework/container-definitions/internal";
11
7
  import { readAndParse } from "@fluidframework/driver-utils/internal";
12
8
  import type { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
13
9
  import { SummaryTreeBuilder } from "@fluidframework/runtime-utils/internal";
@@ -60,72 +56,54 @@ const loadV1 = async (
60
56
  export const toRedirectTable = (
61
57
  blobManagerLoadInfo: IBlobManagerLoadInfo,
62
58
  logger: ITelemetryLoggerExt,
63
- attachState: AttachState,
64
- ): Map<string, string | undefined> => {
59
+ ): Map<string, string> => {
65
60
  logger.sendTelemetryEvent({
66
61
  eventName: "AttachmentBlobsLoaded",
67
62
  count: blobManagerLoadInfo.ids?.length ?? 0,
68
63
  redirectTable: blobManagerLoadInfo.redirectTable?.length,
69
64
  });
70
- const redirectTable = new Map<string, string | undefined>(blobManagerLoadInfo.redirectTable);
71
- const detached = attachState !== AttachState.Attached;
72
- if (blobManagerLoadInfo.ids) {
73
- // If we are detached, we don't have storage IDs yet, so set to undefined
74
- // Otherwise, set identity (id -> id) entries.
75
- for (const entry of blobManagerLoadInfo.ids) {
76
- redirectTable.set(entry, detached ? undefined : entry);
65
+ const redirectTable = new Map<string, string>(blobManagerLoadInfo.redirectTable);
66
+ if (blobManagerLoadInfo.ids !== undefined) {
67
+ for (const storageId of blobManagerLoadInfo.ids) {
68
+ // Older versions of the runtime used the storage ID directly in the handle,
69
+ // rather than routing through the redirectTable. To support old handles that
70
+ // were created in this way but unify handling through the redirectTable, we
71
+ // add identity mappings to the redirect table at load. These identity entries
72
+ // will be excluded during summarization.
73
+ redirectTable.set(storageId, storageId);
77
74
  }
78
75
  }
79
76
  return redirectTable;
80
77
  };
81
78
 
82
79
  export const summarizeBlobManagerState = (
83
- redirectTable: Map<string, string | undefined>,
84
- attachState: AttachState,
85
- ): ISummaryTreeWithStats => summarizeV1(redirectTable, attachState);
80
+ redirectTable: Map<string, string>,
81
+ ): ISummaryTreeWithStats => summarizeV1(redirectTable);
86
82
 
87
- const summarizeV1 = (
88
- redirectTable: Map<string, string | undefined>,
89
- attachState: AttachState,
90
- ): ISummaryTreeWithStats => {
91
- const storageIds = getStorageIds(redirectTable, attachState);
92
-
93
- // if storageIds is empty, it means we are detached and have only local IDs, or that there are no blobs attached
94
- const blobIds = storageIds.size > 0 ? [...storageIds] : [...redirectTable.keys()];
83
+ const summarizeV1 = (redirectTable: Map<string, string>): ISummaryTreeWithStats => {
95
84
  const builder = new SummaryTreeBuilder();
96
- for (const blobId of blobIds) {
97
- builder.addAttachment(blobId);
85
+ const storageIds = getStorageIds(redirectTable);
86
+ for (const storageId of storageIds) {
87
+ // The Attachment is inspectable by storage, which lets it detect that the blob is referenced
88
+ // and therefore should not be GC'd.
89
+ builder.addAttachment(storageId);
98
90
  }
99
91
 
100
- // Any non-identity entries in the table need to be saved in the summary
101
- if (redirectTable.size > blobIds.length) {
102
- builder.addBlob(
103
- redirectTableBlobName,
104
- // filter out identity entries
105
- JSON.stringify(
106
- [...redirectTable.entries()].filter(([localId, storageId]) => localId !== storageId),
107
- ),
108
- );
92
+ // Exclude identity mappings from the redirectTable summary. Note that
93
+ // the storageIds of the identity mappings are still included in the Attachments
94
+ // above, so we expect these identity mappings will be recreated at load
95
+ // time in toRedirectTable even if there is no non-identity mapping in
96
+ // the redirectTable.
97
+ const nonIdentityRedirectTableEntries = [...redirectTable.entries()].filter(
98
+ ([localId, storageId]) => localId !== storageId,
99
+ );
100
+ if (nonIdentityRedirectTableEntries.length > 0) {
101
+ builder.addBlob(redirectTableBlobName, JSON.stringify(nonIdentityRedirectTableEntries));
109
102
  }
110
103
 
111
104
  return builder.getSummaryTree();
112
105
  };
113
106
 
114
- export const getStorageIds = (
115
- redirectTable: Map<string, string | undefined>,
116
- attachState: AttachState,
117
- ): Set<string> => {
118
- const ids = new Set<string | undefined>(redirectTable.values());
119
-
120
- // If we are detached, we will not have storage IDs, only undefined
121
- const undefinedValueInTable = ids.delete(undefined);
122
-
123
- // For a detached container, entries are inserted into the redirect table with an undefined storage ID.
124
- // For an attached container, entries are inserted w/storage ID after the BlobAttach op round-trips.
125
- assert(
126
- !undefinedValueInTable || (attachState === AttachState.Detached && ids.size === 0),
127
- 0x382 /* 'redirectTable' must contain only undefined while detached / defined values while attached */,
128
- );
129
-
130
- return ids as Set<string>;
107
+ export const getStorageIds = (redirectTable: Map<string, string>): Set<string> => {
108
+ return new Set<string>(redirectTable.values());
131
109
  };
@@ -3708,7 +3708,7 @@ export class ContainerRuntime
3708
3708
  telemetryContext?: ITelemetryContext,
3709
3709
  ): ISummaryTree {
3710
3710
  if (blobRedirectTable) {
3711
- this.blobManager.setRedirectTable(blobRedirectTable);
3711
+ this.blobManager.patchRedirectTable(blobRedirectTable);
3712
3712
  }
3713
3713
 
3714
3714
  // We can finalize any allocated IDs since we're the only client
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/container-runtime";
9
- export const pkgVersion = "2.60.0";
9
+ export const pkgVersion = "2.61.0-355054";