@fluidframework/container-runtime 2.4.0 → 2.5.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.
Files changed (95) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/api-report/container-runtime.legacy.alpha.api.md +3 -1
  3. package/container-runtime.test-files.tar +0 -0
  4. package/dist/blobManager/blobManager.d.ts +3 -3
  5. package/dist/blobManager/blobManager.d.ts.map +1 -1
  6. package/dist/blobManager/blobManager.js +1 -1
  7. package/dist/blobManager/blobManager.js.map +1 -1
  8. package/dist/channelCollection.d.ts +20 -5
  9. package/dist/channelCollection.d.ts.map +1 -1
  10. package/dist/channelCollection.js +183 -119
  11. package/dist/channelCollection.js.map +1 -1
  12. package/dist/containerRuntime.d.ts +12 -4
  13. package/dist/containerRuntime.d.ts.map +1 -1
  14. package/dist/containerRuntime.js +155 -66
  15. package/dist/containerRuntime.js.map +1 -1
  16. package/dist/dataStoreContext.d.ts +15 -3
  17. package/dist/dataStoreContext.d.ts.map +1 -1
  18. package/dist/dataStoreContext.js +48 -19
  19. package/dist/dataStoreContext.js.map +1 -1
  20. package/dist/gc/garbageCollection.d.ts +5 -6
  21. package/dist/gc/garbageCollection.d.ts.map +1 -1
  22. package/dist/gc/garbageCollection.js +23 -22
  23. package/dist/gc/garbageCollection.js.map +1 -1
  24. package/dist/gc/gcDefinitions.d.ts +2 -2
  25. package/dist/gc/gcDefinitions.d.ts.map +1 -1
  26. package/dist/gc/gcDefinitions.js.map +1 -1
  27. package/dist/opLifecycle/outbox.d.ts +3 -0
  28. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  29. package/dist/opLifecycle/outbox.js +9 -0
  30. package/dist/opLifecycle/outbox.js.map +1 -1
  31. package/dist/opLifecycle/remoteMessageProcessor.d.ts +1 -0
  32. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  33. package/dist/opLifecycle/remoteMessageProcessor.js +2 -0
  34. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  35. package/dist/opProperties.js +1 -1
  36. package/dist/opProperties.js.map +1 -1
  37. package/dist/packageVersion.d.ts +1 -1
  38. package/dist/packageVersion.js +1 -1
  39. package/dist/packageVersion.js.map +1 -1
  40. package/dist/summary/documentSchema.d.ts +11 -0
  41. package/dist/summary/documentSchema.d.ts.map +1 -1
  42. package/dist/summary/documentSchema.js +45 -30
  43. package/dist/summary/documentSchema.js.map +1 -1
  44. package/lib/blobManager/blobManager.d.ts +3 -3
  45. package/lib/blobManager/blobManager.d.ts.map +1 -1
  46. package/lib/blobManager/blobManager.js +1 -1
  47. package/lib/blobManager/blobManager.js.map +1 -1
  48. package/lib/channelCollection.d.ts +20 -5
  49. package/lib/channelCollection.d.ts.map +1 -1
  50. package/lib/channelCollection.js +183 -119
  51. package/lib/channelCollection.js.map +1 -1
  52. package/lib/containerRuntime.d.ts +12 -4
  53. package/lib/containerRuntime.d.ts.map +1 -1
  54. package/lib/containerRuntime.js +155 -66
  55. package/lib/containerRuntime.js.map +1 -1
  56. package/lib/dataStoreContext.d.ts +15 -3
  57. package/lib/dataStoreContext.d.ts.map +1 -1
  58. package/lib/dataStoreContext.js +48 -19
  59. package/lib/dataStoreContext.js.map +1 -1
  60. package/lib/gc/garbageCollection.d.ts +5 -6
  61. package/lib/gc/garbageCollection.d.ts.map +1 -1
  62. package/lib/gc/garbageCollection.js +23 -22
  63. package/lib/gc/garbageCollection.js.map +1 -1
  64. package/lib/gc/gcDefinitions.d.ts +2 -2
  65. package/lib/gc/gcDefinitions.d.ts.map +1 -1
  66. package/lib/gc/gcDefinitions.js.map +1 -1
  67. package/lib/opLifecycle/outbox.d.ts +3 -0
  68. package/lib/opLifecycle/outbox.d.ts.map +1 -1
  69. package/lib/opLifecycle/outbox.js +9 -0
  70. package/lib/opLifecycle/outbox.js.map +1 -1
  71. package/lib/opLifecycle/remoteMessageProcessor.d.ts +1 -0
  72. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  73. package/lib/opLifecycle/remoteMessageProcessor.js +2 -0
  74. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  75. package/lib/opProperties.js +1 -1
  76. package/lib/opProperties.js.map +1 -1
  77. package/lib/packageVersion.d.ts +1 -1
  78. package/lib/packageVersion.js +1 -1
  79. package/lib/packageVersion.js.map +1 -1
  80. package/lib/summary/documentSchema.d.ts +11 -0
  81. package/lib/summary/documentSchema.d.ts.map +1 -1
  82. package/lib/summary/documentSchema.js +45 -30
  83. package/lib/summary/documentSchema.js.map +1 -1
  84. package/package.json +24 -24
  85. package/src/blobManager/blobManager.ts +2 -2
  86. package/src/channelCollection.ts +227 -160
  87. package/src/containerRuntime.ts +197 -80
  88. package/src/dataStoreContext.ts +66 -23
  89. package/src/gc/garbageCollection.ts +32 -32
  90. package/src/gc/gcDefinitions.ts +3 -3
  91. package/src/opLifecycle/outbox.ts +12 -0
  92. package/src/opLifecycle/remoteMessageProcessor.ts +3 -0
  93. package/src/opProperties.ts +1 -1
  94. package/src/packageVersion.ts +1 -1
  95. package/src/summary/documentSchema.ts +58 -39
@@ -1 +1 @@
1
- {"version":3,"file":"documentSchema.js","sourceRoot":"","sources":["../../src/summary/documentSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,uEAA+E;AAE/E,4DAAkD;AA4GlD;;;;;;;GAOG;AACU,QAAA,4BAA4B,GAAG,CAAC,CAAC;AAyB9C,MAAM,eAAe;IACb,GAAG,CAAC,gBAAuB,EAAE,gBAAuB;QAC1D,OAAO,gBAAgB,KAAK,IAAI,IAAI,gBAAgB,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAClF,CAAC;IAEM,EAAE,CAAC,gBAAuB,EAAE,gBAAuB;QACzD,OAAO,gBAAgB,KAAK,IAAI,IAAI,gBAAgB,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAClF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I,CAAC;IACb,CAAC;IAEM,YAAY;QAClB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACpB,CAAC;CACD;AAlOD,8DAkOC;AAED,2CAA2C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { DataProcessingError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { pkgVersion } from \"../packageVersion.js\";\n\n/**\n * Descripe allowed type for properties in document schema.\n * Please note that for all property types we should use undefined to indicate that particular capability is off.\n * Using false, or some string value (like \"off\") will result in clients who do not understand that property failing, whereas\n * we want them to continue to collaborate alongside clients who support that capability, but such capability is shipping dark for now.\n * @legacy\n * @alpha\n */\nexport type DocumentSchemaValueType = string | string[] | true | number | undefined;\n\n/**\n * ID Compressor mode.\n * \"on\" - compressor is On. It's loaded as part of container load. This mode is sticky - once on, compressor is On for all\n * sessions for a given document. This results in IContainerRuntime.idCompressor to be always available.\n * \"delayed\" - ID compressor bundle is loaded only on establishing of first delta connection, i.e. it does not impact boot of cotnainer.\n * In such mode IContainerRuntime.idCompressor is not made available (unless previous sessions of same document had it \"On\").\n * The only thing that is available is IContainerRuntime.generateDocumentUniqueId() that provides opportunistically short IDs.\n * undefined - ID compressor is not loaded.\n * While IContainerRuntime.generateDocumentUniqueId() is available, it will produce long IDs that are do not compress well.\n *\n * @legacy\n * @alpha\n */\nexport type IdCompressorMode = \"on\" | \"delayed\" | undefined;\n\n/**\n * Document schema information.\n * Describes overall shape of document schema, including unknown (to this version) properties.\n *\n * Used by runtime to make a call if it can understand document schema.\n * If it can't, it should not continue with document and immediately fail, preventing random (cryptic) failures\n * down the road and potentially corrupting documents.\n * For now this structure and appropriate interpretation / behavior is focused only on runtime features.\n * In the future that could be interpolated to more areas, including DDSs used, and even possibly - application\n * schema.\n *\n * Runtime will ignore any properties at the root that it does not understand (i.e. IDocumentSchema.app), but will\n * stop (and fail session) on any unknown properties within \"runtime\" sub-tree.\n *\n * In most cases values preserved in the document will not dictate if such features should be enabled in a given session.\n * I.e. if compression is mentioned in document schema, this means that runtime version that opens such document must know\n * how to interpret such ops, but does not need to actually use compression itself. That said, some options could be\n * sticky, i.e. influence feature selection for all runtimes opening a document. ID compression is one such example.\n * Currently there is no mechanism to remove feature from this property bag, i.e. once compression was used, even if it's\n * disabled (through feature gate or code deployment), all existing documents that used compression will continue to fail\n * if opened by clients who do not support compression.\n *\n * For now we are limiting it to just plain properties, and only really simple types, but that can be changed in the future.\n *\n * @legacy\n * @alpha\n */\nexport interface IDocumentSchema {\n\t// version that describes how data is stored in this structure.\n\t// If runtime sees a version it does not understand, it should immediately fail and not\n\t// attempt to interpret any further data.\n\tversion: number;\n\n\t// Sequence number when this schema became active.\n\trefSeq: number;\n\n\truntime: Record<string, DocumentSchemaValueType>;\n}\n\n/**\n * Content of the type=ContainerMessageType.DocumentSchemaChange ops.\n * The meaning of refSeq field is different in such messages (compared to other usages of IDocumentSchemaCurrent)\n * ContainerMessageType.DocumentSchemaChange messages use CAS (Compare-and-swap) semantics, and convey\n * regSeq of last known schema change (known to a client proposing schema change).\n * @see ContainerRuntimeDocumentSchemaMessage\n * @legacy\n * @alpha\n */\nexport type IDocumentSchemaChangeMessage = IDocumentSchema;\n\n/**\n * Settings that this session would like to have, based on options and feature gates.\n *\n * WARNING: This type is used to infer IDocumentSchemaCurrent type!\n * Any changes here (including renaming of properties) are potentially changing document format and should be considered carefully!\n *\n * @legacy\n * @alpha\n */\nexport interface IDocumentSchemaFeatures {\n\t// Tells if client uses legacy behavior of changing schema.\n\t// - Legacy behavior - changing schema without leveraging schema change ops.\n\t// - New behavior - changes in schema require ops and take into affect with delay.\n\texplicitSchemaControl: boolean;\n\tcompressionLz4: boolean;\n\tidCompressorMode: IdCompressorMode;\n\topGroupingEnabled: boolean;\n\n\t/**\n\t * List of disallowed versions of the runtime.\n\t * This option is sticky. Once a version of runtime is added to this list (when supplied to DocumentsSchemaController's constructor)\n\t * it will be added to the list of disallowed versions and stored in document metadata.\n\t * Each runtime checks if its version is in this list on container open. If it is, it immediately exits with error message\n\t * indicating to the user that this version is no longer supported.\n\t * Currently there is no mechanism to remove version from this list. I.e. If it was once added to the list,\n\t * it gets added to any document metadata (documents that gets open by this runtime) and there is no way to clear it from document's\n\t * metadata.\n\t */\n\tdisallowedVersions: string[];\n}\n\n/**\n * Current version known properties that define document schema\n * This must be bumped whenever the format of document schema or protocol for changing the current document schema changes.\n * Ex: adding a new configuration property (under IDocumentSchema.runtime) does not require changing this version.\n * Ex: Changing the 'document schema acceptance' mechanism from convert-and-swap to one requiring consensus does require changing this version.\n * @legacy\n * @alpha\n */\nexport const currentDocumentVersionSchema = 1;\n\n/**\n * Current document schema.\n * @legacy\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport type IDocumentSchemaCurrent = {\n\tversion: 1;\n\trefSeq: number;\n\n\truntime: {\n\t\t[P in keyof IDocumentSchemaFeatures]?: IDocumentSchemaFeatures[P] extends boolean\n\t\t\t? true\n\t\t\t: IDocumentSchemaFeatures[P];\n\t};\n};\n\ninterface IProperty<T = unknown> {\n\tand: (currentDocSchema: T, desiredDocSchema: T) => T;\n\tor: (currentDocSchema: T, desiredDocSchema: T) => T;\n\tvalidate(t: unknown): boolean;\n}\n\nclass TrueOrUndefined implements IProperty<true | undefined> {\n\tpublic and(currentDocSchema?: true, desiredDocSchema?: true) {\n\t\treturn currentDocSchema === true && desiredDocSchema === true ? true : undefined;\n\t}\n\n\tpublic or(currentDocSchema?: true, desiredDocSchema?: true) {\n\t\treturn currentDocSchema === true || desiredDocSchema === true ? true : undefined;\n\t}\n\n\tpublic validate(t: unknown) {\n\t\treturn t === undefined || t === true;\n\t}\n}\n\nclass TrueOrUndefinedMax extends TrueOrUndefined {\n\tpublic and(currentDocSchema?: true, desiredDocSchema?: true) {\n\t\treturn this.or(currentDocSchema, desiredDocSchema);\n\t}\n}\n\nclass MultiChoice implements IProperty<string | undefined> {\n\tconstructor(private readonly choices: string[]) {}\n\n\tpublic and(currentDocSchema?: string, desiredDocSchema?: string) {\n\t\tif (currentDocSchema === undefined || desiredDocSchema === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.choices[\n\t\t\tMath.min(this.choices.indexOf(currentDocSchema), this.choices.indexOf(desiredDocSchema))\n\t\t];\n\t}\n\n\tpublic or(currentDocSchema?: string, desiredDocSchema?: string) {\n\t\tif (currentDocSchema === undefined) {\n\t\t\treturn desiredDocSchema;\n\t\t}\n\t\tif (desiredDocSchema === undefined) {\n\t\t\treturn currentDocSchema;\n\t\t}\n\t\treturn this.choices[\n\t\t\tMath.max(this.choices.indexOf(currentDocSchema), this.choices.indexOf(desiredDocSchema))\n\t\t];\n\t}\n\n\tpublic validate(t: unknown) {\n\t\treturn t === undefined || (typeof t === \"string\" && this.choices.includes(t));\n\t}\n}\n\nclass IdCompressorProperty extends MultiChoice {\n\t// document schema always wins!\n\tpublic and(currentDocSchema?: string, desiredDocSchema?: string) {\n\t\treturn currentDocSchema;\n\t}\n}\n\nclass CheckVersions implements IProperty<string[] | undefined> {\n\tpublic or(currentDocSchema: string[] = [], desiredDocSchema: string[] = []) {\n\t\tconst set = new Set<string>([...currentDocSchema, ...desiredDocSchema]);\n\t\treturn arrayToProp([...set.values()]);\n\t}\n\n\t// Once version is there, it stays there forever.\n\tpublic and(currentDocSchema: string[] = [], desiredDocSchema: string[] = []) {\n\t\treturn this.or(currentDocSchema, desiredDocSchema);\n\t}\n\n\tpublic validate(t: unknown) {\n\t\treturn t === undefined || (Array.isArray(t) && !t.includes(pkgVersion));\n\t}\n}\n\n/**\n * Helper structure to valida if a schema is compatible with existing code.\n */\nconst documentSchemaSupportedConfigs = {\n\texplicitSchemaControl: new TrueOrUndefinedMax(), // once new behavior shows up, it's sticky\n\tidCompressorMode: new IdCompressorProperty([\"delayed\", \"on\"]),\n\topGroupingEnabled: new TrueOrUndefined(),\n\tcompressionLz4: new TrueOrUndefined(),\n\tdisallowedVersions: new CheckVersions(),\n};\n\n/**\n * Checks if a given schema is compatible with current code, i.e. if current code can understand all the features of that schema.\n * If schema is not compatible with current code, it throws an exception.\n * @param documentSchema - current schema\n */\nfunction checkRuntimeCompatibility(\n\tdocumentSchema: IDocumentSchema | undefined,\n\tschemaName: string,\n) {\n\t// Back-compat - we can't do anything about legacy documents.\n\t// There is no way to validate them, so we are taking a guess that safe deployment processes used by a given app\n\t// do not run into compat problems.\n\tif (documentSchema === undefined) {\n\t\treturn;\n\t}\n\n\tconst msg = \"Document can't be opened with current version of the code\";\n\tif (documentSchema.version !== currentDocumentVersionSchema) {\n\t\tthrow DataProcessingError.create(\n\t\t\tmsg,\n\t\t\t\"checkRuntimeCompat1\",\n\t\t\tundefined, // message\n\t\t\t{\n\t\t\t\truntimeSchemaVersion: documentSchema.version,\n\t\t\t\tcurrentRuntimeSchemaVersion: currentDocumentVersionSchema,\n\t\t\t\tschemaName,\n\t\t\t},\n\t\t);\n\t}\n\n\tlet unknownProperty: string | undefined;\n\n\tconst regSeq = documentSchema.refSeq;\n\t// defence in depth - it should not be possible to get here anything other than integer, but worth validating it.\n\tif (typeof regSeq !== \"number\" || regSeq < 0 || !Number.isInteger(regSeq)) {\n\t\tunknownProperty = \"refSeq\";\n\t} else if (documentSchema.runtime === null || typeof documentSchema.runtime !== \"object\") {\n\t\tunknownProperty = \"runtime\";\n\t} else {\n\t\tfor (const [name, value] of Object.entries(documentSchema.runtime)) {\n\t\t\tconst validator = documentSchemaSupportedConfigs[name] as IProperty | undefined;\n\t\t\tif (validator === undefined || !validator.validate(value)) {\n\t\t\t\tunknownProperty = `runtime/${name}`;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (unknownProperty !== undefined) {\n\t\tconst value = documentSchema[unknownProperty];\n\t\tthrow DataProcessingError.create(\n\t\t\tmsg,\n\t\t\t\"checkRuntimeCompat2\",\n\t\t\tundefined, // message\n\t\t\t{\n\t\t\t\tcodeVersion: currentDocumentVersionSchema,\n\t\t\t\tproperty: unknownProperty,\n\t\t\t\tvalue,\n\t\t\t\tschemaName,\n\t\t\t},\n\t\t);\n\t}\n}\n\nfunction and(\n\tcurrentDocSchema: IDocumentSchemaCurrent,\n\tdesiredDocSchema: IDocumentSchemaCurrent,\n): IDocumentSchemaCurrent {\n\tconst runtime = {};\n\tfor (const key of new Set([\n\t\t...Object.keys(currentDocSchema.runtime),\n\t\t...Object.keys(desiredDocSchema.runtime),\n\t])) {\n\t\truntime[key] = (documentSchemaSupportedConfigs[key] as IProperty).and(\n\t\t\tcurrentDocSchema.runtime[key],\n\t\t\tdesiredDocSchema.runtime[key],\n\t\t);\n\t}\n\treturn {\n\t\tversion: currentDocumentVersionSchema,\n\t\trefSeq: currentDocSchema.refSeq,\n\t\truntime,\n\t} as unknown as IDocumentSchemaCurrent;\n}\n\nfunction or(\n\tcurrentDocSchema: IDocumentSchemaCurrent,\n\tdesiredDocSchema: IDocumentSchemaCurrent,\n): IDocumentSchemaCurrent {\n\tconst runtime = {};\n\tfor (const key of new Set([\n\t\t...Object.keys(currentDocSchema.runtime),\n\t\t...Object.keys(desiredDocSchema.runtime),\n\t])) {\n\t\truntime[key] = (documentSchemaSupportedConfigs[key] as IProperty).or(\n\t\t\tcurrentDocSchema.runtime[key],\n\t\t\tdesiredDocSchema.runtime[key],\n\t\t);\n\t}\n\treturn {\n\t\tversion: currentDocumentVersionSchema,\n\t\trefSeq: currentDocSchema.refSeq,\n\t\truntime,\n\t} as unknown as IDocumentSchemaCurrent;\n}\n\nfunction same(\n\tcurrentDocSchema: IDocumentSchemaCurrent,\n\tdesiredDocSchema: IDocumentSchemaCurrent,\n): boolean {\n\tfor (const key of new Set([\n\t\t...Object.keys(currentDocSchema.runtime),\n\t\t...Object.keys(desiredDocSchema.runtime),\n\t])) {\n\t\t// If schemas differ only by type of behavior, then we should not send schema change ops!\n\t\tif (\n\t\t\tkey !== \"explicitSchemaControl\" &&\n\t\t\tcurrentDocSchema.runtime[key] !== desiredDocSchema.runtime[key]\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction boolToProp(b: boolean) {\n\treturn b ? true : undefined;\n}\n\nfunction arrayToProp(arr: string[]) {\n\treturn arr.length === 0 ? undefined : arr;\n}\n\n/* eslint-disable jsdoc/check-indentation */\n\n/**\n * Controller of document schema.\n *\n * Recommended pre-reading: https://github.com/microsoft/FluidFramework/blob/main/packages/dds/SchemaVersioning.md\n *\n * This class manages current document schema and transitions between document schemas.\n * At the moment, it only focuses on subset of document schema, specifically - how FluidFramework runtime serializes data\n * (summary and op format), features & capabilities that a version of runtime has to support and understand in\n * order to collaborate on a document.\n * New features that modify document format have to be included in document schema definition.\n * Usage of such features could only happen after document schema has been updated to reflect such feature.\n *\n * This formality allows clients that do not understand such features to fail right away when they observe\n * document schema listing capabilities that such client does not understand.\n * Old clients will fail in predictable way. This allows us to\n * 1) Immediately see such issues and adjust if features are enabled too early, before changes have been saturated.\n * 2) There is no way to get to 100% saturation with new code. Even if we have 99.99% saturation, there are\n * still 0.01% of clients who will fail. Failing early and predictably ensures they have no chance to limp along\n * and potentially corrupt the document. This is especially true for summarizer client, who could simply \"undo\"\n * changes it does not understands.\n *\n * It's important to note how it overlaps with feature gates and safe velocity.\n * If new feature was in use, that resulted in a number of documents referencing such feature in document schema.\n * But, developers (through code deployment or feature gates) could disable usage of such features.\n * That will stop a process of further document schema changes (for documents that were not using such feature).\n * And documents that already list such capability in their schema will continue to do so. Later ensures that old\n * clients who do not understand such feature will continue to fail to open such documents, as such documents very\n * likely contain data in a new format.\n *\n * Controller operates with 4 schemas:\n * - document schema: whatever we loaded from summary metadata + ops. It follows eventuall consistency rules (i.e. like DDS).\n * - desired schema - what client is asking for to have (i.e. all the desired settings, based on runtime options / feature gates).\n * - session schema - current session schema. It's \"and\" of the above two schemas.\n * - future schema - \"or\" of document and desires schemas.\n *\n * \"or\" & \"and\" operators are defined individually for each property. For Boolean properties it's literally &&, || operators.\n * But for other properties it's more nuanced.\n *\n * Whenver document schema does not match future schema, controller will send an op that attempts to changs documents schema to\n * future schema.\n *\n * Users of this class need to use DocumentsSchemaController.sessionSchema to determine what features can be used.\n *\n * There are two modes this class can operate:\n * 1) Legacy mode. In such mode it does not issue any ops to change document schema. Any changes happen implicitly,\n * right away, and new features are available right away\n * 2) Non-legacy mode. In such mode any changes to schema require an op roundtrip. This class will manage such transitions.\n * However code should assume that any new features that were not enabled in a given document will not be available\n * for a given session. That's because this session may never send any ops (including read-only documents). Or it may\n * fail to convert schema.\n * This class promises eventual movement forward. I.e. if new feature is allowed (let's say - through feature gates),\n * then eventually all documents that are modified will have that feature reflected in their schema. It could require\n * multiple reloads / new sessions to get there (depends on if code reacts to schema changes right away, or only consults\n * schema on document load).\n *\n * How schemas are changed (in non-legacy mode):\n * If a client needs to change a schema, it will attempt to do so as part of normal ops sending process.\n * Changes happen in CAS (Compare-and-swap) fashion, i.e. client tells current schema and schema it wants to change to.\n * When a number of clients race to change a schema, then only one of them will win, all others will fail because they will\n * reference old schema that is no longer in effect.\n * Clients can retry, but current implementation is simply - they will not (and will rely on next session / reload to do\n * recalc and decide if schema needs to be changed or not).\n *\n * @legacy\n * @alpha\n */\nexport class DocumentsSchemaController {\n\tprivate explicitSchemaControl: boolean;\n\tprivate sendOp = true;\n\n\t// schema coming from document metadata (snapshot we loaded from)\n\tprivate documentSchema: IDocumentSchemaCurrent;\n\n\t// desired schema, based on feature gates / runtime options.\n\t// This includes requests to enable to disable functionality\n\tprivate readonly desiredSchema: IDocumentSchemaCurrent;\n\n\t// OR() of document schema and desired schema. It enables all the features that are enabled in either of schemas.\n\tprivate futureSchema: IDocumentSchemaCurrent | undefined;\n\n\t// Current schema this session operates with.\n\t// 1) Legacy mode (explicitSchemaControl === false): this is same as desired schema - all options that were requested to be on are on, and all options requested to be off are off.\n\t// 2) Non-legacy mode (explicitSchemaControl === true): this is AND() of document schema and desired schema. Only options that are enabled in both are enabled here.\n\t// If there are any options that are not enabled in document schema, but are enabled in desired schema, then attempt to change schema\n\t// (and enable such options) will be made through the session.\n\tpublic sessionSchema: IDocumentSchemaCurrent;\n\n\t/**\n\t * Constructs DocumentsSchemaController that controls current schema and processes around it, including changes in schema.\n\t * @param existing - Is the document existing document, or a new doc.\n\t * @param documentMetadataSchema - current document's schema, if present.\n\t * @param features - features of the document schema that current session wants to see enabled.\n\t * @param onSchemaChange - callback that is called whenever schema is changed (not called on creation / load, only when processing document schema change ops)\n\t */\n\tconstructor(\n\t\texisting: boolean,\n\t\tsnapshotSequenceNumber: number,\n\t\tdocumentMetadataSchema: IDocumentSchema | undefined,\n\t\tfeatures: IDocumentSchemaFeatures,\n\t\tprivate readonly onSchemaChange: (schema: IDocumentSchemaCurrent) => void,\n\t) {\n\t\t// For simplicity, let's only support new schema features for explicit schema control mode\n\t\tassert(\n\t\t\tfeatures.disallowedVersions.length === 0 || features.explicitSchemaControl,\n\t\t\t0x949 /* not supported */,\n\t\t);\n\n\t\t// Desired schema by this session - almost all props are coming from arguments\n\t\tthis.desiredSchema = {\n\t\t\tversion: currentDocumentVersionSchema,\n\t\t\trefSeq: documentMetadataSchema?.refSeq ?? 0,\n\t\t\truntime: {\n\t\t\t\texplicitSchemaControl: boolToProp(features.explicitSchemaControl),\n\t\t\t\tcompressionLz4: boolToProp(features.compressionLz4),\n\t\t\t\tidCompressorMode: features.idCompressorMode,\n\t\t\t\topGroupingEnabled: boolToProp(features.opGroupingEnabled),\n\t\t\t\tdisallowedVersions: arrayToProp(features.disallowedVersions),\n\t\t\t},\n\t\t};\n\n\t\t// Schema coming from document metadata (snapshot we loaded from), or if no document exists\n\t\t// (this is a new document) then this is the same as desiredSchema (same as session schema in such case).\n\t\t// Latter is importnat sure that's what will go into summary.\n\t\tthis.documentSchema = !existing\n\t\t\t? this.desiredSchema\n\t\t\t: (documentMetadataSchema as IDocumentSchemaCurrent) ??\n\t\t\t\t({\n\t\t\t\t\tversion: currentDocumentVersionSchema,\n\t\t\t\t\t// see comment in summarizeDocumentSchema() on why it has to stay zero\n\t\t\t\t\trefSeq: 0,\n\t\t\t\t\t// If it's existing document and it has no schema, then it was written by legacy client.\n\t\t\t\t\t// If it's a new document, then we define it's legacy-related behaviors.\n\t\t\t\t\truntime: {\n\t\t\t\t\t\texplicitSchemaControl: boolToProp(!existing && features.explicitSchemaControl),\n\t\t\t\t\t},\n\t\t\t\t} satisfies IDocumentSchemaCurrent);\n\n\t\tcheckRuntimeCompatibility(this.documentSchema, \"document\");\n\t\tthis.validateSeqNumber(this.documentSchema.refSeq, snapshotSequenceNumber, \"summary\");\n\n\t\t// Use legacy behavior only if both document and options tell us to use legacy.\n\t\t// Otherwise it's no longer legacy time!\n\t\tthis.explicitSchemaControl =\n\t\t\tthis.documentSchema.runtime.explicitSchemaControl === true ||\n\t\t\tfeatures.explicitSchemaControl;\n\n\t\t// Calculate\n\t\t// - current session schema (overlap of document schema and desired schema)\n\t\t// - future schema to propose (concatination of document schema and desired schema)\n\t\tif (!this.explicitSchemaControl || !existing) {\n\t\t\tthis.sessionSchema = this.desiredSchema;\n\t\t\tassert(\n\t\t\t\tboolToProp(this.explicitSchemaControl) ===\n\t\t\t\t\tthis.sessionSchema.runtime.explicitSchemaControl,\n\t\t\t\t0x94a /* explicitSchemaControl */,\n\t\t\t);\n\t\t\tthis.futureSchema = undefined;\n\t\t} else {\n\t\t\tthis.sessionSchema = and(this.documentSchema, this.desiredSchema);\n\t\t\tthis.futureSchema = or(this.documentSchema, this.desiredSchema);\n\t\t\tassert(this.sessionSchema.runtime.explicitSchemaControl === true, 0x94b /* legacy */);\n\t\t\tassert(this.futureSchema.runtime.explicitSchemaControl === true, 0x94c /* legacy */);\n\t\t\tif (same(this.documentSchema, this.futureSchema)) {\n\t\t\t\tthis.futureSchema = undefined;\n\t\t\t}\n\t\t}\n\n\t\t// Validate that schema we are operating in is actually a schema we consider compatible with current runtime.\n\t\tcheckRuntimeCompatibility(this.desiredSchema, \"desired\");\n\t\tcheckRuntimeCompatibility(this.sessionSchema, \"session\");\n\t\tcheckRuntimeCompatibility(this.futureSchema, \"future\");\n\t}\n\n\tpublic summarizeDocumentSchema(refSeq: number): IDocumentSchemaCurrent | undefined {\n\t\t// For legacy behavior, we could write nothing (return undefined).\n\t\t// It does not buy us anything, as whatever written in summary does not actually impact clients operating in legacy mode.\n\t\t// But writing current used config (and assuming most of the clients settle on same config over time) will help with transition\n\t\t// out of legacy mode, as clients transitioning out of it would be able to use all the\n\t\t// features that are mentioned in schema right away, without a need to go through schema transition (and thus for a session or\n\t\t// two losing ability to use all the features)\n\n\t\tconst schema = this.explicitSchemaControl ? this.documentSchema : this.desiredSchema;\n\n\t\t// It's important to keep refSeq at zero in legacy mode, such that transition out of it is simple and we do not have\n\t\t// race conditions. If we put any other number (including latest seq number), then we will have two clients\n\t\t// (loading from two different summaries) with different numbers, and eventual consistency will be broken as schema\n\t\t// change ops will be interpretted differently by those two clients.\n\t\tassert(\n\t\t\tthis.explicitSchemaControl || schema.refSeq === 0,\n\t\t\t0x94d /* refSeq should be zero */,\n\t\t);\n\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Called by Container runtime whenever it is about to send some op.\n\t * It gives opportunity for controller to issue its own ops - we do not want to send ops if there are no local changes in document.\n\t * Please consider note above constructor about race conditions - current design is to send op only once in a session lifetime.\n\t * @returns Optional message to send.\n\t */\n\tpublic maybeSendSchemaMessage(): IDocumentSchemaChangeMessage | undefined {\n\t\tif (this.sendOp && this.futureSchema !== undefined) {\n\t\t\tthis.sendOp = false;\n\t\t\tassert(\n\t\t\t\tthis.explicitSchemaControl && this.futureSchema.runtime.explicitSchemaControl === true,\n\t\t\t\t0x94e /* not legacy */,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\t...this.futureSchema,\n\t\t\t\trefSeq: this.documentSchema.refSeq,\n\t\t\t};\n\t\t}\n\t}\n\n\tprivate validateSeqNumber(schemaSeqNumber: number, lastKnowSeqNumber, message: string) {\n\t\tif (!Number.isInteger(schemaSeqNumber) || !(schemaSeqNumber <= lastKnowSeqNumber)) {\n\t\t\tthrow DataProcessingError.create(\n\t\t\t\t\"DocSchema: Incorrect sequence number\",\n\t\t\t\t\"checkRuntimeCompat3\",\n\t\t\t\tundefined, // message\n\t\t\t\t{\n\t\t\t\t\tschemaSeqNumber,\n\t\t\t\t\tsequenceNumber: lastKnowSeqNumber,\n\t\t\t\t\tmessage,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Process document schema change message\n\t * Called by ContainerRuntime whenever it sees document schema messages.\n\t * @param content - content of the message\n\t * @param local - whether op is local\n\t * @param sequenceNumber - sequence number of the op\n\t * @returns - true if schema was accepted, otherwise false (rejected due to failed CAS)\n\t */\n\tpublic processDocumentSchemaOp(\n\t\tcontent: IDocumentSchemaChangeMessage,\n\t\tlocal: boolean,\n\t\tsequenceNumber: number,\n\t) {\n\t\tthis.validateSeqNumber(content.refSeq, this.documentSchema.refSeq, \"content.refSeq\");\n\t\tthis.validateSeqNumber(this.documentSchema.refSeq, sequenceNumber, \"refSeq\");\n\t\t// validate is strickly less, not equal\n\t\tassert(\n\t\t\tthis.documentSchema.refSeq < sequenceNumber,\n\t\t\t0x950 /* time should move forward only! */,\n\t\t);\n\n\t\tif (content.refSeq !== this.documentSchema.refSeq) {\n\t\t\t// CAS failed\n\t\t\treturn false;\n\t\t}\n\n\t\t// This assert should be after checking for successful CAS above.\n\t\t// This will ensure we do not trip on our own messages that are no longer wanted as we processed someone else schema change message.\n\t\tassert(\n\t\t\t!local || (this.explicitSchemaControl && this.futureSchema !== undefined),\n\t\t\t0x951 /* not sending ops */,\n\t\t);\n\n\t\t// Changes are in effect. Immediately check that this client understands these changes\n\t\tcheckRuntimeCompatibility(content, \"change\");\n\n\t\tconst schema: IDocumentSchema = { ...content, refSeq: sequenceNumber };\n\t\tthis.documentSchema = schema as IDocumentSchemaCurrent;\n\t\tthis.sessionSchema = and(this.documentSchema, this.desiredSchema);\n\t\tassert(this.sessionSchema.refSeq === sequenceNumber, 0x97d /* seq# */);\n\n\t\t// legacy behavior is automatically off for the document once someone sends a schema op -\n\t\t// from now on it's fully controlled by ops.\n\t\t// This is very important, as summarizeDocumentSchema() should use this new schema!\n\t\tthis.explicitSchemaControl = true;\n\n\t\t// Stop attempting changing schema.\n\t\t// If it was local op, then we succeeded and do not need to try again.\n\t\t// If it was remote op, then some changes happened to schema.\n\t\t// We would need to recalculate this.futureSchema by merging changes that we just received.\n\t\t// Avoid this complexity for now - a new client session (loading from new summary with these changes)\n\t\t// will automatically do this recalculation and will figure out\n\t\tthis.futureSchema = undefined;\n\n\t\tthis.onSchemaChange(this.sessionSchema);\n\n\t\treturn true;\n\t}\n\n\tpublic onDisconnect() {\n\t\tthis.sendOp = true;\n\t}\n}\n\n/* eslint-enable jsdoc/check-indentation */\n"]}
1
+ {"version":3,"file":"documentSchema.js","sourceRoot":"","sources":["../../src/summary/documentSchema.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,uEAA+E;AAE/E,4DAAkD;AA4GlD;;;;;;;GAOG;AACU,QAAA,4BAA4B,GAAG,CAAC,CAAC;AAyB9C,MAAM,eAAe;IACb,GAAG,CAAC,gBAAuB,EAAE,gBAAuB;QAC1D,OAAO,gBAAgB,KAAK,IAAI,IAAI,gBAAgB,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAClF,CAAC;IAEM,EAAE,CAAC,gBAAuB,EAAE,gBAAuB;QACzD,OAAO,gBAAgB,KAAK,IAAI,IAAI,gBAAgB,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAClF,CAAC;IAEM,QAAQ,CAAC,CAAU;QACzB,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,CAAC;IACtC,CAAC;CACD;AAED,MAAM,kBAAmB,SAAQ,eAAe;IACxC,GAAG,CAAC,gBAAuB,EAAE,gBAAuB;QAC1D,OAAO,I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AAI,CAAC,aAAa,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,YAAY;QAClB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACpB,CAAC;CACD;AApPD,8DAoPC;AAED,2CAA2C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { DataProcessingError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { pkgVersion } from \"../packageVersion.js\";\n\n/**\n * Descripe allowed type for properties in document schema.\n * Please note that for all property types we should use undefined to indicate that particular capability is off.\n * Using false, or some string value (like \"off\") will result in clients who do not understand that property failing, whereas\n * we want them to continue to collaborate alongside clients who support that capability, but such capability is shipping dark for now.\n * @legacy\n * @alpha\n */\nexport type DocumentSchemaValueType = string | string[] | true | number | undefined;\n\n/**\n * ID Compressor mode.\n * \"on\" - compressor is On. It's loaded as part of container load. This mode is sticky - once on, compressor is On for all\n * sessions for a given document. This results in IContainerRuntime.idCompressor to be always available.\n * \"delayed\" - ID compressor bundle is loaded only on establishing of first delta connection, i.e. it does not impact boot of cotnainer.\n * In such mode IContainerRuntime.idCompressor is not made available (unless previous sessions of same document had it \"On\").\n * The only thing that is available is IContainerRuntime.generateDocumentUniqueId() that provides opportunistically short IDs.\n * undefined - ID compressor is not loaded.\n * While IContainerRuntime.generateDocumentUniqueId() is available, it will produce long IDs that are do not compress well.\n *\n * @legacy\n * @alpha\n */\nexport type IdCompressorMode = \"on\" | \"delayed\" | undefined;\n\n/**\n * Document schema information.\n * Describes overall shape of document schema, including unknown (to this version) properties.\n *\n * Used by runtime to make a call if it can understand document schema.\n * If it can't, it should not continue with document and immediately fail, preventing random (cryptic) failures\n * down the road and potentially corrupting documents.\n * For now this structure and appropriate interpretation / behavior is focused only on runtime features.\n * In the future that could be interpolated to more areas, including DDSs used, and even possibly - application\n * schema.\n *\n * Runtime will ignore any properties at the root that it does not understand (i.e. IDocumentSchema.app), but will\n * stop (and fail session) on any unknown properties within \"runtime\" sub-tree.\n *\n * In most cases values preserved in the document will not dictate if such features should be enabled in a given session.\n * I.e. if compression is mentioned in document schema, this means that runtime version that opens such document must know\n * how to interpret such ops, but does not need to actually use compression itself. That said, some options could be\n * sticky, i.e. influence feature selection for all runtimes opening a document. ID compression is one such example.\n * Currently there is no mechanism to remove feature from this property bag, i.e. once compression was used, even if it's\n * disabled (through feature gate or code deployment), all existing documents that used compression will continue to fail\n * if opened by clients who do not support compression.\n *\n * For now we are limiting it to just plain properties, and only really simple types, but that can be changed in the future.\n *\n * @legacy\n * @alpha\n */\nexport interface IDocumentSchema {\n\t// version that describes how data is stored in this structure.\n\t// If runtime sees a version it does not understand, it should immediately fail and not\n\t// attempt to interpret any further data.\n\tversion: number;\n\n\t// Sequence number when this schema became active.\n\trefSeq: number;\n\n\truntime: Record<string, DocumentSchemaValueType>;\n}\n\n/**\n * Content of the type=ContainerMessageType.DocumentSchemaChange ops.\n * The meaning of refSeq field is different in such messages (compared to other usages of IDocumentSchemaCurrent)\n * ContainerMessageType.DocumentSchemaChange messages use CAS (Compare-and-swap) semantics, and convey\n * regSeq of last known schema change (known to a client proposing schema change).\n * @see ContainerRuntimeDocumentSchemaMessage\n * @legacy\n * @alpha\n */\nexport type IDocumentSchemaChangeMessage = IDocumentSchema;\n\n/**\n * Settings that this session would like to have, based on options and feature gates.\n *\n * WARNING: This type is used to infer IDocumentSchemaCurrent type!\n * Any changes here (including renaming of properties) are potentially changing document format and should be considered carefully!\n *\n * @legacy\n * @alpha\n */\nexport interface IDocumentSchemaFeatures {\n\t// Tells if client uses legacy behavior of changing schema.\n\t// - Legacy behavior - changing schema without leveraging schema change ops.\n\t// - New behavior - changes in schema require ops and take into affect with delay.\n\texplicitSchemaControl: boolean;\n\tcompressionLz4: boolean;\n\tidCompressorMode: IdCompressorMode;\n\topGroupingEnabled: boolean;\n\n\t/**\n\t * List of disallowed versions of the runtime.\n\t * This option is sticky. Once a version of runtime is added to this list (when supplied to DocumentsSchemaController's constructor)\n\t * it will be added to the list of disallowed versions and stored in document metadata.\n\t * Each runtime checks if its version is in this list on container open. If it is, it immediately exits with error message\n\t * indicating to the user that this version is no longer supported.\n\t * Currently there is no mechanism to remove version from this list. I.e. If it was once added to the list,\n\t * it gets added to any document metadata (documents that gets open by this runtime) and there is no way to clear it from document's\n\t * metadata.\n\t */\n\tdisallowedVersions: string[];\n}\n\n/**\n * Current version known properties that define document schema\n * This must be bumped whenever the format of document schema or protocol for changing the current document schema changes.\n * Ex: adding a new configuration property (under IDocumentSchema.runtime) does not require changing this version.\n * Ex: Changing the 'document schema acceptance' mechanism from convert-and-swap to one requiring consensus does require changing this version.\n * @legacy\n * @alpha\n */\nexport const currentDocumentVersionSchema = 1;\n\n/**\n * Current document schema.\n * @legacy\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport type IDocumentSchemaCurrent = {\n\tversion: 1;\n\trefSeq: number;\n\n\truntime: {\n\t\t[P in keyof IDocumentSchemaFeatures]?: IDocumentSchemaFeatures[P] extends boolean\n\t\t\t? true\n\t\t\t: IDocumentSchemaFeatures[P];\n\t};\n};\n\ninterface IProperty<T = unknown> {\n\tand: (currentDocSchema: T, desiredDocSchema: T) => T;\n\tor: (currentDocSchema: T, desiredDocSchema: T) => T;\n\tvalidate(t: unknown): boolean;\n}\n\nclass TrueOrUndefined implements IProperty<true | undefined> {\n\tpublic and(currentDocSchema?: true, desiredDocSchema?: true) {\n\t\treturn currentDocSchema === true && desiredDocSchema === true ? true : undefined;\n\t}\n\n\tpublic or(currentDocSchema?: true, desiredDocSchema?: true) {\n\t\treturn currentDocSchema === true || desiredDocSchema === true ? true : undefined;\n\t}\n\n\tpublic validate(t: unknown) {\n\t\treturn t === undefined || t === true;\n\t}\n}\n\nclass TrueOrUndefinedMax extends TrueOrUndefined {\n\tpublic and(currentDocSchema?: true, desiredDocSchema?: true) {\n\t\treturn this.or(currentDocSchema, desiredDocSchema);\n\t}\n}\n\nclass MultiChoice implements IProperty<string | undefined> {\n\tconstructor(private readonly choices: string[]) {}\n\n\tpublic and(currentDocSchema?: string, desiredDocSchema?: string) {\n\t\tif (currentDocSchema === undefined || desiredDocSchema === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn this.choices[\n\t\t\tMath.min(this.choices.indexOf(currentDocSchema), this.choices.indexOf(desiredDocSchema))\n\t\t];\n\t}\n\n\tpublic or(currentDocSchema?: string, desiredDocSchema?: string) {\n\t\tif (currentDocSchema === undefined) {\n\t\t\treturn desiredDocSchema;\n\t\t}\n\t\tif (desiredDocSchema === undefined) {\n\t\t\treturn currentDocSchema;\n\t\t}\n\t\treturn this.choices[\n\t\t\tMath.max(this.choices.indexOf(currentDocSchema), this.choices.indexOf(desiredDocSchema))\n\t\t];\n\t}\n\n\tpublic validate(t: unknown) {\n\t\treturn t === undefined || (typeof t === \"string\" && this.choices.includes(t));\n\t}\n}\n\nclass IdCompressorProperty extends MultiChoice {\n\t// document schema always wins!\n\tpublic and(currentDocSchema?: string, desiredDocSchema?: string) {\n\t\treturn currentDocSchema;\n\t}\n}\n\nclass CheckVersions implements IProperty<string[] | undefined> {\n\tpublic or(currentDocSchema: string[] = [], desiredDocSchema: string[] = []) {\n\t\tconst set = new Set<string>([...currentDocSchema, ...desiredDocSchema]);\n\t\treturn arrayToProp([...set.values()]);\n\t}\n\n\t// Once version is there, it stays there forever.\n\tpublic and(currentDocSchema: string[] = [], desiredDocSchema: string[] = []) {\n\t\treturn this.or(currentDocSchema, desiredDocSchema);\n\t}\n\n\tpublic validate(t: unknown) {\n\t\treturn t === undefined || (Array.isArray(t) && !t.includes(pkgVersion));\n\t}\n}\n\n/**\n * Helper structure to valida if a schema is compatible with existing code.\n */\nconst documentSchemaSupportedConfigs = {\n\texplicitSchemaControl: new TrueOrUndefinedMax(), // once new behavior shows up, it's sticky\n\tidCompressorMode: new IdCompressorProperty([\"delayed\", \"on\"]),\n\topGroupingEnabled: new TrueOrUndefined(),\n\tcompressionLz4: new TrueOrUndefined(),\n\tdisallowedVersions: new CheckVersions(),\n};\n\n/**\n * Checks if a given schema is compatible with current code, i.e. if current code can understand all the features of that schema.\n * If schema is not compatible with current code, it throws an exception.\n * @param documentSchema - current schema\n */\nfunction checkRuntimeCompatibility(\n\tdocumentSchema: IDocumentSchema | undefined,\n\tschemaName: string,\n) {\n\t// Back-compat - we can't do anything about legacy documents.\n\t// There is no way to validate them, so we are taking a guess that safe deployment processes used by a given app\n\t// do not run into compat problems.\n\tif (documentSchema === undefined) {\n\t\treturn;\n\t}\n\n\tconst msg = \"Document can't be opened with current version of the code\";\n\tif (documentSchema.version !== currentDocumentVersionSchema) {\n\t\tthrow DataProcessingError.create(\n\t\t\tmsg,\n\t\t\t\"checkRuntimeCompat1\",\n\t\t\tundefined, // message\n\t\t\t{\n\t\t\t\truntimeSchemaVersion: documentSchema.version,\n\t\t\t\tcurrentRuntimeSchemaVersion: currentDocumentVersionSchema,\n\t\t\t\tschemaName,\n\t\t\t},\n\t\t);\n\t}\n\n\tlet unknownProperty: string | undefined;\n\n\tconst regSeq = documentSchema.refSeq;\n\t// defence in depth - it should not be possible to get here anything other than integer, but worth validating it.\n\tif (typeof regSeq !== \"number\" || regSeq < 0 || !Number.isInteger(regSeq)) {\n\t\tunknownProperty = \"refSeq\";\n\t} else if (documentSchema.runtime === null || typeof documentSchema.runtime !== \"object\") {\n\t\tunknownProperty = \"runtime\";\n\t} else {\n\t\tfor (const [name, value] of Object.entries(documentSchema.runtime)) {\n\t\t\tconst validator = documentSchemaSupportedConfigs[name] as IProperty | undefined;\n\t\t\tif (validator === undefined || !validator.validate(value)) {\n\t\t\t\tunknownProperty = `runtime/${name}`;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (unknownProperty !== undefined) {\n\t\tconst value = documentSchema[unknownProperty];\n\t\tthrow DataProcessingError.create(\n\t\t\tmsg,\n\t\t\t\"checkRuntimeCompat2\",\n\t\t\tundefined, // message\n\t\t\t{\n\t\t\t\tcodeVersion: currentDocumentVersionSchema,\n\t\t\t\tproperty: unknownProperty,\n\t\t\t\tvalue,\n\t\t\t\tschemaName,\n\t\t\t},\n\t\t);\n\t}\n}\n\nfunction and(\n\tcurrentDocSchema: IDocumentSchemaCurrent,\n\tdesiredDocSchema: IDocumentSchemaCurrent,\n): IDocumentSchemaCurrent {\n\tconst runtime = {};\n\tfor (const key of new Set([\n\t\t...Object.keys(currentDocSchema.runtime),\n\t\t...Object.keys(desiredDocSchema.runtime),\n\t])) {\n\t\truntime[key] = (documentSchemaSupportedConfigs[key] as IProperty).and(\n\t\t\tcurrentDocSchema.runtime[key],\n\t\t\tdesiredDocSchema.runtime[key],\n\t\t);\n\t}\n\treturn {\n\t\tversion: currentDocumentVersionSchema,\n\t\trefSeq: currentDocSchema.refSeq,\n\t\truntime,\n\t} as unknown as IDocumentSchemaCurrent;\n}\n\nfunction or(\n\tcurrentDocSchema: IDocumentSchemaCurrent,\n\tdesiredDocSchema: IDocumentSchemaCurrent,\n): IDocumentSchemaCurrent {\n\tconst runtime = {};\n\tfor (const key of new Set([\n\t\t...Object.keys(currentDocSchema.runtime),\n\t\t...Object.keys(desiredDocSchema.runtime),\n\t])) {\n\t\truntime[key] = (documentSchemaSupportedConfigs[key] as IProperty).or(\n\t\t\tcurrentDocSchema.runtime[key],\n\t\t\tdesiredDocSchema.runtime[key],\n\t\t);\n\t}\n\treturn {\n\t\tversion: currentDocumentVersionSchema,\n\t\trefSeq: currentDocSchema.refSeq,\n\t\truntime,\n\t} as unknown as IDocumentSchemaCurrent;\n}\n\nfunction same(\n\tcurrentDocSchema: IDocumentSchemaCurrent,\n\tdesiredDocSchema: IDocumentSchemaCurrent,\n): boolean {\n\tfor (const key of new Set([\n\t\t...Object.keys(currentDocSchema.runtime),\n\t\t...Object.keys(desiredDocSchema.runtime),\n\t])) {\n\t\t// If schemas differ only by type of behavior, then we should not send schema change ops!\n\t\tif (\n\t\t\tkey !== \"explicitSchemaControl\" &&\n\t\t\tcurrentDocSchema.runtime[key] !== desiredDocSchema.runtime[key]\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction boolToProp(b: boolean) {\n\treturn b ? true : undefined;\n}\n\nfunction arrayToProp(arr: string[]) {\n\treturn arr.length === 0 ? undefined : arr;\n}\n\n/* eslint-disable jsdoc/check-indentation */\n\n/**\n * Controller of document schema.\n *\n * Recommended pre-reading: https://github.com/microsoft/FluidFramework/blob/main/packages/dds/SchemaVersioning.md\n *\n * This class manages current document schema and transitions between document schemas.\n * At the moment, it only focuses on subset of document schema, specifically - how FluidFramework runtime serializes data\n * (summary and op format), features & capabilities that a version of runtime has to support and understand in\n * order to collaborate on a document.\n * New features that modify document format have to be included in document schema definition.\n * Usage of such features could only happen after document schema has been updated to reflect such feature.\n *\n * This formality allows clients that do not understand such features to fail right away when they observe\n * document schema listing capabilities that such client does not understand.\n * Old clients will fail in predictable way. This allows us to\n * 1) Immediately see such issues and adjust if features are enabled too early, before changes have been saturated.\n * 2) There is no way to get to 100% saturation with new code. Even if we have 99.99% saturation, there are\n * still 0.01% of clients who will fail. Failing early and predictably ensures they have no chance to limp along\n * and potentially corrupt the document. This is especially true for summarizer client, who could simply \"undo\"\n * changes it does not understands.\n *\n * It's important to note how it overlaps with feature gates and safe velocity.\n * If new feature was in use, that resulted in a number of documents referencing such feature in document schema.\n * But, developers (through code deployment or feature gates) could disable usage of such features.\n * That will stop a process of further document schema changes (for documents that were not using such feature).\n * And documents that already list such capability in their schema will continue to do so. Later ensures that old\n * clients who do not understand such feature will continue to fail to open such documents, as such documents very\n * likely contain data in a new format.\n *\n * Controller operates with 4 schemas:\n * - document schema: whatever we loaded from summary metadata + ops. It follows eventuall consistency rules (i.e. like DDS).\n * - desired schema - what client is asking for to have (i.e. all the desired settings, based on runtime options / feature gates).\n * - session schema - current session schema. It's \"and\" of the above two schemas.\n * - future schema - \"or\" of document and desires schemas.\n *\n * \"or\" & \"and\" operators are defined individually for each property. For Boolean properties it's literally &&, || operators.\n * But for other properties it's more nuanced.\n *\n * Whenver document schema does not match future schema, controller will send an op that attempts to changs documents schema to\n * future schema.\n *\n * Users of this class need to use DocumentsSchemaController.sessionSchema to determine what features can be used.\n *\n * There are two modes this class can operate:\n * 1) Legacy mode. In such mode it does not issue any ops to change document schema. Any changes happen implicitly,\n * right away, and new features are available right away\n * 2) Non-legacy mode. In such mode any changes to schema require an op roundtrip. This class will manage such transitions.\n * However code should assume that any new features that were not enabled in a given document will not be available\n * for a given session. That's because this session may never send any ops (including read-only documents). Or it may\n * fail to convert schema.\n * This class promises eventual movement forward. I.e. if new feature is allowed (let's say - through feature gates),\n * then eventually all documents that are modified will have that feature reflected in their schema. It could require\n * multiple reloads / new sessions to get there (depends on if code reacts to schema changes right away, or only consults\n * schema on document load).\n *\n * How schemas are changed (in non-legacy mode):\n * If a client needs to change a schema, it will attempt to do so as part of normal ops sending process.\n * Changes happen in CAS (Compare-and-swap) fashion, i.e. client tells current schema and schema it wants to change to.\n * When a number of clients race to change a schema, then only one of them will win, all others will fail because they will\n * reference old schema that is no longer in effect.\n * Clients can retry, but current implementation is simply - they will not (and will rely on next session / reload to do\n * recalc and decide if schema needs to be changed or not).\n *\n * @legacy\n * @alpha\n * @sealed\n */\nexport class DocumentsSchemaController {\n\tprivate explicitSchemaControl: boolean;\n\tprivate sendOp = true;\n\n\t// schema coming from document metadata (snapshot we loaded from)\n\tprivate documentSchema: IDocumentSchemaCurrent;\n\n\t// desired schema, based on feature gates / runtime options.\n\t// This includes requests to enable to disable functionality\n\tprivate readonly desiredSchema: IDocumentSchemaCurrent;\n\n\t// OR() of document schema and desired schema. It enables all the features that are enabled in either of schemas.\n\tprivate futureSchema: IDocumentSchemaCurrent | undefined;\n\n\t// Current schema this session operates with.\n\t// 1) Legacy mode (explicitSchemaControl === false): this is same as desired schema - all options that were requested to be on are on, and all options requested to be off are off.\n\t// 2) Non-legacy mode (explicitSchemaControl === true): this is AND() of document schema and desired schema. Only options that are enabled in both are enabled here.\n\t// If there are any options that are not enabled in document schema, but are enabled in desired schema, then attempt to change schema\n\t// (and enable such options) will be made through the session.\n\tpublic sessionSchema: IDocumentSchemaCurrent;\n\n\t/**\n\t * Constructs DocumentsSchemaController that controls current schema and processes around it, including changes in schema.\n\t * @param existing - Is the document existing document, or a new doc.\n\t * @param documentMetadataSchema - current document's schema, if present.\n\t * @param features - features of the document schema that current session wants to see enabled.\n\t * @param onSchemaChange - callback that is called whenever schema is changed (not called on creation / load, only when processing document schema change ops)\n\t */\n\tconstructor(\n\t\texisting: boolean,\n\t\tsnapshotSequenceNumber: number,\n\t\tdocumentMetadataSchema: IDocumentSchema | undefined,\n\t\tfeatures: IDocumentSchemaFeatures,\n\t\tprivate readonly onSchemaChange: (schema: IDocumentSchemaCurrent) => void,\n\t) {\n\t\t// For simplicity, let's only support new schema features for explicit schema control mode\n\t\tassert(\n\t\t\tfeatures.disallowedVersions.length === 0 || features.explicitSchemaControl,\n\t\t\t0x949 /* not supported */,\n\t\t);\n\n\t\t// Desired schema by this session - almost all props are coming from arguments\n\t\tthis.desiredSchema = {\n\t\t\tversion: currentDocumentVersionSchema,\n\t\t\trefSeq: documentMetadataSchema?.refSeq ?? 0,\n\t\t\truntime: {\n\t\t\t\texplicitSchemaControl: boolToProp(features.explicitSchemaControl),\n\t\t\t\tcompressionLz4: boolToProp(features.compressionLz4),\n\t\t\t\tidCompressorMode: features.idCompressorMode,\n\t\t\t\topGroupingEnabled: boolToProp(features.opGroupingEnabled),\n\t\t\t\tdisallowedVersions: arrayToProp(features.disallowedVersions),\n\t\t\t},\n\t\t};\n\n\t\t// Schema coming from document metadata (snapshot we loaded from), or if no document exists\n\t\t// (this is a new document) then this is the same as desiredSchema (same as session schema in such case).\n\t\t// Latter is importnat sure that's what will go into summary.\n\t\tthis.documentSchema = !existing\n\t\t\t? this.desiredSchema\n\t\t\t: ((documentMetadataSchema as IDocumentSchemaCurrent) ??\n\t\t\t\t({\n\t\t\t\t\tversion: currentDocumentVersionSchema,\n\t\t\t\t\t// see comment in summarizeDocumentSchema() on why it has to stay zero\n\t\t\t\t\trefSeq: 0,\n\t\t\t\t\t// If it's existing document and it has no schema, then it was written by legacy client.\n\t\t\t\t\t// If it's a new document, then we define it's legacy-related behaviors.\n\t\t\t\t\truntime: {\n\t\t\t\t\t\texplicitSchemaControl: boolToProp(!existing && features.explicitSchemaControl),\n\t\t\t\t\t},\n\t\t\t\t} satisfies IDocumentSchemaCurrent));\n\n\t\tcheckRuntimeCompatibility(this.documentSchema, \"document\");\n\t\tthis.validateSeqNumber(this.documentSchema.refSeq, snapshotSequenceNumber, \"summary\");\n\n\t\t// Use legacy behavior only if both document and options tell us to use legacy.\n\t\t// Otherwise it's no longer legacy time!\n\t\tthis.explicitSchemaControl =\n\t\t\tthis.documentSchema.runtime.explicitSchemaControl === true ||\n\t\t\tfeatures.explicitSchemaControl;\n\n\t\t// Calculate\n\t\t// - current session schema (overlap of document schema and desired schema)\n\t\t// - future schema to propose (concatination of document schema and desired schema)\n\t\tif (!this.explicitSchemaControl || !existing) {\n\t\t\tthis.sessionSchema = this.desiredSchema;\n\t\t\tassert(\n\t\t\t\tboolToProp(this.explicitSchemaControl) ===\n\t\t\t\t\tthis.sessionSchema.runtime.explicitSchemaControl,\n\t\t\t\t0x94a /* explicitSchemaControl */,\n\t\t\t);\n\t\t\tthis.futureSchema = undefined;\n\t\t} else {\n\t\t\tthis.sessionSchema = and(this.documentSchema, this.desiredSchema);\n\t\t\tthis.futureSchema = or(this.documentSchema, this.desiredSchema);\n\t\t\tassert(this.sessionSchema.runtime.explicitSchemaControl === true, 0x94b /* legacy */);\n\t\t\tassert(this.futureSchema.runtime.explicitSchemaControl === true, 0x94c /* legacy */);\n\t\t\tif (same(this.documentSchema, this.futureSchema)) {\n\t\t\t\tthis.futureSchema = undefined;\n\t\t\t}\n\t\t}\n\n\t\t// Validate that schema we are operating in is actually a schema we consider compatible with current runtime.\n\t\tcheckRuntimeCompatibility(this.desiredSchema, \"desired\");\n\t\tcheckRuntimeCompatibility(this.sessionSchema, \"session\");\n\t\tcheckRuntimeCompatibility(this.futureSchema, \"future\");\n\t}\n\n\tpublic summarizeDocumentSchema(refSeq: number): IDocumentSchemaCurrent | undefined {\n\t\t// For legacy behavior, we could write nothing (return undefined).\n\t\t// It does not buy us anything, as whatever written in summary does not actually impact clients operating in legacy mode.\n\t\t// But writing current used config (and assuming most of the clients settle on same config over time) will help with transition\n\t\t// out of legacy mode, as clients transitioning out of it would be able to use all the\n\t\t// features that are mentioned in schema right away, without a need to go through schema transition (and thus for a session or\n\t\t// two losing ability to use all the features)\n\n\t\tconst schema = this.explicitSchemaControl ? this.documentSchema : this.desiredSchema;\n\n\t\t// It's important to keep refSeq at zero in legacy mode, such that transition out of it is simple and we do not have\n\t\t// race conditions. If we put any other number (including latest seq number), then we will have two clients\n\t\t// (loading from two different summaries) with different numbers, and eventual consistency will be broken as schema\n\t\t// change ops will be interpretted differently by those two clients.\n\t\tassert(\n\t\t\tthis.explicitSchemaControl || schema.refSeq === 0,\n\t\t\t0x94d /* refSeq should be zero */,\n\t\t);\n\n\t\treturn schema;\n\t}\n\n\t/**\n\t * Called by Container runtime whenever it is about to send some op.\n\t * It gives opportunity for controller to issue its own ops - we do not want to send ops if there are no local changes in document.\n\t * Please consider note above constructor about race conditions - current design is to send op only once in a session lifetime.\n\t * @returns Optional message to send.\n\t */\n\tpublic maybeSendSchemaMessage(): IDocumentSchemaChangeMessage | undefined {\n\t\tif (this.sendOp && this.futureSchema !== undefined) {\n\t\t\tthis.sendOp = false;\n\t\t\tassert(\n\t\t\t\tthis.explicitSchemaControl && this.futureSchema.runtime.explicitSchemaControl === true,\n\t\t\t\t0x94e /* not legacy */,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\t...this.futureSchema,\n\t\t\t\trefSeq: this.documentSchema.refSeq,\n\t\t\t};\n\t\t}\n\t}\n\n\tprivate validateSeqNumber(schemaSeqNumber: number, lastKnowSeqNumber, message: string) {\n\t\tif (!Number.isInteger(schemaSeqNumber) || !(schemaSeqNumber <= lastKnowSeqNumber)) {\n\t\t\tthrow DataProcessingError.create(\n\t\t\t\t\"DocSchema: Incorrect sequence number\",\n\t\t\t\t\"checkRuntimeCompat3\",\n\t\t\t\tundefined, // message\n\t\t\t\t{\n\t\t\t\t\tschemaSeqNumber,\n\t\t\t\t\tsequenceNumber: lastKnowSeqNumber,\n\t\t\t\t\tmessage,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Process document schema change message\n\t * Called by ContainerRuntime whenever it sees document schema messages.\n\t * @param content - content of the message\n\t * @param local - whether op is local\n\t * @param sequenceNumber - sequence number of the op\n\t * @returns - true if schema was accepted, otherwise false (rejected due to failed CAS)\n\t * @deprecated It has been replaced by processDocumentSchemaMessages instead.\n\t */\n\tpublic processDocumentSchemaOp(\n\t\tcontent: IDocumentSchemaChangeMessage,\n\t\tlocal: boolean,\n\t\tsequenceNumber: number,\n\t) {\n\t\treturn this.processDocumentSchemaMessages([content], local, sequenceNumber);\n\t}\n\n\t/**\n\t * Process document schema change messages\n\t * Called by ContainerRuntime whenever it sees document schema messages.\n\t * @param contents - contents of the messages\n\t * @param local - whether op is local\n\t * @param sequenceNumber - sequence number of the op\n\t * @returns - true if schema was accepted, otherwise false (rejected due to failed CAS)\n\t */\n\tpublic processDocumentSchemaMessages(\n\t\tcontents: IDocumentSchemaChangeMessage[],\n\t\tlocal: boolean,\n\t\tsequenceNumber: number,\n\t) {\n\t\tfor (const content of contents) {\n\t\t\tthis.validateSeqNumber(content.refSeq, this.documentSchema.refSeq, \"content.refSeq\");\n\t\t\tthis.validateSeqNumber(this.documentSchema.refSeq, sequenceNumber, \"refSeq\");\n\t\t\t// validate is strickly less, not equal\n\t\t\tassert(\n\t\t\t\tthis.documentSchema.refSeq < sequenceNumber,\n\t\t\t\t0x950 /* time should move forward only! */,\n\t\t\t);\n\n\t\t\tif (content.refSeq !== this.documentSchema.refSeq) {\n\t\t\t\t// CAS failed\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// This assert should be after checking for successful CAS above.\n\t\t\t// This will ensure we do not trip on our own messages that are no longer wanted as we processed someone else schema change message.\n\t\t\tassert(\n\t\t\t\t!local || (this.explicitSchemaControl && this.futureSchema !== undefined),\n\t\t\t\t0x951 /* not sending ops */,\n\t\t\t);\n\n\t\t\t// Changes are in effect. Immediately check that this client understands these changes\n\t\t\tcheckRuntimeCompatibility(content, \"change\");\n\n\t\t\tconst schema: IDocumentSchema = { ...content, refSeq: sequenceNumber };\n\t\t\tthis.documentSchema = schema as IDocumentSchemaCurrent;\n\t\t\tthis.sessionSchema = and(this.documentSchema, this.desiredSchema);\n\t\t\tassert(this.sessionSchema.refSeq === sequenceNumber, 0x97d /* seq# */);\n\n\t\t\t// legacy behavior is automatically off for the document once someone sends a schema op -\n\t\t\t// from now on it's fully controlled by ops.\n\t\t\t// This is very important, as summarizeDocumentSchema() should use this new schema!\n\t\t\tthis.explicitSchemaControl = true;\n\n\t\t\t// Stop attempting changing schema.\n\t\t\t// If it was local op, then we succeeded and do not need to try again.\n\t\t\t// If it was remote op, then some changes happened to schema.\n\t\t\t// We would need to recalculate this.futureSchema by merging changes that we just received.\n\t\t\t// Avoid this complexity for now - a new client session (loading from new summary with these changes)\n\t\t\t// will automatically do this recalculation and will figure out\n\t\t\tthis.futureSchema = undefined;\n\n\t\t\tthis.onSchemaChange(this.sessionSchema);\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic onDisconnect() {\n\t\tthis.sendOp = true;\n\t}\n}\n\n/* eslint-enable jsdoc/check-indentation */\n"]}
@@ -6,8 +6,8 @@ import { TypedEventEmitter } from "@fluid-internal/client-utils";
6
6
  import { ICriticalContainerError } from "@fluidframework/container-definitions";
7
7
  import { IContainerRuntime, IContainerRuntimeEvents } from "@fluidframework/container-runtime-definitions/internal";
8
8
  import { IFluidHandleContext, type IFluidHandleInternal } from "@fluidframework/core-interfaces/internal";
9
- import { IDocumentStorageService, ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
10
- import { IGarbageCollectionData, ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions/internal";
9
+ import { IDocumentStorageService } from "@fluidframework/driver-definitions/internal";
10
+ import { IGarbageCollectionData, ISummaryTreeWithStats, ITelemetryContext, type ISequencedMessageEnvelope } from "@fluidframework/runtime-definitions/internal";
11
11
  import { FluidHandleBase } from "@fluidframework/runtime-utils/internal";
12
12
  import { type IBlobManagerLoadInfo } from "./blobManagerSnapSum.js";
13
13
  /**
@@ -119,7 +119,7 @@ export declare class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
119
119
  * @param metadata - op metadata containing storage and/or local IDs
120
120
  */
121
121
  reSubmit(metadata: Record<string, unknown> | undefined): void;
122
- processBlobAttachOp(message: ISequencedDocumentMessage, local: boolean): void;
122
+ processBlobAttachMessage(message: ISequencedMessageEnvelope, local: boolean): void;
123
123
  summarize(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
124
124
  /**
125
125
  * Generates data used for garbage collection. Each blob uploaded represents a node in the GC graph as it can be
@@ -1 +1 @@
1
- {"version":3,"file":"blobManager.d.ts","sourceRoot":"","sources":["../../src/blobManager/blobManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,iBAAiB,EAGjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAe,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAC7F,OAAO,EACN,iBAAiB,EACjB,uBAAuB,EACvB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EACN,mBAAmB,EACnB,KAAK,oBAAoB,EACzB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EACN,uBAAuB,EAEvB,yBAAyB,EACzB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EACN,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACN,eAAe,EA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OAKG;IACI,SAAS,CAAC,MAAM,GAAE,OAAe,GAAG,sBAAsB;IAejE;;;;;OAKG;IACI,qBAAqB,CAAC,oBAAoB,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE;IAKxF;;;;;;;;;;OAUG;IACH,OAAO,CAAC,4BAA4B;IA8CpC;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAqBrB,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAiBlD;;;;;;;;;OASG;IACU,wBAAwB,CACpC,uBAAuB,CAAC,EAAE,WAAW,GACnC,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAiFrC;AAkBD;;GAEG;AACH,eAAO,MAAM,UAAU,SAAU,MAAM,gCACL,CAAC;AAEnC,eAAO,MAAM,gBAAgB,cACjB,MAAM,EAAE,wCAE2C,CAAC"}
@@ -354,7 +354,7 @@ export class BlobManager extends TypedEventEmitter {
354
354
  }
355
355
  return this.sendBlobAttachOp(localId, blobId);
356
356
  }
357
- processBlobAttachOp(message, local) {
357
+ processBlobAttachMessage(message, local) {
358
358
  const localId = message.metadata?.localId;
359
359
  const blobId = message.metadata?.blobId;
360
360
  if (localId) {
@@ -1 +1 @@
1
- {"version":3,"file":"blobManager.js","sourceRoot":"","sources":["../../src/blobManager/blobManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,iBAAiB,EACjB,cAAc,EACd,cAAc,GACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,WAAW,EAA2B,MAAM,uCAAuC,CAAC;AAS7F,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAMvE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAMtF,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,GACnB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACN,YAAY,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AAC;AAExF;;GAEG;AACH,MAAM,uBAAuB,GAAG,CAAC,QAAgB,EAAE,EAAE;IACpD,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,4BAA4B,CAAC,CAAC;IACxE,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;AACrB,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAsD,EAAE,CAC9F,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAEnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC/B,SAAmB,EACqC,EAAE,CAC1D,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,mBAAmB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tTypedEventEmitter,\n\tbufferToString,\n\tstringToBuffer,\n} from \"@fluid-internal/client-utils\";\nimport { AttachState, ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport {\n\tIContainerRuntime,\n\tIContainerRuntimeEvents,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport {\n\tIFluidHandleContext,\n\ttype IFluidHandleInternal,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDocumentStorageService,\n\tICreateBlobResponse,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { canRetryOnError, runWithRetry } from \"@fluidframework/driver-utils/internal\";\nimport {\n\tIGarbageCollectionData,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tFluidHandleBase,\n\tcreateResponseError,\n\tgenerateHandleContextPath,\n\tresponseToException,\n} from \"@fluidframework/runtime-utils/internal\";\nimport {\n\tGenericError,\n\tLoggingError,\n\tMonitoringContext,\n\tPerformanceEvent,\n\tcreateChildMonitoringContext,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { IBlobMetadata } from \"../metadata.js\";\n\nimport {\n\tgetStorageIds,\n\tsummarizeBlobManagerState,\n\ttoRedirectTable,\n\ttype IBlobManagerLoadInfo,\n} from \"./blobManagerSnapSum.js\";\n\n/**\n * This class represents blob (long string)\n * This object is used only when creating (writing) new blob and serialization purposes.\n * De-serialization process goes through FluidObjectHandle and request flow:\n * DataObject.request() recognizes requests in the form of `/blobs/<id>`\n * and loads blob.\n */\nexport class BlobHandle extends FluidHandleBase<ArrayBufferLike> {\n\tprivate attached: boolean = false;\n\n\tpublic get isAttached(): boolean {\n\t\treturn this.routeContext.isAttached && this.attached;\n\t}\n\n\tpublic readonly absolutePath: string;\n\n\tconstructor(\n\t\tpublic readonly path: string,\n\t\tpublic readonly routeContext: IFluidHandleContext,\n\t\tpublic get: () => Promise<ArrayBufferLike>,\n\t\tprivate readonly onAttachGraph?: () => void,\n\t) {\n\t\tsuper();\n\t\tthis.absolutePath = generateHandleContextPath(path, this.routeContext);\n\t}\n\n\tpublic attachGraph() {\n\t\tif (!this.attached) {\n\t\t\tthis.attached = true;\n\t\t\tthis.onAttachGraph?.();\n\t\t}\n\t}\n\n\tpublic bind(handle: IFluidHandleInternal) {\n\t\tthrow new Error(\"Cannot bind to blob handle\");\n\t}\n}\n\n// Restrict the IContainerRuntime interface to the subset required by BlobManager. This helps to make\n// the contract explicit and reduces the amount of mocking required for tests.\nexport type IBlobManagerRuntime = Pick<\n\tIContainerRuntime,\n\t\"attachState\" | \"connected\" | \"baseLogger\" | \"clientDetails\"\n> &\n\tTypedEventEmitter<IContainerRuntimeEvents>;\n\ntype ICreateBlobResponseWithTTL = ICreateBlobResponse &\n\tPartial<Record<\"minTTLInSeconds\", number>>;\n\ninterface PendingBlob {\n\tblob: ArrayBufferLike;\n\topsent?: boolean;\n\tstorageId?: string;\n\thandleP: Deferred<BlobHandle>;\n\tuploadP?: Promise<ICreateBlobResponse | void>;\n\tuploadTime?: number;\n\tminTTLInSeconds?: number;\n\tattached?: boolean;\n\tacked?: boolean;\n\tabortSignal?: AbortSignal;\n\tstashedUpload?: boolean;\n}\n\nexport interface IPendingBlobs {\n\t[id: string]: {\n\t\tblob: string;\n\t\tstorageId?: string;\n\t\tuploadTime?: number;\n\t\tminTTLInSeconds?: number;\n\t\tacked?: boolean;\n\t};\n}\n\nexport interface IBlobManagerEvents {\n\t(event: \"noPendingBlobs\", listener: () => void);\n}\n\nconst stashedPendingBlobOverrides: Pick<\n\tPendingBlob,\n\t\"stashedUpload\" | \"storageId\" | \"minTTLInSeconds\" | \"uploadTime\"\n> = {\n\tstashedUpload: true,\n\tstorageId: undefined,\n\tminTTLInSeconds: undefined,\n\tuploadTime: undefined,\n} as const;\n\nexport const blobManagerBasePath = \"_blobs\" as const;\n\nexport class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {\n\tprivate readonly mc: MonitoringContext;\n\n\t/**\n\t * Map of local IDs to storage IDs. Contains identity entries (id → id) for storage IDs. All requested IDs should\n\t * be a key in this map. Blobs created while the container is detached are stored in IDetachedBlobStorage which\n\t * gives local IDs; the storage IDs are filled in at attach time.\n\t * Note: It contains mappings from all clients, i.e., from remote clients as well. local ID comes from the client\n\t * that uploaded the blob but its mapping to storage ID is needed in all clients in order to retrieve the blob.\n\t */\n\tprivate readonly redirectTable: Map<string, string | undefined>;\n\n\t/**\n\t * Blobs which we have not yet seen a BlobAttach op round-trip and not yet attached to a DDS.\n\t */\n\tprivate readonly pendingBlobs: Map<string, PendingBlob> = new Map();\n\n\t/**\n\t * Track ops in flight for online flow. This is used for optimizations where if we receive an ack for a storage ID,\n\t * we can resolve all pending blobs with the same storage ID even though they may have different local IDs. That's\n\t * because we know that the server will not delete the blob corresponding to that storage ID.\n\t */\n\tprivate readonly opsInFlight: Map<string, string[]> = new Map();\n\n\tprivate readonly sendBlobAttachOp: (localId: string, storageId?: string) => void;\n\tprivate stopAttaching: boolean = false;\n\n\tprivate readonly routeContext: IFluidHandleContext;\n\tprivate readonly getStorage: () => IDocumentStorageService;\n\t// Called when a blob node is requested. blobPath is the path of the blob's node in GC's graph.\n\t// blobPath's format - `/<basePath>/<blobId>`.\n\tprivate readonly blobRequested: (blobPath: string) => void;\n\t// Called to check if a blob has been deleted by GC.\n\t// blobPath's format - `/<basePath>/<blobId>`.\n\tprivate readonly isBlobDeleted: (blobPath: string) => boolean;\n\tprivate readonly runtime: IBlobManagerRuntime;\n\tprivate readonly closeContainer: (error?: ICriticalContainerError) => void;\n\n\tconstructor(props: {\n\t\treadonly routeContext: IFluidHandleContext;\n\t\tsnapshot: IBlobManagerLoadInfo;\n\t\treadonly getStorage: () => IDocumentStorageService;\n\t\t/**\n\t\t * Submit a BlobAttach op. When a blob is uploaded, there is a short grace period before which the blob is\n\t\t * deleted. The BlobAttach op notifies the server that blob is in use. The server will then not delete the\n\t\t * the blob as long as it is listed as referenced in future summaries. The summarizing client will know to\n\t\t * include the storage ID in the summary when it sees the op.\n\t\t *\n\t\t * The op will also include a local ID to inform all clients of the relation to the storage ID, without\n\t\t * knowledge of which they cannot request the blob from storage. It's important that this op is sequenced\n\t\t * before any ops that reference the local ID, otherwise, an invalid handle could be added to the document.\n\t\t */\n\t\tsendBlobAttachOp: (localId: string, storageId?: string) => void;\n\t\t// Called when a blob node is requested. blobPath is the path of the blob's node in GC's graph.\n\t\t// blobPath's format - `/<basePath>/<blobId>`.\n\t\treadonly blobRequested: (blobPath: string) => void;\n\t\t// Called to check if a blob has been deleted by GC.\n\t\t// blobPath's format - `/<basePath>/<blobId>`.\n\t\treadonly isBlobDeleted: (blobPath: string) => boolean;\n\t\treadonly runtime: IBlobManagerRuntime;\n\t\tstashedBlobs: IPendingBlobs | undefined;\n\t\treadonly closeContainer: (error?: ICriticalContainerError) => void;\n\t}) {\n\t\tsuper();\n\t\tconst {\n\t\t\trouteContext,\n\t\t\tsnapshot,\n\t\t\tgetStorage,\n\t\t\tsendBlobAttachOp,\n\t\t\tblobRequested,\n\t\t\tisBlobDeleted,\n\t\t\truntime,\n\t\t\tstashedBlobs,\n\t\t\tcloseContainer,\n\t\t} = props;\n\t\tthis.routeContext = routeContext;\n\t\tthis.getStorage = getStorage;\n\t\tthis.blobRequested = blobRequested;\n\t\tthis.isBlobDeleted = isBlobDeleted;\n\t\tthis.runtime = runtime;\n\t\tthis.closeContainer = closeContainer;\n\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: this.runtime.baseLogger,\n\t\t\tnamespace: \"BlobManager\",\n\t\t});\n\n\t\tthis.redirectTable = toRedirectTable(snapshot, this.mc.logger, this.runtime.attachState);\n\n\t\t// Begin uploading stashed blobs from previous container instance\n\t\tObject.entries(stashedBlobs ?? {}).forEach(([localId, entry]) => {\n\t\t\tconst { acked, storageId, minTTLInSeconds, uploadTime } = entry;\n\t\t\tconst blob = stringToBuffer(entry.blob, \"base64\");\n\t\t\tconst pendingEntry: PendingBlob = {\n\t\t\t\tblob,\n\t\t\t\topsent: true,\n\t\t\t\thandleP: new Deferred(),\n\t\t\t\tstorageId,\n\t\t\t\tuploadP: undefined,\n\t\t\t\tuploadTime,\n\t\t\t\tminTTLInSeconds,\n\t\t\t\tattached: true,\n\t\t\t\tacked,\n\t\t\t};\n\t\t\tthis.pendingBlobs.set(localId, pendingEntry);\n\n\t\t\tif (storageId !== undefined && minTTLInSeconds && uploadTime) {\n\t\t\t\tconst timeLapseSinceLocalUpload = (Date.now() - uploadTime) / 1000;\n\t\t\t\t// stashed entries with more than half-life in storage will not be reuploaded\n\t\t\t\tif (minTTLInSeconds - timeLapseSinceLocalUpload > minTTLInSeconds / 2) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.pendingBlobs.set(localId, {\n\t\t\t\t...pendingEntry,\n\t\t\t\t...stashedPendingBlobOverrides,\n\t\t\t\tuploadP: this.uploadBlob(localId, blob),\n\t\t\t});\n\t\t});\n\n\t\tthis.sendBlobAttachOp = (localId: string, blobId?: string) => {\n\t\t\tconst pendingEntry = this.pendingBlobs.get(localId);\n\t\t\tassert(\n\t\t\t\tpendingEntry !== undefined,\n\t\t\t\t0x725 /* Must have pending blob entry for upcoming op */,\n\t\t\t);\n\t\t\tif (pendingEntry?.uploadTime && pendingEntry?.minTTLInSeconds) {\n\t\t\t\tconst secondsSinceUpload = (Date.now() - pendingEntry.uploadTime) / 1000;\n\t\t\t\tconst expired = pendingEntry.minTTLInSeconds - secondsSinceUpload < 0;\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"sendBlobAttach\",\n\t\t\t\t\tsecondsSinceUpload,\n\t\t\t\t\tminTTLInSeconds: pendingEntry.minTTLInSeconds,\n\t\t\t\t\texpired,\n\t\t\t\t});\n\t\t\t\tif (expired) {\n\t\t\t\t\t// we want to avoid submitting ops with broken handles\n\t\t\t\t\tthis.closeContainer(\n\t\t\t\t\t\tnew GenericError(\"Trying to submit a BlobAttach for expired blob\", undefined, {\n\t\t\t\t\t\t\tlocalId,\n\t\t\t\t\t\t\tblobId,\n\t\t\t\t\t\t\tsecondsSinceUpload,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tpendingEntry.opsent = true;\n\t\t\treturn sendBlobAttachOp(localId, blobId);\n\t\t};\n\t}\n\n\tpublic get allBlobsAttached(): boolean {\n\t\tfor (const [, entry] of this.pendingBlobs) {\n\t\t\tif (entry.attached === false) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic get hasPendingBlobs(): boolean {\n\t\treturn (\n\t\t\t(this.runtime.attachState !== AttachState.Attached && this.redirectTable.size > 0) ||\n\t\t\tthis.pendingBlobs.size > 0\n\t\t);\n\t}\n\n\tprivate createAbortError(pending?: PendingBlob) {\n\t\treturn new LoggingError(\"uploadBlob aborted\", {\n\t\t\tacked: pending?.acked,\n\t\t\tuploadTime: pending?.uploadTime,\n\t\t});\n\t}\n\n\tpublic hasPendingStashedUploads(): boolean {\n\t\treturn Array.from(this.pendingBlobs.values()).some((e) => e.stashedUpload === true);\n\t}\n\t/**\n\t * Upload blobs added while offline. This must be completed before connecting and resubmitting ops.\n\t */\n\tpublic async trackPendingStashedUploads(): Promise<void> {\n\t\tconst pendingUploads = Array.from(this.pendingBlobs.values())\n\t\t\t.filter((e) => e.stashedUpload === true)\n\t\t\t.map(async (e) => e.uploadP);\n\t\tif (pendingUploads.length === 0) {\n\t\t\treturn;\n\t\t}\n\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{\n\t\t\t\teventName: \"BlobUploadProcessStashedChanges\",\n\t\t\t\tcount: pendingUploads.length,\n\t\t\t},\n\t\t\tasync () => Promise.all(pendingUploads),\n\t\t\t{ start: true, end: true },\n\t\t);\n\t}\n\n\tpublic async getBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\t// Verify that the blob is not deleted, i.e., it has not been garbage collected. If it is, this will throw\n\t\t// an error, failing the call.\n\t\tthis.verifyBlobNotDeleted(blobId);\n\t\t// Let runtime know that the corresponding GC node was requested.\n\t\t// Note that this will throw if the blob is inactive or tombstoned and throwing on incorrect usage\n\t\t// is configured.\n\t\tthis.blobRequested(getGCNodePathFromBlobId(blobId));\n\n\t\tconst pending = this.pendingBlobs.get(blobId);\n\t\tif (pending) {\n\t\t\treturn pending.blob;\n\t\t}\n\n\t\tlet storageId: string;\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\tassert(this.redirectTable.has(blobId), 0x383 /* requesting unknown blobs */);\n\n\t\t\t// Blobs created while the container is detached are stored in IDetachedBlobStorage.\n\t\t\t// The 'IDocumentStorageService.readBlob()' call below will retrieve these via localId.\n\t\t\tstorageId = blobId;\n\t\t} else {\n\t\t\tconst attachedStorageId = this.redirectTable.get(blobId);\n\t\t\tassert(!!attachedStorageId, 0x11f /* \"requesting unknown blobs\" */);\n\t\t\tstorageId = attachedStorageId;\n\t\t}\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{ eventName: \"AttachmentReadBlob\", id: storageId },\n\t\t\tasync () => {\n\t\t\t\treturn this.getStorage().readBlob(storageId);\n\t\t\t},\n\t\t\t{ end: true, cancel: \"error\" },\n\t\t);\n\t}\n\n\tprivate getBlobHandle(id: string): BlobHandle {\n\t\tassert(\n\t\t\tthis.redirectTable.has(id) || this.pendingBlobs.has(id),\n\t\t\t0x384 /* requesting handle for unknown blob */,\n\t\t);\n\t\tconst pending = this.pendingBlobs.get(id);\n\t\t// Create a callback function for once the blob has been attached\n\t\tconst callback = pending\n\t\t\t? () => {\n\t\t\t\t\tpending.attached = true;\n\t\t\t\t\t// Notify listeners (e.g. serialization process) that blob has been attached\n\t\t\t\t\tthis.emit(\"blobAttached\", pending);\n\t\t\t\t\tthis.deletePendingBlobMaybe(id);\n\t\t\t\t}\n\t\t\t: undefined;\n\t\treturn new BlobHandle(\n\t\t\tgetGCNodePathFromBlobId(id),\n\t\t\tthis.routeContext,\n\t\t\tasync () => this.getBlob(id),\n\t\t\tcallback,\n\t\t);\n\t}\n\n\tprivate async createBlobDetached(\n\t\tblob: ArrayBufferLike,\n\t): Promise<IFluidHandleInternal<ArrayBufferLike>> {\n\t\t// Blobs created while the container is detached are stored in IDetachedBlobStorage.\n\t\t// The 'IDocumentStorageService.createBlob()' call below will respond with a localId.\n\t\tconst response = await this.getStorage().createBlob(blob);\n\t\tthis.setRedirection(response.id, undefined);\n\t\treturn this.getBlobHandle(response.id);\n\t}\n\n\tpublic async createBlob(\n\t\tblob: ArrayBufferLike,\n\t\tsignal?: AbortSignal,\n\t): Promise<IFluidHandleInternal<ArrayBufferLike>> {\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\treturn this.createBlobDetached(blob);\n\t\t}\n\t\tif (this.runtime.attachState === AttachState.Attaching) {\n\t\t\t// blob upload is not supported in \"Attaching\" state\n\t\t\tthis.mc.logger.sendTelemetryEvent({ eventName: \"CreateBlobWhileAttaching\" });\n\t\t\tawait new Promise<void>((resolve) => this.runtime.once(\"attached\", resolve));\n\t\t}\n\t\tassert(\n\t\t\tthis.runtime.attachState === AttachState.Attached,\n\t\t\t0x385 /* For clarity and paranoid defense against adding future attachment states */,\n\t\t);\n\n\t\tif (signal?.aborted) {\n\t\t\tthrow this.createAbortError();\n\t\t}\n\n\t\t// Create a local ID for the blob. After uploading it to storage and before returning it, a local ID to\n\t\t// storage ID mapping is created.\n\t\tconst localId = uuid();\n\t\tconst pendingEntry: PendingBlob = {\n\t\t\tblob,\n\t\t\thandleP: new Deferred(),\n\t\t\tuploadP: this.uploadBlob(localId, blob),\n\t\t\tattached: false,\n\t\t\tacked: false,\n\t\t\tabortSignal: signal,\n\t\t\topsent: false,\n\t\t};\n\t\tthis.pendingBlobs.set(localId, pendingEntry);\n\n\t\tconst abortListener = () => {\n\t\t\tif (!pendingEntry.acked) {\n\t\t\t\tpendingEntry.handleP.reject(this.createAbortError(pendingEntry));\n\t\t\t}\n\t\t};\n\t\tsignal?.addEventListener(\"abort\", abortListener, { once: true });\n\n\t\treturn pendingEntry.handleP.promise.finally(() => {\n\t\t\tsignal?.removeEventListener(\"abort\", abortListener);\n\t\t});\n\t}\n\n\tprivate async uploadBlob(\n\t\tlocalId: string,\n\t\tblob: ArrayBufferLike,\n\t): Promise<ICreateBlobResponse | void> {\n\t\treturn runWithRetry(\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\treturn await this.getStorage().createBlob(blob);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst entry = this.pendingBlobs.get(localId);\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!!entry,\n\t\t\t\t\t\t0x387 /* Must have pending blob entry for blob which failed to upload */,\n\t\t\t\t\t);\n\t\t\t\t\tif (entry.opsent && !canRetryOnError(error)) {\n\t\t\t\t\t\tthrow wrapError(\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t() => new LoggingError(`uploadBlob error`, { canRetry: true }),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"createBlob\",\n\t\t\tthis.mc.logger,\n\t\t\t{\n\t\t\t\tcancel: this.pendingBlobs.get(localId)?.abortSignal,\n\t\t\t},\n\t\t).then(\n\t\t\t(response) => this.onUploadResolve(localId, response),\n\t\t\t(error) => {\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"UploadBlobReject\",\n\t\t\t\t\terror,\n\t\t\t\t\tlocalId,\n\t\t\t\t});\n\t\t\t\t// it will only reject if we haven't sent an op\n\t\t\t\t// and is a non-retriable error. It will only reject\n\t\t\t\t// the promise but not throw any error outside.\n\t\t\t\tthis.pendingBlobs.get(localId)?.handleP.reject(error);\n\t\t\t\tthis.deletePendingBlob(localId);\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * Set up a mapping in the redirect table from fromId to toId. Also, notify the runtime that a reference is added\n\t * which is required for GC.\n\t */\n\tprivate setRedirection(fromId: string, toId: string | undefined) {\n\t\tthis.redirectTable.set(fromId, toId);\n\t}\n\n\tprivate deletePendingBlobMaybe(id: string) {\n\t\tif (this.pendingBlobs.has(id)) {\n\t\t\tconst entry = this.pendingBlobs.get(id);\n\t\t\tif (entry?.attached && entry?.acked) {\n\t\t\t\tthis.deletePendingBlob(id);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate deletePendingBlob(id: string) {\n\t\tif (this.pendingBlobs.delete(id) && !this.hasPendingBlobs) {\n\t\t\tthis.emit(\"noPendingBlobs\");\n\t\t}\n\t}\n\n\tprivate onUploadResolve(localId: string, response: ICreateBlobResponseWithTTL) {\n\t\tconst entry = this.pendingBlobs.get(localId);\n\t\tassert(entry !== undefined, 0x6c8 /* pending blob entry not found for uploaded blob */);\n\t\tif ((entry.abortSignal?.aborted === true && !entry.opsent) || this.stopAttaching) {\n\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"BlobAborted\",\n\t\t\t\tlocalId,\n\t\t\t});\n\t\t\tthis.deletePendingBlob(localId);\n\t\t\treturn;\n\t\t}\n\t\tassert(\n\t\t\tentry.storageId === undefined,\n\t\t\t0x386 /* Must have pending blob entry for uploaded blob */,\n\t\t);\n\t\tentry.stashedUpload = undefined;\n\t\tentry.storageId = response.id;\n\t\tentry.uploadTime = Date.now();\n\t\tentry.minTTLInSeconds = response.minTTLInSeconds;\n\t\t// Send a blob attach op. This serves two purposes:\n\t\t// 1. If its a new blob, i.e., it isn't de-duped, the server will keep the blob alive if it sees this op\n\t\t// until its storage ID is added to the next summary.\n\t\t// 2. It will create a local ID to storage ID mapping in all clients which is needed to retrieve the\n\t\t// blob from the server via the storage ID.\n\t\tif (!entry.opsent) {\n\t\t\tthis.sendBlobAttachOp(localId, response.id);\n\t\t}\n\t\tconst storageIds = getStorageIds(this.redirectTable, this.runtime.attachState);\n\t\tif (storageIds.has(response.id)) {\n\t\t\t// The blob is de-duped. Set up a local ID to storage ID mapping and return the blob. Since this is\n\t\t\t// an existing blob, we don't have to wait for the op to be ack'd since this step has already\n\t\t\t// happened before and so, the server won't delete it.\n\t\t\tthis.setRedirection(localId, response.id);\n\t\t\tentry.handleP.resolve(this.getBlobHandle(localId));\n\t\t\tthis.deletePendingBlobMaybe(localId);\n\t\t} else {\n\t\t\t// If there is already an op for this storage ID, append the local ID to the list. Once any op for\n\t\t\t// this storage ID is ack'd, all pending blobs for it can be resolved since the op will keep the\n\t\t\t// blob alive in storage.\n\t\t\tthis.opsInFlight.set(\n\t\t\t\tresponse.id,\n\t\t\t\t(this.opsInFlight.get(response.id) ?? []).concat(localId),\n\t\t\t);\n\t\t}\n\t\treturn response;\n\t}\n\n\t/**\n\t * Resubmit a BlobAttach op. Used to add storage IDs to ops that were\n\t * submitted to runtime while disconnected.\n\t * @param metadata - op metadata containing storage and/or local IDs\n\t */\n\tpublic reSubmit(metadata: Record<string, unknown> | undefined) {\n\t\tassert(!!metadata, 0x38b /* Resubmitted ops must have metadata */);\n\t\tconst { localId, blobId }: { localId?: string; blobId?: string } = metadata;\n\t\tassert(localId !== undefined, 0x50d /* local ID not available on reSubmit */);\n\t\tconst pendingEntry = this.pendingBlobs.get(localId);\n\n\t\tif (!blobId) {\n\t\t\t// We submitted this op while offline. The blob should have been uploaded by now.\n\t\t\tassert(\n\t\t\t\tpendingEntry?.opsent === true && !!pendingEntry?.storageId,\n\t\t\t\t0x38d /* blob must be uploaded before resubmitting BlobAttach op */,\n\t\t\t);\n\t\t\treturn this.sendBlobAttachOp(localId, pendingEntry?.storageId);\n\t\t}\n\t\treturn this.sendBlobAttachOp(localId, blobId);\n\t}\n\n\tpublic processBlobAttachOp(message: ISequencedDocumentMessage, local: boolean) {\n\t\tconst localId = (message.metadata as IBlobMetadata | undefined)?.localId;\n\t\tconst blobId = (message.metadata as IBlobMetadata | undefined)?.blobId;\n\n\t\tif (localId) {\n\t\t\tconst pendingEntry = this.pendingBlobs.get(localId);\n\t\t\tif (pendingEntry?.abortSignal?.aborted) {\n\t\t\t\tthis.deletePendingBlob(localId);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tassert(blobId !== undefined, 0x12a /* \"Missing blob id on metadata\" */);\n\n\t\t// Set up a mapping from local ID to storage ID. This is crucial since without this the blob cannot be\n\t\t// requested from the server.\n\t\t// Note: The check for undefined is needed for back-compat when localId was not part of the BlobAttach op that\n\t\t// was sent when online.\n\t\tif (localId !== undefined) {\n\t\t\tthis.setRedirection(localId, blobId);\n\t\t}\n\t\t// set identity (id -> id) entry\n\t\tthis.setRedirection(blobId, blobId);\n\n\t\tif (local) {\n\t\t\tassert(localId !== undefined, 0x50e /* local ID not present in blob attach message */);\n\t\t\tconst waitingBlobs = this.opsInFlight.get(blobId);\n\t\t\tif (waitingBlobs !== undefined) {\n\t\t\t\t// For each op corresponding to this storage ID that we are waiting for, resolve the pending blob.\n\t\t\t\t// This is safe because the server will keep the blob alive and the op containing the local ID to\n\t\t\t\t// storage ID is already in flight and any op containing this local ID will be sequenced after that.\n\t\t\t\twaitingBlobs.forEach((pendingLocalId) => {\n\t\t\t\t\tconst entry = this.pendingBlobs.get(pendingLocalId);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tentry !== undefined,\n\t\t\t\t\t\t0x38f /* local online BlobAttach op with no pending blob entry */,\n\t\t\t\t\t);\n\t\t\t\t\tthis.setRedirection(pendingLocalId, blobId);\n\t\t\t\t\tentry.acked = true;\n\t\t\t\t\tentry.handleP.resolve(this.getBlobHandle(pendingLocalId));\n\t\t\t\t\tthis.deletePendingBlobMaybe(pendingLocalId);\n\t\t\t\t});\n\t\t\t\tthis.opsInFlight.delete(blobId);\n\t\t\t}\n\t\t\tconst localEntry = this.pendingBlobs.get(localId);\n\t\t\tif (localEntry) {\n\t\t\t\tlocalEntry.acked = true;\n\t\t\t\tlocalEntry.handleP.resolve(this.getBlobHandle(localId));\n\t\t\t\tthis.deletePendingBlobMaybe(localId);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic summarize(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {\n\t\treturn summarizeBlobManagerState(this.redirectTable, this.runtime.attachState);\n\t}\n\n\t/**\n\t * Generates data used for garbage collection. Each blob uploaded represents a node in the GC graph as it can be\n\t * individually referenced by storing its handle in a referenced DDS. Returns the list of blob ids as GC nodes.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data. BlobManager doesn't care\n\t * about this for now because the data is a simple list of blob ids.\n\t */\n\tpublic getGCData(fullGC: boolean = false): IGarbageCollectionData {\n\t\tconst gcData: IGarbageCollectionData = { gcNodes: {} };\n\t\tfor (const [localId, storageId] of this.redirectTable) {\n\t\t\tassert(!!storageId, 0x390 /* Must be attached to get GC data */);\n\t\t\t// Only return local ids as GC nodes because a blob can only be referenced via its local id. The storage\n\t\t\t// id entries have the same key and value, ignore them.\n\t\t\t// The outbound routes are empty because a blob node cannot reference other nodes. It can only be referenced\n\t\t\t// by adding its handle to a referenced DDS.\n\t\t\tif (localId !== storageId) {\n\t\t\t\tgcData.gcNodes[getGCNodePathFromBlobId(localId)] = [];\n\t\t\t}\n\t\t}\n\t\treturn gcData;\n\t}\n\n\t/**\n\t * Delete attachment blobs that are sweep ready.\n\t * @param sweepReadyBlobRoutes - The routes of blobs that are sweep ready and should be deleted. These routes will\n\t * be based off of local ids.\n\t * @returns The routes of blobs that were deleted.\n\t */\n\tpublic deleteSweepReadyNodes(sweepReadyBlobRoutes: readonly string[]): readonly string[] {\n\t\tthis.deleteBlobsFromRedirectTable(sweepReadyBlobRoutes);\n\t\treturn Array.from(sweepReadyBlobRoutes);\n\t}\n\n\t/**\n\t * Delete blobs with the given routes from the redirect table.\n\t * The routes are GC nodes paths of format -`/<blobManagerBasePath>/<blobId>`. The blob ids are all local ids.\n\t * Deleting the blobs involves 2 steps:\n\t * 1. The redirect table entry for the local ids are deleted.\n\t * 2. If the storage ids corresponding to the deleted local ids are not in-use anymore, the redirect table entries\n\t * for the storage ids are deleted as well.\n\t *\n\t * Note that this does not delete the blobs from storage service immediately. Deleting the blobs from redirect table\n\t * will remove them the next summary. The service would them delete them some time in the future.\n\t */\n\tprivate deleteBlobsFromRedirectTable(blobRoutes: readonly string[]) {\n\t\tif (blobRoutes.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\t// This tracks the storage ids of local ids that are deleted. After the local ids have been deleted, if any of\n\t\t// these storage ids are unused, they will be deleted as well.\n\t\tconst maybeUnusedStorageIds: Set<string> = new Set();\n\t\tfor (const route of blobRoutes) {\n\t\t\tconst blobId = getBlobIdFromGCNodePath(route);\n\t\t\t// If the blob hasn't already been deleted, log an error because this should never happen.\n\t\t\t// If the blob has already been deleted, log a telemetry event. This can happen because multiple GC\n\t\t\t// sweep ops can contain the same data store. It would be interesting to track how often this happens.\n\t\t\tconst alreadyDeleted = this.isBlobDeleted(route);\n\t\t\tif (!this.redirectTable.has(blobId)) {\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"DeletedAttachmentBlobNotFound\",\n\t\t\t\t\tcategory: alreadyDeleted ? \"generic\" : \"error\",\n\t\t\t\t\tblobId,\n\t\t\t\t\tdetails: { alreadyDeleted },\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst storageId = this.redirectTable.get(blobId);\n\t\t\tassert(!!storageId, 0x5bb /* Must be attached to run GC */);\n\t\t\tmaybeUnusedStorageIds.add(storageId);\n\t\t\tthis.redirectTable.delete(blobId);\n\t\t}\n\n\t\t// Find out storage ids that are in-use and remove them from maybeUnusedStorageIds. A storage id is in-use if\n\t\t// the redirect table has a local id -> storage id entry for it.\n\t\tfor (const [localId, storageId] of this.redirectTable.entries()) {\n\t\t\tassert(!!storageId, 0x5bc /* Must be attached to run GC */);\n\t\t\t// For every storage id, the redirect table has a id -> id entry. These do not make the storage id in-use.\n\t\t\tif (maybeUnusedStorageIds.has(storageId) && localId !== storageId) {\n\t\t\t\tmaybeUnusedStorageIds.delete(storageId);\n\t\t\t}\n\t\t}\n\n\t\t// For unused storage ids, delete their id -> id entries from the redirect table.\n\t\t// This way they'll be absent from the next summary, and the service is free to delete them from storage.\n\t\tfor (const storageId of maybeUnusedStorageIds) {\n\t\t\tthis.redirectTable.delete(storageId);\n\t\t}\n\t}\n\n\t/**\n\t * Verifies that the blob with given id is not deleted, i.e., it has not been garbage collected. If the blob is GC'd,\n\t * log an error and throw if necessary.\n\t */\n\tprivate verifyBlobNotDeleted(blobId: string) {\n\t\tif (!this.isBlobDeleted(getGCNodePathFromBlobId(blobId))) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst request = { url: blobId };\n\t\tconst error = responseToException(\n\t\t\tcreateResponseError(404, `Blob was deleted`, request),\n\t\t\trequest,\n\t\t);\n\t\t// Only log deleted events. Tombstone events are logged by garbage collector.\n\t\tthis.mc.logger.sendErrorEvent(\n\t\t\t{\n\t\t\t\teventName: \"GC_Deleted_Blob_Requested\",\n\t\t\t\tpkg: blobManagerBasePath,\n\t\t\t},\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n\n\tpublic setRedirectTable(table: Map<string, string>) {\n\t\tassert(\n\t\t\tthis.runtime.attachState === AttachState.Detached,\n\t\t\t0x252 /* \"redirect table can only be set in detached container\" */,\n\t\t);\n\t\tassert(\n\t\t\tthis.redirectTable.size === table.size,\n\t\t\t0x391 /* Redirect table size must match BlobManager's local ID count */,\n\t\t);\n\t\tfor (const [localId, storageId] of table) {\n\t\t\tassert(this.redirectTable.has(localId), 0x254 /* \"unrecognized id in redirect table\" */);\n\t\t\tthis.setRedirection(localId, storageId);\n\t\t\t// set identity (id -> id) entry\n\t\t\tthis.setRedirection(storageId, storageId);\n\t\t}\n\t}\n\n\t/**\n\t * Part of container serialization when imminent closure is enabled (Currently when calling closeAndGetPendingLocalState).\n\t * This asynchronous function resolves all pending createBlob calls and waits for each blob\n\t * to be attached. It will also send BlobAttach ops for each pending blob that hasn't sent it\n\t * yet so that serialized container can resubmit them when rehydrated.\n\t *\n\t * @param stopBlobAttachingSignal - Optional signal to abort the blob attaching process.\n\t * @returns - A promise that resolves with the details of the attached blobs,\n\t * or undefined if no blobs were processed.\n\t */\n\tpublic async attachAndGetPendingBlobs(\n\t\tstopBlobAttachingSignal?: AbortSignal,\n\t): Promise<IPendingBlobs | undefined> {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{ eventName: \"GetPendingBlobs\" },\n\t\t\tasync () => {\n\t\t\t\tif (this.pendingBlobs.size === 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst blobs = {};\n\t\t\t\tconst localBlobs = new Set<PendingBlob>();\n\t\t\t\t// This while is used to stash blobs created while attaching and getting blobs\n\t\t\t\twhile (localBlobs.size < this.pendingBlobs.size) {\n\t\t\t\t\tconst attachBlobsP: Promise<void>[] = [];\n\t\t\t\t\tfor (const [id, entry] of this.pendingBlobs) {\n\t\t\t\t\t\tif (!localBlobs.has(entry)) {\n\t\t\t\t\t\t\tlocalBlobs.add(entry);\n\t\t\t\t\t\t\t// In order to follow natural blob creation flow we need to:\n\t\t\t\t\t\t\t// 1 send the blob attach op\n\t\t\t\t\t\t\t// 2 resolve the blob handle\n\t\t\t\t\t\t\t// 3 wait for op referencing the blob\n\t\t\t\t\t\t\tif (!entry.opsent) {\n\t\t\t\t\t\t\t\tthis.sendBlobAttachOp(id, entry.storageId);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Resolving the blob handle to let hosts continue with their operations (it will resolve\n\t\t\t\t\t\t\t// original createBlob call) and let them attach the blob. This is a lie we told since the upload\n\t\t\t\t\t\t\t// hasn't finished yet, but it's fine since we will retry on rehydration.\n\t\t\t\t\t\t\tentry.handleP.resolve(this.getBlobHandle(id));\n\t\t\t\t\t\t\t// Array of promises that will resolve when blobs get attached.\n\t\t\t\t\t\t\tattachBlobsP.push(\n\t\t\t\t\t\t\t\tnew Promise<void>((resolve, reject) => {\n\t\t\t\t\t\t\t\t\tstopBlobAttachingSignal?.addEventListener(\n\t\t\t\t\t\t\t\t\t\t\"abort\",\n\t\t\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\t\t\tthis.stopAttaching = true;\n\t\t\t\t\t\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t{ once: true },\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst onBlobAttached = (attachedEntry) => {\n\t\t\t\t\t\t\t\t\t\tif (attachedEntry === entry) {\n\t\t\t\t\t\t\t\t\t\t\tthis.off(\"blobAttached\", onBlobAttached);\n\t\t\t\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tif (!entry.attached) {\n\t\t\t\t\t\t\t\t\t\tthis.on(\"blobAttached\", onBlobAttached);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Wait for all blobs to be attached. This is important, otherwise serialized container\n\t\t\t\t\t// could send the blobAttach op without any op that references the blob, making it useless.\n\t\t\t\t\tawait Promise.allSettled(attachBlobsP).catch(() => {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tfor (const [id, entry] of this.pendingBlobs) {\n\t\t\t\t\tif (stopBlobAttachingSignal?.aborted && !entry.attached) {\n\t\t\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\t\t\teventName: \"UnableToStashBlob\",\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tassert(entry.attached === true, 0x790 /* stashed blob should be attached */);\n\t\t\t\t\tblobs[id] = {\n\t\t\t\t\t\tblob: bufferToString(entry.blob, \"base64\"),\n\t\t\t\t\t\tstorageId: entry.storageId,\n\t\t\t\t\t\tacked: entry.acked,\n\t\t\t\t\t\tminTTLInSeconds: entry.minTTLInSeconds,\n\t\t\t\t\t\tuploadTime: entry.uploadTime,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn Object.keys(blobs).length > 0 ? blobs : undefined;\n\t\t\t},\n\t\t);\n\t}\n}\n\n/**\n * For a blobId, returns its path in GC's graph. The node path is of the format `/<blobManagerBasePath>/<blobId>`.\n * This path must match the path of the blob handle returned by the createBlob API because blobs are marked\n * referenced by storing these handles in a referenced DDS.\n */\nconst getGCNodePathFromBlobId = (blobId: string) => `/${blobManagerBasePath}/${blobId}`;\n\n/**\n * For a given GC node path, return the blobId. The node path is of the format `/<basePath>/<blobId>`.\n */\nconst getBlobIdFromGCNodePath = (nodePath: string) => {\n\tconst pathParts = nodePath.split(\"/\");\n\tassert(areBlobPathParts(pathParts), 0x5bd /* Invalid blob node path */);\n\treturn pathParts[2];\n};\n\n/**\n * Returns whether a given path is for attachment blobs that are in the format - \"/blobManagerBasePath/...\".\n */\nexport const isBlobPath = (path: string): path is `/${typeof blobManagerBasePath}/${string}` =>\n\tareBlobPathParts(path.split(\"/\"));\n\nexport const areBlobPathParts = (\n\tpathParts: string[],\n): pathParts is [\"\", typeof blobManagerBasePath, string] =>\n\tpathParts.length === 3 && pathParts[1] === blobManagerBasePath;\n"]}
1
+ {"version":3,"file":"blobManager.js","sourceRoot":"","sources":["../../src/blobManager/blobManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,iBAAiB,EACjB,cAAc,EACd,cAAc,GACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,WAAW,EAA2B,MAAM,uCAAuC,CAAC;AAS7F,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAKvE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAOtF,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,GACnB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACN,YAAY,EACZ,YAAY,EAEZ,gBAAgB,EAChB,4BAA4B,EAC5B,SAAS,GACT,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAIlC,OAAO,EACN,aAAa,EACb,yBAAyB,EACzB,eAAe,GAEf,MAAM,yBAAyB,CAAC;AAEjC;;;;;;GAMG;AACH,MAAM,OAAO,UAAW,SAAQ,eAAgC;IAG/D,IAAW,UAAU;QACpB,OAAO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AAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAsD,EAAE,CAC9F,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAEnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC/B,SAAmB,EACqC,EAAE,CAC1D,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,mBAAmB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tTypedEventEmitter,\n\tbufferToString,\n\tstringToBuffer,\n} from \"@fluid-internal/client-utils\";\nimport { AttachState, ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport {\n\tIContainerRuntime,\n\tIContainerRuntimeEvents,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport {\n\tIFluidHandleContext,\n\ttype IFluidHandleInternal,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDocumentStorageService,\n\tICreateBlobResponse,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { canRetryOnError, runWithRetry } from \"@fluidframework/driver-utils/internal\";\nimport {\n\tIGarbageCollectionData,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\ttype ISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tFluidHandleBase,\n\tcreateResponseError,\n\tgenerateHandleContextPath,\n\tresponseToException,\n} from \"@fluidframework/runtime-utils/internal\";\nimport {\n\tGenericError,\n\tLoggingError,\n\tMonitoringContext,\n\tPerformanceEvent,\n\tcreateChildMonitoringContext,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { IBlobMetadata } from \"../metadata.js\";\n\nimport {\n\tgetStorageIds,\n\tsummarizeBlobManagerState,\n\ttoRedirectTable,\n\ttype IBlobManagerLoadInfo,\n} from \"./blobManagerSnapSum.js\";\n\n/**\n * This class represents blob (long string)\n * This object is used only when creating (writing) new blob and serialization purposes.\n * De-serialization process goes through FluidObjectHandle and request flow:\n * DataObject.request() recognizes requests in the form of `/blobs/<id>`\n * and loads blob.\n */\nexport class BlobHandle extends FluidHandleBase<ArrayBufferLike> {\n\tprivate attached: boolean = false;\n\n\tpublic get isAttached(): boolean {\n\t\treturn this.routeContext.isAttached && this.attached;\n\t}\n\n\tpublic readonly absolutePath: string;\n\n\tconstructor(\n\t\tpublic readonly path: string,\n\t\tpublic readonly routeContext: IFluidHandleContext,\n\t\tpublic get: () => Promise<ArrayBufferLike>,\n\t\tprivate readonly onAttachGraph?: () => void,\n\t) {\n\t\tsuper();\n\t\tthis.absolutePath = generateHandleContextPath(path, this.routeContext);\n\t}\n\n\tpublic attachGraph() {\n\t\tif (!this.attached) {\n\t\t\tthis.attached = true;\n\t\t\tthis.onAttachGraph?.();\n\t\t}\n\t}\n\n\tpublic bind(handle: IFluidHandleInternal) {\n\t\tthrow new Error(\"Cannot bind to blob handle\");\n\t}\n}\n\n// Restrict the IContainerRuntime interface to the subset required by BlobManager. This helps to make\n// the contract explicit and reduces the amount of mocking required for tests.\nexport type IBlobManagerRuntime = Pick<\n\tIContainerRuntime,\n\t\"attachState\" | \"connected\" | \"baseLogger\" | \"clientDetails\"\n> &\n\tTypedEventEmitter<IContainerRuntimeEvents>;\n\ntype ICreateBlobResponseWithTTL = ICreateBlobResponse &\n\tPartial<Record<\"minTTLInSeconds\", number>>;\n\ninterface PendingBlob {\n\tblob: ArrayBufferLike;\n\topsent?: boolean;\n\tstorageId?: string;\n\thandleP: Deferred<BlobHandle>;\n\tuploadP?: Promise<ICreateBlobResponse | void>;\n\tuploadTime?: number;\n\tminTTLInSeconds?: number;\n\tattached?: boolean;\n\tacked?: boolean;\n\tabortSignal?: AbortSignal;\n\tstashedUpload?: boolean;\n}\n\nexport interface IPendingBlobs {\n\t[id: string]: {\n\t\tblob: string;\n\t\tstorageId?: string;\n\t\tuploadTime?: number;\n\t\tminTTLInSeconds?: number;\n\t\tacked?: boolean;\n\t};\n}\n\nexport interface IBlobManagerEvents {\n\t(event: \"noPendingBlobs\", listener: () => void);\n}\n\nconst stashedPendingBlobOverrides: Pick<\n\tPendingBlob,\n\t\"stashedUpload\" | \"storageId\" | \"minTTLInSeconds\" | \"uploadTime\"\n> = {\n\tstashedUpload: true,\n\tstorageId: undefined,\n\tminTTLInSeconds: undefined,\n\tuploadTime: undefined,\n} as const;\n\nexport const blobManagerBasePath = \"_blobs\" as const;\n\nexport class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {\n\tprivate readonly mc: MonitoringContext;\n\n\t/**\n\t * Map of local IDs to storage IDs. Contains identity entries (id → id) for storage IDs. All requested IDs should\n\t * be a key in this map. Blobs created while the container is detached are stored in IDetachedBlobStorage which\n\t * gives local IDs; the storage IDs are filled in at attach time.\n\t * Note: It contains mappings from all clients, i.e., from remote clients as well. local ID comes from the client\n\t * that uploaded the blob but its mapping to storage ID is needed in all clients in order to retrieve the blob.\n\t */\n\tprivate readonly redirectTable: Map<string, string | undefined>;\n\n\t/**\n\t * Blobs which we have not yet seen a BlobAttach op round-trip and not yet attached to a DDS.\n\t */\n\tprivate readonly pendingBlobs: Map<string, PendingBlob> = new Map();\n\n\t/**\n\t * Track ops in flight for online flow. This is used for optimizations where if we receive an ack for a storage ID,\n\t * we can resolve all pending blobs with the same storage ID even though they may have different local IDs. That's\n\t * because we know that the server will not delete the blob corresponding to that storage ID.\n\t */\n\tprivate readonly opsInFlight: Map<string, string[]> = new Map();\n\n\tprivate readonly sendBlobAttachOp: (localId: string, storageId?: string) => void;\n\tprivate stopAttaching: boolean = false;\n\n\tprivate readonly routeContext: IFluidHandleContext;\n\tprivate readonly getStorage: () => IDocumentStorageService;\n\t// Called when a blob node is requested. blobPath is the path of the blob's node in GC's graph.\n\t// blobPath's format - `/<basePath>/<blobId>`.\n\tprivate readonly blobRequested: (blobPath: string) => void;\n\t// Called to check if a blob has been deleted by GC.\n\t// blobPath's format - `/<basePath>/<blobId>`.\n\tprivate readonly isBlobDeleted: (blobPath: string) => boolean;\n\tprivate readonly runtime: IBlobManagerRuntime;\n\tprivate readonly closeContainer: (error?: ICriticalContainerError) => void;\n\n\tconstructor(props: {\n\t\treadonly routeContext: IFluidHandleContext;\n\t\tsnapshot: IBlobManagerLoadInfo;\n\t\treadonly getStorage: () => IDocumentStorageService;\n\t\t/**\n\t\t * Submit a BlobAttach op. When a blob is uploaded, there is a short grace period before which the blob is\n\t\t * deleted. The BlobAttach op notifies the server that blob is in use. The server will then not delete the\n\t\t * the blob as long as it is listed as referenced in future summaries. The summarizing client will know to\n\t\t * include the storage ID in the summary when it sees the op.\n\t\t *\n\t\t * The op will also include a local ID to inform all clients of the relation to the storage ID, without\n\t\t * knowledge of which they cannot request the blob from storage. It's important that this op is sequenced\n\t\t * before any ops that reference the local ID, otherwise, an invalid handle could be added to the document.\n\t\t */\n\t\tsendBlobAttachOp: (localId: string, storageId?: string) => void;\n\t\t// Called when a blob node is requested. blobPath is the path of the blob's node in GC's graph.\n\t\t// blobPath's format - `/<basePath>/<blobId>`.\n\t\treadonly blobRequested: (blobPath: string) => void;\n\t\t// Called to check if a blob has been deleted by GC.\n\t\t// blobPath's format - `/<basePath>/<blobId>`.\n\t\treadonly isBlobDeleted: (blobPath: string) => boolean;\n\t\treadonly runtime: IBlobManagerRuntime;\n\t\tstashedBlobs: IPendingBlobs | undefined;\n\t\treadonly closeContainer: (error?: ICriticalContainerError) => void;\n\t}) {\n\t\tsuper();\n\t\tconst {\n\t\t\trouteContext,\n\t\t\tsnapshot,\n\t\t\tgetStorage,\n\t\t\tsendBlobAttachOp,\n\t\t\tblobRequested,\n\t\t\tisBlobDeleted,\n\t\t\truntime,\n\t\t\tstashedBlobs,\n\t\t\tcloseContainer,\n\t\t} = props;\n\t\tthis.routeContext = routeContext;\n\t\tthis.getStorage = getStorage;\n\t\tthis.blobRequested = blobRequested;\n\t\tthis.isBlobDeleted = isBlobDeleted;\n\t\tthis.runtime = runtime;\n\t\tthis.closeContainer = closeContainer;\n\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: this.runtime.baseLogger,\n\t\t\tnamespace: \"BlobManager\",\n\t\t});\n\n\t\tthis.redirectTable = toRedirectTable(snapshot, this.mc.logger, this.runtime.attachState);\n\n\t\t// Begin uploading stashed blobs from previous container instance\n\t\tObject.entries(stashedBlobs ?? {}).forEach(([localId, entry]) => {\n\t\t\tconst { acked, storageId, minTTLInSeconds, uploadTime } = entry;\n\t\t\tconst blob = stringToBuffer(entry.blob, \"base64\");\n\t\t\tconst pendingEntry: PendingBlob = {\n\t\t\t\tblob,\n\t\t\t\topsent: true,\n\t\t\t\thandleP: new Deferred(),\n\t\t\t\tstorageId,\n\t\t\t\tuploadP: undefined,\n\t\t\t\tuploadTime,\n\t\t\t\tminTTLInSeconds,\n\t\t\t\tattached: true,\n\t\t\t\tacked,\n\t\t\t};\n\t\t\tthis.pendingBlobs.set(localId, pendingEntry);\n\n\t\t\tif (storageId !== undefined && minTTLInSeconds && uploadTime) {\n\t\t\t\tconst timeLapseSinceLocalUpload = (Date.now() - uploadTime) / 1000;\n\t\t\t\t// stashed entries with more than half-life in storage will not be reuploaded\n\t\t\t\tif (minTTLInSeconds - timeLapseSinceLocalUpload > minTTLInSeconds / 2) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.pendingBlobs.set(localId, {\n\t\t\t\t...pendingEntry,\n\t\t\t\t...stashedPendingBlobOverrides,\n\t\t\t\tuploadP: this.uploadBlob(localId, blob),\n\t\t\t});\n\t\t});\n\n\t\tthis.sendBlobAttachOp = (localId: string, blobId?: string) => {\n\t\t\tconst pendingEntry = this.pendingBlobs.get(localId);\n\t\t\tassert(\n\t\t\t\tpendingEntry !== undefined,\n\t\t\t\t0x725 /* Must have pending blob entry for upcoming op */,\n\t\t\t);\n\t\t\tif (pendingEntry?.uploadTime && pendingEntry?.minTTLInSeconds) {\n\t\t\t\tconst secondsSinceUpload = (Date.now() - pendingEntry.uploadTime) / 1000;\n\t\t\t\tconst expired = pendingEntry.minTTLInSeconds - secondsSinceUpload < 0;\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"sendBlobAttach\",\n\t\t\t\t\tsecondsSinceUpload,\n\t\t\t\t\tminTTLInSeconds: pendingEntry.minTTLInSeconds,\n\t\t\t\t\texpired,\n\t\t\t\t});\n\t\t\t\tif (expired) {\n\t\t\t\t\t// we want to avoid submitting ops with broken handles\n\t\t\t\t\tthis.closeContainer(\n\t\t\t\t\t\tnew GenericError(\"Trying to submit a BlobAttach for expired blob\", undefined, {\n\t\t\t\t\t\t\tlocalId,\n\t\t\t\t\t\t\tblobId,\n\t\t\t\t\t\t\tsecondsSinceUpload,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tpendingEntry.opsent = true;\n\t\t\treturn sendBlobAttachOp(localId, blobId);\n\t\t};\n\t}\n\n\tpublic get allBlobsAttached(): boolean {\n\t\tfor (const [, entry] of this.pendingBlobs) {\n\t\t\tif (entry.attached === false) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tpublic get hasPendingBlobs(): boolean {\n\t\treturn (\n\t\t\t(this.runtime.attachState !== AttachState.Attached && this.redirectTable.size > 0) ||\n\t\t\tthis.pendingBlobs.size > 0\n\t\t);\n\t}\n\n\tprivate createAbortError(pending?: PendingBlob) {\n\t\treturn new LoggingError(\"uploadBlob aborted\", {\n\t\t\tacked: pending?.acked,\n\t\t\tuploadTime: pending?.uploadTime,\n\t\t});\n\t}\n\n\tpublic hasPendingStashedUploads(): boolean {\n\t\treturn Array.from(this.pendingBlobs.values()).some((e) => e.stashedUpload === true);\n\t}\n\t/**\n\t * Upload blobs added while offline. This must be completed before connecting and resubmitting ops.\n\t */\n\tpublic async trackPendingStashedUploads(): Promise<void> {\n\t\tconst pendingUploads = Array.from(this.pendingBlobs.values())\n\t\t\t.filter((e) => e.stashedUpload === true)\n\t\t\t.map(async (e) => e.uploadP);\n\t\tif (pendingUploads.length === 0) {\n\t\t\treturn;\n\t\t}\n\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{\n\t\t\t\teventName: \"BlobUploadProcessStashedChanges\",\n\t\t\t\tcount: pendingUploads.length,\n\t\t\t},\n\t\t\tasync () => Promise.all(pendingUploads),\n\t\t\t{ start: true, end: true },\n\t\t);\n\t}\n\n\tpublic async getBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\t// Verify that the blob is not deleted, i.e., it has not been garbage collected. If it is, this will throw\n\t\t// an error, failing the call.\n\t\tthis.verifyBlobNotDeleted(blobId);\n\t\t// Let runtime know that the corresponding GC node was requested.\n\t\t// Note that this will throw if the blob is inactive or tombstoned and throwing on incorrect usage\n\t\t// is configured.\n\t\tthis.blobRequested(getGCNodePathFromBlobId(blobId));\n\n\t\tconst pending = this.pendingBlobs.get(blobId);\n\t\tif (pending) {\n\t\t\treturn pending.blob;\n\t\t}\n\n\t\tlet storageId: string;\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\tassert(this.redirectTable.has(blobId), 0x383 /* requesting unknown blobs */);\n\n\t\t\t// Blobs created while the container is detached are stored in IDetachedBlobStorage.\n\t\t\t// The 'IDocumentStorageService.readBlob()' call below will retrieve these via localId.\n\t\t\tstorageId = blobId;\n\t\t} else {\n\t\t\tconst attachedStorageId = this.redirectTable.get(blobId);\n\t\t\tassert(!!attachedStorageId, 0x11f /* \"requesting unknown blobs\" */);\n\t\t\tstorageId = attachedStorageId;\n\t\t}\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{ eventName: \"AttachmentReadBlob\", id: storageId },\n\t\t\tasync () => {\n\t\t\t\treturn this.getStorage().readBlob(storageId);\n\t\t\t},\n\t\t\t{ end: true, cancel: \"error\" },\n\t\t);\n\t}\n\n\tprivate getBlobHandle(id: string): BlobHandle {\n\t\tassert(\n\t\t\tthis.redirectTable.has(id) || this.pendingBlobs.has(id),\n\t\t\t0x384 /* requesting handle for unknown blob */,\n\t\t);\n\t\tconst pending = this.pendingBlobs.get(id);\n\t\t// Create a callback function for once the blob has been attached\n\t\tconst callback = pending\n\t\t\t? () => {\n\t\t\t\t\tpending.attached = true;\n\t\t\t\t\t// Notify listeners (e.g. serialization process) that blob has been attached\n\t\t\t\t\tthis.emit(\"blobAttached\", pending);\n\t\t\t\t\tthis.deletePendingBlobMaybe(id);\n\t\t\t\t}\n\t\t\t: undefined;\n\t\treturn new BlobHandle(\n\t\t\tgetGCNodePathFromBlobId(id),\n\t\t\tthis.routeContext,\n\t\t\tasync () => this.getBlob(id),\n\t\t\tcallback,\n\t\t);\n\t}\n\n\tprivate async createBlobDetached(\n\t\tblob: ArrayBufferLike,\n\t): Promise<IFluidHandleInternal<ArrayBufferLike>> {\n\t\t// Blobs created while the container is detached are stored in IDetachedBlobStorage.\n\t\t// The 'IDocumentStorageService.createBlob()' call below will respond with a localId.\n\t\tconst response = await this.getStorage().createBlob(blob);\n\t\tthis.setRedirection(response.id, undefined);\n\t\treturn this.getBlobHandle(response.id);\n\t}\n\n\tpublic async createBlob(\n\t\tblob: ArrayBufferLike,\n\t\tsignal?: AbortSignal,\n\t): Promise<IFluidHandleInternal<ArrayBufferLike>> {\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\treturn this.createBlobDetached(blob);\n\t\t}\n\t\tif (this.runtime.attachState === AttachState.Attaching) {\n\t\t\t// blob upload is not supported in \"Attaching\" state\n\t\t\tthis.mc.logger.sendTelemetryEvent({ eventName: \"CreateBlobWhileAttaching\" });\n\t\t\tawait new Promise<void>((resolve) => this.runtime.once(\"attached\", resolve));\n\t\t}\n\t\tassert(\n\t\t\tthis.runtime.attachState === AttachState.Attached,\n\t\t\t0x385 /* For clarity and paranoid defense against adding future attachment states */,\n\t\t);\n\n\t\tif (signal?.aborted) {\n\t\t\tthrow this.createAbortError();\n\t\t}\n\n\t\t// Create a local ID for the blob. After uploading it to storage and before returning it, a local ID to\n\t\t// storage ID mapping is created.\n\t\tconst localId = uuid();\n\t\tconst pendingEntry: PendingBlob = {\n\t\t\tblob,\n\t\t\thandleP: new Deferred(),\n\t\t\tuploadP: this.uploadBlob(localId, blob),\n\t\t\tattached: false,\n\t\t\tacked: false,\n\t\t\tabortSignal: signal,\n\t\t\topsent: false,\n\t\t};\n\t\tthis.pendingBlobs.set(localId, pendingEntry);\n\n\t\tconst abortListener = () => {\n\t\t\tif (!pendingEntry.acked) {\n\t\t\t\tpendingEntry.handleP.reject(this.createAbortError(pendingEntry));\n\t\t\t}\n\t\t};\n\t\tsignal?.addEventListener(\"abort\", abortListener, { once: true });\n\n\t\treturn pendingEntry.handleP.promise.finally(() => {\n\t\t\tsignal?.removeEventListener(\"abort\", abortListener);\n\t\t});\n\t}\n\n\tprivate async uploadBlob(\n\t\tlocalId: string,\n\t\tblob: ArrayBufferLike,\n\t): Promise<ICreateBlobResponse | void> {\n\t\treturn runWithRetry(\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\treturn await this.getStorage().createBlob(blob);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst entry = this.pendingBlobs.get(localId);\n\t\t\t\t\tassert(\n\t\t\t\t\t\t!!entry,\n\t\t\t\t\t\t0x387 /* Must have pending blob entry for blob which failed to upload */,\n\t\t\t\t\t);\n\t\t\t\t\tif (entry.opsent && !canRetryOnError(error)) {\n\t\t\t\t\t\tthrow wrapError(\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t() => new LoggingError(`uploadBlob error`, { canRetry: true }),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"createBlob\",\n\t\t\tthis.mc.logger,\n\t\t\t{\n\t\t\t\tcancel: this.pendingBlobs.get(localId)?.abortSignal,\n\t\t\t},\n\t\t).then(\n\t\t\t(response) => this.onUploadResolve(localId, response),\n\t\t\t(error) => {\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"UploadBlobReject\",\n\t\t\t\t\terror,\n\t\t\t\t\tlocalId,\n\t\t\t\t});\n\t\t\t\t// it will only reject if we haven't sent an op\n\t\t\t\t// and is a non-retriable error. It will only reject\n\t\t\t\t// the promise but not throw any error outside.\n\t\t\t\tthis.pendingBlobs.get(localId)?.handleP.reject(error);\n\t\t\t\tthis.deletePendingBlob(localId);\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * Set up a mapping in the redirect table from fromId to toId. Also, notify the runtime that a reference is added\n\t * which is required for GC.\n\t */\n\tprivate setRedirection(fromId: string, toId: string | undefined) {\n\t\tthis.redirectTable.set(fromId, toId);\n\t}\n\n\tprivate deletePendingBlobMaybe(id: string) {\n\t\tif (this.pendingBlobs.has(id)) {\n\t\t\tconst entry = this.pendingBlobs.get(id);\n\t\t\tif (entry?.attached && entry?.acked) {\n\t\t\t\tthis.deletePendingBlob(id);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate deletePendingBlob(id: string) {\n\t\tif (this.pendingBlobs.delete(id) && !this.hasPendingBlobs) {\n\t\t\tthis.emit(\"noPendingBlobs\");\n\t\t}\n\t}\n\n\tprivate onUploadResolve(localId: string, response: ICreateBlobResponseWithTTL) {\n\t\tconst entry = this.pendingBlobs.get(localId);\n\t\tassert(entry !== undefined, 0x6c8 /* pending blob entry not found for uploaded blob */);\n\t\tif ((entry.abortSignal?.aborted === true && !entry.opsent) || this.stopAttaching) {\n\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"BlobAborted\",\n\t\t\t\tlocalId,\n\t\t\t});\n\t\t\tthis.deletePendingBlob(localId);\n\t\t\treturn;\n\t\t}\n\t\tassert(\n\t\t\tentry.storageId === undefined,\n\t\t\t0x386 /* Must have pending blob entry for uploaded blob */,\n\t\t);\n\t\tentry.stashedUpload = undefined;\n\t\tentry.storageId = response.id;\n\t\tentry.uploadTime = Date.now();\n\t\tentry.minTTLInSeconds = response.minTTLInSeconds;\n\t\t// Send a blob attach op. This serves two purposes:\n\t\t// 1. If its a new blob, i.e., it isn't de-duped, the server will keep the blob alive if it sees this op\n\t\t// until its storage ID is added to the next summary.\n\t\t// 2. It will create a local ID to storage ID mapping in all clients which is needed to retrieve the\n\t\t// blob from the server via the storage ID.\n\t\tif (!entry.opsent) {\n\t\t\tthis.sendBlobAttachOp(localId, response.id);\n\t\t}\n\t\tconst storageIds = getStorageIds(this.redirectTable, this.runtime.attachState);\n\t\tif (storageIds.has(response.id)) {\n\t\t\t// The blob is de-duped. Set up a local ID to storage ID mapping and return the blob. Since this is\n\t\t\t// an existing blob, we don't have to wait for the op to be ack'd since this step has already\n\t\t\t// happened before and so, the server won't delete it.\n\t\t\tthis.setRedirection(localId, response.id);\n\t\t\tentry.handleP.resolve(this.getBlobHandle(localId));\n\t\t\tthis.deletePendingBlobMaybe(localId);\n\t\t} else {\n\t\t\t// If there is already an op for this storage ID, append the local ID to the list. Once any op for\n\t\t\t// this storage ID is ack'd, all pending blobs for it can be resolved since the op will keep the\n\t\t\t// blob alive in storage.\n\t\t\tthis.opsInFlight.set(\n\t\t\t\tresponse.id,\n\t\t\t\t(this.opsInFlight.get(response.id) ?? []).concat(localId),\n\t\t\t);\n\t\t}\n\t\treturn response;\n\t}\n\n\t/**\n\t * Resubmit a BlobAttach op. Used to add storage IDs to ops that were\n\t * submitted to runtime while disconnected.\n\t * @param metadata - op metadata containing storage and/or local IDs\n\t */\n\tpublic reSubmit(metadata: Record<string, unknown> | undefined) {\n\t\tassert(!!metadata, 0x38b /* Resubmitted ops must have metadata */);\n\t\tconst { localId, blobId }: { localId?: string; blobId?: string } = metadata;\n\t\tassert(localId !== undefined, 0x50d /* local ID not available on reSubmit */);\n\t\tconst pendingEntry = this.pendingBlobs.get(localId);\n\n\t\tif (!blobId) {\n\t\t\t// We submitted this op while offline. The blob should have been uploaded by now.\n\t\t\tassert(\n\t\t\t\tpendingEntry?.opsent === true && !!pendingEntry?.storageId,\n\t\t\t\t0x38d /* blob must be uploaded before resubmitting BlobAttach op */,\n\t\t\t);\n\t\t\treturn this.sendBlobAttachOp(localId, pendingEntry?.storageId);\n\t\t}\n\t\treturn this.sendBlobAttachOp(localId, blobId);\n\t}\n\n\tpublic processBlobAttachMessage(message: ISequencedMessageEnvelope, local: boolean) {\n\t\tconst localId = (message.metadata as IBlobMetadata | undefined)?.localId;\n\t\tconst blobId = (message.metadata as IBlobMetadata | undefined)?.blobId;\n\n\t\tif (localId) {\n\t\t\tconst pendingEntry = this.pendingBlobs.get(localId);\n\t\t\tif (pendingEntry?.abortSignal?.aborted) {\n\t\t\t\tthis.deletePendingBlob(localId);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tassert(blobId !== undefined, 0x12a /* \"Missing blob id on metadata\" */);\n\n\t\t// Set up a mapping from local ID to storage ID. This is crucial since without this the blob cannot be\n\t\t// requested from the server.\n\t\t// Note: The check for undefined is needed for back-compat when localId was not part of the BlobAttach op that\n\t\t// was sent when online.\n\t\tif (localId !== undefined) {\n\t\t\tthis.setRedirection(localId, blobId);\n\t\t}\n\t\t// set identity (id -> id) entry\n\t\tthis.setRedirection(blobId, blobId);\n\n\t\tif (local) {\n\t\t\tassert(localId !== undefined, 0x50e /* local ID not present in blob attach message */);\n\t\t\tconst waitingBlobs = this.opsInFlight.get(blobId);\n\t\t\tif (waitingBlobs !== undefined) {\n\t\t\t\t// For each op corresponding to this storage ID that we are waiting for, resolve the pending blob.\n\t\t\t\t// This is safe because the server will keep the blob alive and the op containing the local ID to\n\t\t\t\t// storage ID is already in flight and any op containing this local ID will be sequenced after that.\n\t\t\t\twaitingBlobs.forEach((pendingLocalId) => {\n\t\t\t\t\tconst entry = this.pendingBlobs.get(pendingLocalId);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tentry !== undefined,\n\t\t\t\t\t\t0x38f /* local online BlobAttach op with no pending blob entry */,\n\t\t\t\t\t);\n\t\t\t\t\tthis.setRedirection(pendingLocalId, blobId);\n\t\t\t\t\tentry.acked = true;\n\t\t\t\t\tentry.handleP.resolve(this.getBlobHandle(pendingLocalId));\n\t\t\t\t\tthis.deletePendingBlobMaybe(pendingLocalId);\n\t\t\t\t});\n\t\t\t\tthis.opsInFlight.delete(blobId);\n\t\t\t}\n\t\t\tconst localEntry = this.pendingBlobs.get(localId);\n\t\t\tif (localEntry) {\n\t\t\t\tlocalEntry.acked = true;\n\t\t\t\tlocalEntry.handleP.resolve(this.getBlobHandle(localId));\n\t\t\t\tthis.deletePendingBlobMaybe(localId);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic summarize(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {\n\t\treturn summarizeBlobManagerState(this.redirectTable, this.runtime.attachState);\n\t}\n\n\t/**\n\t * Generates data used for garbage collection. Each blob uploaded represents a node in the GC graph as it can be\n\t * individually referenced by storing its handle in a referenced DDS. Returns the list of blob ids as GC nodes.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data. BlobManager doesn't care\n\t * about this for now because the data is a simple list of blob ids.\n\t */\n\tpublic getGCData(fullGC: boolean = false): IGarbageCollectionData {\n\t\tconst gcData: IGarbageCollectionData = { gcNodes: {} };\n\t\tfor (const [localId, storageId] of this.redirectTable) {\n\t\t\tassert(!!storageId, 0x390 /* Must be attached to get GC data */);\n\t\t\t// Only return local ids as GC nodes because a blob can only be referenced via its local id. The storage\n\t\t\t// id entries have the same key and value, ignore them.\n\t\t\t// The outbound routes are empty because a blob node cannot reference other nodes. It can only be referenced\n\t\t\t// by adding its handle to a referenced DDS.\n\t\t\tif (localId !== storageId) {\n\t\t\t\tgcData.gcNodes[getGCNodePathFromBlobId(localId)] = [];\n\t\t\t}\n\t\t}\n\t\treturn gcData;\n\t}\n\n\t/**\n\t * Delete attachment blobs that are sweep ready.\n\t * @param sweepReadyBlobRoutes - The routes of blobs that are sweep ready and should be deleted. These routes will\n\t * be based off of local ids.\n\t * @returns The routes of blobs that were deleted.\n\t */\n\tpublic deleteSweepReadyNodes(sweepReadyBlobRoutes: readonly string[]): readonly string[] {\n\t\tthis.deleteBlobsFromRedirectTable(sweepReadyBlobRoutes);\n\t\treturn Array.from(sweepReadyBlobRoutes);\n\t}\n\n\t/**\n\t * Delete blobs with the given routes from the redirect table.\n\t * The routes are GC nodes paths of format -`/<blobManagerBasePath>/<blobId>`. The blob ids are all local ids.\n\t * Deleting the blobs involves 2 steps:\n\t * 1. The redirect table entry for the local ids are deleted.\n\t * 2. If the storage ids corresponding to the deleted local ids are not in-use anymore, the redirect table entries\n\t * for the storage ids are deleted as well.\n\t *\n\t * Note that this does not delete the blobs from storage service immediately. Deleting the blobs from redirect table\n\t * will remove them the next summary. The service would them delete them some time in the future.\n\t */\n\tprivate deleteBlobsFromRedirectTable(blobRoutes: readonly string[]) {\n\t\tif (blobRoutes.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\t// This tracks the storage ids of local ids that are deleted. After the local ids have been deleted, if any of\n\t\t// these storage ids are unused, they will be deleted as well.\n\t\tconst maybeUnusedStorageIds: Set<string> = new Set();\n\t\tfor (const route of blobRoutes) {\n\t\t\tconst blobId = getBlobIdFromGCNodePath(route);\n\t\t\t// If the blob hasn't already been deleted, log an error because this should never happen.\n\t\t\t// If the blob has already been deleted, log a telemetry event. This can happen because multiple GC\n\t\t\t// sweep ops can contain the same data store. It would be interesting to track how often this happens.\n\t\t\tconst alreadyDeleted = this.isBlobDeleted(route);\n\t\t\tif (!this.redirectTable.has(blobId)) {\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"DeletedAttachmentBlobNotFound\",\n\t\t\t\t\tcategory: alreadyDeleted ? \"generic\" : \"error\",\n\t\t\t\t\tblobId,\n\t\t\t\t\tdetails: { alreadyDeleted },\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst storageId = this.redirectTable.get(blobId);\n\t\t\tassert(!!storageId, 0x5bb /* Must be attached to run GC */);\n\t\t\tmaybeUnusedStorageIds.add(storageId);\n\t\t\tthis.redirectTable.delete(blobId);\n\t\t}\n\n\t\t// Find out storage ids that are in-use and remove them from maybeUnusedStorageIds. A storage id is in-use if\n\t\t// the redirect table has a local id -> storage id entry for it.\n\t\tfor (const [localId, storageId] of this.redirectTable.entries()) {\n\t\t\tassert(!!storageId, 0x5bc /* Must be attached to run GC */);\n\t\t\t// For every storage id, the redirect table has a id -> id entry. These do not make the storage id in-use.\n\t\t\tif (maybeUnusedStorageIds.has(storageId) && localId !== storageId) {\n\t\t\t\tmaybeUnusedStorageIds.delete(storageId);\n\t\t\t}\n\t\t}\n\n\t\t// For unused storage ids, delete their id -> id entries from the redirect table.\n\t\t// This way they'll be absent from the next summary, and the service is free to delete them from storage.\n\t\tfor (const storageId of maybeUnusedStorageIds) {\n\t\t\tthis.redirectTable.delete(storageId);\n\t\t}\n\t}\n\n\t/**\n\t * Verifies that the blob with given id is not deleted, i.e., it has not been garbage collected. If the blob is GC'd,\n\t * log an error and throw if necessary.\n\t */\n\tprivate verifyBlobNotDeleted(blobId: string) {\n\t\tif (!this.isBlobDeleted(getGCNodePathFromBlobId(blobId))) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst request = { url: blobId };\n\t\tconst error = responseToException(\n\t\t\tcreateResponseError(404, `Blob was deleted`, request),\n\t\t\trequest,\n\t\t);\n\t\t// Only log deleted events. Tombstone events are logged by garbage collector.\n\t\tthis.mc.logger.sendErrorEvent(\n\t\t\t{\n\t\t\t\teventName: \"GC_Deleted_Blob_Requested\",\n\t\t\t\tpkg: blobManagerBasePath,\n\t\t\t},\n\t\t\terror,\n\t\t);\n\t\tthrow error;\n\t}\n\n\tpublic setRedirectTable(table: Map<string, string>) {\n\t\tassert(\n\t\t\tthis.runtime.attachState === AttachState.Detached,\n\t\t\t0x252 /* \"redirect table can only be set in detached container\" */,\n\t\t);\n\t\tassert(\n\t\t\tthis.redirectTable.size === table.size,\n\t\t\t0x391 /* Redirect table size must match BlobManager's local ID count */,\n\t\t);\n\t\tfor (const [localId, storageId] of table) {\n\t\t\tassert(this.redirectTable.has(localId), 0x254 /* \"unrecognized id in redirect table\" */);\n\t\t\tthis.setRedirection(localId, storageId);\n\t\t\t// set identity (id -> id) entry\n\t\t\tthis.setRedirection(storageId, storageId);\n\t\t}\n\t}\n\n\t/**\n\t * Part of container serialization when imminent closure is enabled (Currently when calling closeAndGetPendingLocalState).\n\t * This asynchronous function resolves all pending createBlob calls and waits for each blob\n\t * to be attached. It will also send BlobAttach ops for each pending blob that hasn't sent it\n\t * yet so that serialized container can resubmit them when rehydrated.\n\t *\n\t * @param stopBlobAttachingSignal - Optional signal to abort the blob attaching process.\n\t * @returns - A promise that resolves with the details of the attached blobs,\n\t * or undefined if no blobs were processed.\n\t */\n\tpublic async attachAndGetPendingBlobs(\n\t\tstopBlobAttachingSignal?: AbortSignal,\n\t): Promise<IPendingBlobs | undefined> {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{ eventName: \"GetPendingBlobs\" },\n\t\t\tasync () => {\n\t\t\t\tif (this.pendingBlobs.size === 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst blobs = {};\n\t\t\t\tconst localBlobs = new Set<PendingBlob>();\n\t\t\t\t// This while is used to stash blobs created while attaching and getting blobs\n\t\t\t\twhile (localBlobs.size < this.pendingBlobs.size) {\n\t\t\t\t\tconst attachBlobsP: Promise<void>[] = [];\n\t\t\t\t\tfor (const [id, entry] of this.pendingBlobs) {\n\t\t\t\t\t\tif (!localBlobs.has(entry)) {\n\t\t\t\t\t\t\tlocalBlobs.add(entry);\n\t\t\t\t\t\t\t// In order to follow natural blob creation flow we need to:\n\t\t\t\t\t\t\t// 1 send the blob attach op\n\t\t\t\t\t\t\t// 2 resolve the blob handle\n\t\t\t\t\t\t\t// 3 wait for op referencing the blob\n\t\t\t\t\t\t\tif (!entry.opsent) {\n\t\t\t\t\t\t\t\tthis.sendBlobAttachOp(id, entry.storageId);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Resolving the blob handle to let hosts continue with their operations (it will resolve\n\t\t\t\t\t\t\t// original createBlob call) and let them attach the blob. This is a lie we told since the upload\n\t\t\t\t\t\t\t// hasn't finished yet, but it's fine since we will retry on rehydration.\n\t\t\t\t\t\t\tentry.handleP.resolve(this.getBlobHandle(id));\n\t\t\t\t\t\t\t// Array of promises that will resolve when blobs get attached.\n\t\t\t\t\t\t\tattachBlobsP.push(\n\t\t\t\t\t\t\t\tnew Promise<void>((resolve, reject) => {\n\t\t\t\t\t\t\t\t\tstopBlobAttachingSignal?.addEventListener(\n\t\t\t\t\t\t\t\t\t\t\"abort\",\n\t\t\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\t\t\tthis.stopAttaching = true;\n\t\t\t\t\t\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t{ once: true },\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst onBlobAttached = (attachedEntry) => {\n\t\t\t\t\t\t\t\t\t\tif (attachedEntry === entry) {\n\t\t\t\t\t\t\t\t\t\t\tthis.off(\"blobAttached\", onBlobAttached);\n\t\t\t\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tif (!entry.attached) {\n\t\t\t\t\t\t\t\t\t\tthis.on(\"blobAttached\", onBlobAttached);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Wait for all blobs to be attached. This is important, otherwise serialized container\n\t\t\t\t\t// could send the blobAttach op without any op that references the blob, making it useless.\n\t\t\t\t\tawait Promise.allSettled(attachBlobsP).catch(() => {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tfor (const [id, entry] of this.pendingBlobs) {\n\t\t\t\t\tif (stopBlobAttachingSignal?.aborted && !entry.attached) {\n\t\t\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\t\t\teventName: \"UnableToStashBlob\",\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tassert(entry.attached === true, 0x790 /* stashed blob should be attached */);\n\t\t\t\t\tblobs[id] = {\n\t\t\t\t\t\tblob: bufferToString(entry.blob, \"base64\"),\n\t\t\t\t\t\tstorageId: entry.storageId,\n\t\t\t\t\t\tacked: entry.acked,\n\t\t\t\t\t\tminTTLInSeconds: entry.minTTLInSeconds,\n\t\t\t\t\t\tuploadTime: entry.uploadTime,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn Object.keys(blobs).length > 0 ? blobs : undefined;\n\t\t\t},\n\t\t);\n\t}\n}\n\n/**\n * For a blobId, returns its path in GC's graph. The node path is of the format `/<blobManagerBasePath>/<blobId>`.\n * This path must match the path of the blob handle returned by the createBlob API because blobs are marked\n * referenced by storing these handles in a referenced DDS.\n */\nconst getGCNodePathFromBlobId = (blobId: string) => `/${blobManagerBasePath}/${blobId}`;\n\n/**\n * For a given GC node path, return the blobId. The node path is of the format `/<basePath>/<blobId>`.\n */\nconst getBlobIdFromGCNodePath = (nodePath: string) => {\n\tconst pathParts = nodePath.split(\"/\");\n\tassert(areBlobPathParts(pathParts), 0x5bd /* Invalid blob node path */);\n\treturn pathParts[2];\n};\n\n/**\n * Returns whether a given path is for attachment blobs that are in the format - \"/blobManagerBasePath/...\".\n */\nexport const isBlobPath = (path: string): path is `/${typeof blobManagerBasePath}/${string}` =>\n\tareBlobPathParts(path.split(\"/\"));\n\nexport const areBlobPathParts = (\n\tpathParts: string[],\n): pathParts is [\"\", typeof blobManagerBasePath, string] =>\n\tpathParts.length === 3 && pathParts[1] === blobManagerBasePath;\n"]}
@@ -7,7 +7,7 @@ import { FluidObject, IDisposable, IRequest, IResponse, ITelemetryBaseLogger } f
7
7
  import type { IFluidHandleInternal } from "@fluidframework/core-interfaces/internal";
8
8
  import type { ISnapshot } from "@fluidframework/driver-definitions/internal";
9
9
  import { ISnapshotTree, ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
10
- import { ISummaryTreeWithStats, ITelemetryContext, IGarbageCollectionData, AliasResult, IEnvelope, IFluidDataStoreChannel, IFluidDataStoreContext, IFluidDataStoreContextDetached, IFluidDataStoreFactory, IFluidDataStoreRegistry, IFluidParentContext, NamedFluidDataStoreRegistryEntries, IInboundSignalMessage } from "@fluidframework/runtime-definitions/internal";
10
+ import { ISummaryTreeWithStats, ITelemetryContext, IGarbageCollectionData, AliasResult, IEnvelope, IFluidDataStoreChannel, IFluidDataStoreContext, IFluidDataStoreContextDetached, IFluidDataStoreFactory, IFluidDataStoreRegistry, IFluidParentContext, NamedFluidDataStoreRegistryEntries, IInboundSignalMessage, type IRuntimeMessageCollection } from "@fluidframework/runtime-definitions/internal";
11
11
  import { MonitoringContext } from "@fluidframework/telemetry-utils/internal";
12
12
  import { RuntimeHeaderData } from "./containerRuntime.js";
13
13
  import { IFluidDataStoreContextInternal, ILocalDetachedFluidDataStoreContextProps, LocalFluidDataStoreContext } from "./dataStoreContext.js";
@@ -73,8 +73,8 @@ export declare class ChannelCollection implements IFluidDataStoreChannel, IDispo
73
73
  * Currently this API is called by context only for root data stores.
74
74
  */
75
75
  makeVisibleAndAttachGraph(): void;
76
- private processAttachMessage;
77
- private processAliasMessage;
76
+ private processAttachMessages;
77
+ private processAliasMessages;
78
78
  processAliasMessageCore(internalId: string, alias: string, messageTimestampMs?: number): boolean;
79
79
  private alreadyProcessed;
80
80
  /** Package up the context's attach summary etc into an IAttachMessage */
@@ -114,8 +114,23 @@ export declare class ChannelCollection implements IFluidDataStoreChannel, IDispo
114
114
  applyStashedOp(content: unknown): Promise<unknown>;
115
115
  protected applyStashedChannelChannelOp(envelope: IEnvelope): Promise<unknown>;
116
116
  private applyStashedAttachOp;
117
- process(message: ISequencedDocumentMessage, local: boolean, localMessageMetadata: unknown): void;
118
- protected processChannelOp(address: string, message: ISequencedDocumentMessage, local: boolean, localMessageMetadata: unknown): void;
117
+ /**
118
+ * Process messages for this channel collection. The messages here are contiguous messages in a batch.
119
+ * @param messageCollection - The collection of messages to process.
120
+ */
121
+ processMessages(messageCollection: IRuntimeMessageCollection): void;
122
+ /**
123
+ * This is still here for back-compat purposes because channel collection implements
124
+ * IFluidDataStoreChannel. Once it is removed from the interface, this method can be removed.
125
+ * Container runtime calls `processMessages` instead.
126
+ */
127
+ process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
128
+ /**
129
+ * Process channel messages. The messages here are contiguous channel type messages in a batch. Bunch
130
+ * of contiguous messages for a data store should be sent to it together.
131
+ * @param messageCollection - The collection of messages to process.
132
+ */
133
+ private processChannelMessages;
119
134
  private getDataStore;
120
135
  /**
121
136
  * Returns the data store requested with the given id if available. Otherwise, returns undefined.