@fluidframework/container-runtime 2.100.0 → 2.101.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 (106) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/container-runtime.test-files.tar +0 -0
  3. package/dist/blobManager/blobManager.d.ts +3 -0
  4. package/dist/blobManager/blobManager.d.ts.map +1 -1
  5. package/dist/blobManager/blobManager.js +3 -0
  6. package/dist/blobManager/blobManager.js.map +1 -1
  7. package/dist/blobManager/blobManagerSnapSum.d.ts +3 -0
  8. package/dist/blobManager/blobManagerSnapSum.d.ts.map +1 -1
  9. package/dist/blobManager/blobManagerSnapSum.js +12 -5
  10. package/dist/blobManager/blobManagerSnapSum.js.map +1 -1
  11. package/dist/connectionTelemetry.d.ts.map +1 -1
  12. package/dist/connectionTelemetry.js +3 -1
  13. package/dist/connectionTelemetry.js.map +1 -1
  14. package/dist/containerRuntime.d.ts +6 -1
  15. package/dist/containerRuntime.d.ts.map +1 -1
  16. package/dist/containerRuntime.js +33 -15
  17. package/dist/containerRuntime.js.map +1 -1
  18. package/dist/gc/garbageCollection.d.ts +4 -0
  19. package/dist/gc/garbageCollection.d.ts.map +1 -1
  20. package/dist/gc/garbageCollection.js +3 -2
  21. package/dist/gc/garbageCollection.js.map +1 -1
  22. package/dist/gc/gcDefinitions.d.ts +10 -4
  23. package/dist/gc/gcDefinitions.d.ts.map +1 -1
  24. package/dist/gc/gcDefinitions.js.map +1 -1
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +16 -12
  28. package/dist/index.js.map +1 -1
  29. package/dist/metadata.d.ts +14 -0
  30. package/dist/metadata.d.ts.map +1 -1
  31. package/dist/metadata.js.map +1 -1
  32. package/dist/opLifecycle/duplicateBatchDetector.d.ts +8 -0
  33. package/dist/opLifecycle/duplicateBatchDetector.d.ts.map +1 -1
  34. package/dist/opLifecycle/duplicateBatchDetector.js +23 -1
  35. package/dist/opLifecycle/duplicateBatchDetector.js.map +1 -1
  36. package/dist/opLifecycle/opGroupingManager.js +2 -2
  37. package/dist/opLifecycle/opGroupingManager.js.map +1 -1
  38. package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
  39. package/dist/opLifecycle/opSplitter.js +13 -3
  40. package/dist/opLifecycle/opSplitter.js.map +1 -1
  41. package/dist/packageVersion.d.ts +1 -1
  42. package/dist/packageVersion.js +1 -1
  43. package/dist/packageVersion.js.map +1 -1
  44. package/dist/runtimeLayerCompatState.d.ts +1 -1
  45. package/dist/summary/summarizerTypes.d.ts +3 -1
  46. package/dist/summary/summarizerTypes.d.ts.map +1 -1
  47. package/dist/summary/summarizerTypes.js.map +1 -1
  48. package/lib/blobManager/blobManager.d.ts +3 -0
  49. package/lib/blobManager/blobManager.d.ts.map +1 -1
  50. package/lib/blobManager/blobManager.js +3 -0
  51. package/lib/blobManager/blobManager.js.map +1 -1
  52. package/lib/blobManager/blobManagerSnapSum.d.ts +3 -0
  53. package/lib/blobManager/blobManagerSnapSum.d.ts.map +1 -1
  54. package/lib/blobManager/blobManagerSnapSum.js +12 -5
  55. package/lib/blobManager/blobManagerSnapSum.js.map +1 -1
  56. package/lib/connectionTelemetry.d.ts.map +1 -1
  57. package/lib/connectionTelemetry.js +3 -1
  58. package/lib/connectionTelemetry.js.map +1 -1
  59. package/lib/containerRuntime.d.ts +6 -1
  60. package/lib/containerRuntime.d.ts.map +1 -1
  61. package/lib/containerRuntime.js +33 -15
  62. package/lib/containerRuntime.js.map +1 -1
  63. package/lib/gc/garbageCollection.d.ts +4 -0
  64. package/lib/gc/garbageCollection.d.ts.map +1 -1
  65. package/lib/gc/garbageCollection.js +3 -2
  66. package/lib/gc/garbageCollection.js.map +1 -1
  67. package/lib/gc/gcDefinitions.d.ts +10 -4
  68. package/lib/gc/gcDefinitions.d.ts.map +1 -1
  69. package/lib/gc/gcDefinitions.js.map +1 -1
  70. package/lib/index.d.ts +1 -0
  71. package/lib/index.d.ts.map +1 -1
  72. package/lib/index.js +1 -0
  73. package/lib/index.js.map +1 -1
  74. package/lib/metadata.d.ts +14 -0
  75. package/lib/metadata.d.ts.map +1 -1
  76. package/lib/metadata.js.map +1 -1
  77. package/lib/opLifecycle/duplicateBatchDetector.d.ts +8 -0
  78. package/lib/opLifecycle/duplicateBatchDetector.d.ts.map +1 -1
  79. package/lib/opLifecycle/duplicateBatchDetector.js +23 -1
  80. package/lib/opLifecycle/duplicateBatchDetector.js.map +1 -1
  81. package/lib/opLifecycle/opGroupingManager.js +2 -2
  82. package/lib/opLifecycle/opGroupingManager.js.map +1 -1
  83. package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
  84. package/lib/opLifecycle/opSplitter.js +13 -3
  85. package/lib/opLifecycle/opSplitter.js.map +1 -1
  86. package/lib/packageVersion.d.ts +1 -1
  87. package/lib/packageVersion.js +1 -1
  88. package/lib/packageVersion.js.map +1 -1
  89. package/lib/runtimeLayerCompatState.d.ts +1 -1
  90. package/lib/summary/summarizerTypes.d.ts +3 -1
  91. package/lib/summary/summarizerTypes.d.ts.map +1 -1
  92. package/lib/summary/summarizerTypes.js.map +1 -1
  93. package/package.json +18 -18
  94. package/src/blobManager/blobManager.ts +3 -0
  95. package/src/blobManager/blobManagerSnapSum.ts +12 -5
  96. package/src/connectionTelemetry.ts +15 -10
  97. package/src/containerRuntime.ts +44 -17
  98. package/src/gc/garbageCollection.ts +8 -6
  99. package/src/gc/gcDefinitions.ts +11 -4
  100. package/src/index.ts +5 -0
  101. package/src/metadata.ts +14 -0
  102. package/src/opLifecycle/duplicateBatchDetector.ts +27 -6
  103. package/src/opLifecycle/opGroupingManager.ts +2 -2
  104. package/src/opLifecycle/opSplitter.ts +13 -3
  105. package/src/packageVersion.ts +1 -1
  106. package/src/summary/summarizerTypes.ts +3 -1
@@ -1 +1 @@
1
- {"version":3,"file":"blobManager.js","sourceRoot":"","sources":["../../src/blobManager/blobManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,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AAC,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC;qBACpD;oBACF,CAAC,CAAC;wBACA,GAAG,eAAe;wBAClB,KAAK,EAAE,UAAU;wBACjB,IAAI,EAAE,cAAc,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC;qBACpD,CAAC;QACN,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;IACxE,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,OAAe,EAAU,EAAE,CACnE,IAAI,mBAAmB,IAAI,OAAO,EAAE,CAAC;AAEtC;;GAEG;AACH,MAAM,wBAAwB,GAAG,CAAC,QAAgB,EAAU,EAAE;IAC7D,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,gBAAgB,GAAG,CACxB,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 { bufferToString, createEmitter, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport {\n\tAttachState,\n\ttype IContainerStorageService,\n} from \"@fluidframework/container-definitions/internal\";\nimport type {\n\tIContainerRuntime,\n\tIContainerRuntimeEvents,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tIEmitter,\n\tIEventProvider,\n\tIFluidHandleContext,\n\tIFluidHandleInternalPayloadPending,\n\tILocalFluidHandle,\n\tILocalFluidHandleEvents,\n\tListenable,\n\tPayloadState,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { ICreateBlobResponse } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tIGarbageCollectionData,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tFluidHandleBase,\n\tcreateResponseError,\n\tgenerateHandleContextPath,\n\tresponseToException,\n} from \"@fluidframework/runtime-utils/internal\";\nimport {\n\tLoggingError,\n\ttype MonitoringContext,\n\tPerformanceEvent,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { isBlobMetadata } from \"../metadata.js\";\n\nimport {\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\n\textends FluidHandleBase<ArrayBufferLike>\n\timplements\n\t\tILocalFluidHandle<ArrayBufferLike>,\n\t\tIFluidHandleInternalPayloadPending<ArrayBufferLike>\n{\n\tprivate attached: boolean = false;\n\n\tpublic get isAttached(): boolean {\n\t\treturn this.routeContext.isAttached && this.attached;\n\t}\n\n\tprivate _events:\n\t\t| (Listenable<ILocalFluidHandleEvents> & IEmitter<ILocalFluidHandleEvents>)\n\t\t| undefined;\n\tpublic get events(): Listenable<ILocalFluidHandleEvents> {\n\t\treturn (this._events ??= createEmitter<ILocalFluidHandleEvents>());\n\t}\n\n\tprivate _payloadState: PayloadState;\n\tpublic get payloadState(): PayloadState {\n\t\treturn this._payloadState;\n\t}\n\n\t/**\n\t * The error property starts undefined, signalling that there has been no error yet.\n\t * If an error occurs, the property will contain the error.\n\t */\n\tprivate _payloadShareError: unknown;\n\tpublic get payloadShareError(): unknown {\n\t\treturn this._payloadShareError;\n\t}\n\n\tpublic readonly absolutePath: string;\n\n\tpublic constructor(\n\t\tpublic readonly path: string,\n\t\tpublic readonly routeContext: IFluidHandleContext,\n\t\t// TODO: just take the blob rather than a get function?\n\t\tpublic get: () => Promise<ArrayBufferLike>,\n\t\tpublic readonly payloadPending: boolean,\n\t\tprivate readonly onAttachGraph?: () => void,\n\t) {\n\t\tsuper();\n\t\tthis._payloadState = payloadPending ? \"pending\" : \"shared\";\n\t\tthis.absolutePath = generateHandleContextPath(path, this.routeContext);\n\t}\n\n\tpublic readonly notifyShared = (): void => {\n\t\tthis._payloadState = \"shared\";\n\t\tthis._events?.emit(\"payloadShared\");\n\t};\n\n\tpublic readonly notifyFailed = (error: unknown): void => {\n\t\tthis._payloadShareError = error;\n\t\tthis._events?.emit(\"payloadShareFailed\", error);\n\t};\n\n\tpublic attachGraph(): void {\n\t\tif (!this.attached) {\n\t\t\tthis.attached = true;\n\t\t\tthis.onAttachGraph?.();\n\t\t}\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\" | \"baseLogger\" | \"disposed\"\n> &\n\tIEventProvider<IContainerRuntimeEvents>;\n\nexport type ICreateBlobResponseWithTTL = ICreateBlobResponse &\n\tPartial<Record<\"minTTLInSeconds\", number>>;\n\n/**\n * A blob tracked by BlobManager that is only available on the local client. It is not currently\n * attempting an upload.\n */\ninterface LocalOnlyBlob {\n\tstate: \"localOnly\";\n\tblob: ArrayBufferLike;\n}\n\n/**\n * A blob tracked by BlobManager that is only known to be available on the local client, but is in\n * the process of being uploaded to storage.\n */\ninterface UploadingBlob {\n\tstate: \"uploading\";\n\tblob: ArrayBufferLike;\n}\n\n/**\n * A blob tracked by BlobManager that has been uploaded to storage. If the TTL has not expired, it\n * should still be available in storage. It is not currently attempting to send a BlobAttach op.\n */\ninterface UploadedBlob {\n\tstate: \"uploaded\";\n\tblob: ArrayBufferLike;\n\tstorageId: string;\n\tuploadTime: number;\n\tminTTLInSeconds: number | undefined;\n}\n\n/**\n * A blob tracked by BlobManager that has been uploaded to storage and is in the process of sending\n * a BlobAttach message and waiting for the ack.\n */\ninterface AttachingBlob {\n\tstate: \"attaching\";\n\tblob: ArrayBufferLike;\n\tstorageId: string;\n\tuploadTime: number;\n\tminTTLInSeconds: number | undefined;\n}\n\n/**\n * A blob tracked by BlobManager that has been uploaded to storage and its BlobAttach message has been\n * ack'd. It is fully shared and available to all clients, and is no longer considered pending.\n */\ninterface AttachedBlob {\n\tstate: \"attached\";\n\tblob: ArrayBufferLike;\n}\n\n/**\n * Blobs that were created locally are tracked, and may be in one of these states. When first\n * created, they are in localOnly state. The process of sharing has two steps, blob upload and\n * sending a BlobAttach op. Progress through the stages may regress back to localOnly if we\n * determine the storage may have deleted the blob before we could finish attaching it.\n */\ntype LocalBlobRecord =\n\t| LocalOnlyBlob\n\t| UploadingBlob\n\t| UploadedBlob\n\t| AttachingBlob\n\t| AttachedBlob;\n\n/**\n * Serializable form of the LocalBlobRecord that can be used to save and restore pending state.\n * Omits attached blobs since they are fully uploaded and don't need to be saved and restored.\n * Omits uploading and attaching states since upon restore we will need to restart those processes.\n */\nexport type SerializableLocalBlobRecord =\n\t| (Omit<LocalOnlyBlob, \"blob\"> & { blob: string })\n\t| (Omit<UploadedBlob, \"blob\"> & { blob: string });\n\nexport interface IPendingBlobs {\n\t[localId: string]: SerializableLocalBlobRecord;\n}\n\n/**\n * Check if for a given uploaded or attaching blob, the TTL is too close to expiry to safely attempt\n * an attach. Currently using a heuristic of half the TTL duration having passed since upload.\n */\nconst isTTLTooCloseToExpiry = (blobRecord: UploadedBlob | AttachingBlob): boolean =>\n\tblobRecord.minTTLInSeconds !== undefined &&\n\tDate.now() - blobRecord.uploadTime > (blobRecord.minTTLInSeconds / 2) * 1000;\n\ninterface IBlobManagerInternalEvents {\n\tblobExpired: (localId: string) => void;\n\thandleAttached: (pending: LocalBlobRecord) => void;\n\tprocessedBlobAttach: (localId: string, storageId: string) => void;\n}\n\nconst createAbortError = (): LoggingError => new LoggingError(\"uploadBlob aborted\");\n\nexport const blobManagerBasePath = \"_blobs\";\n\nexport class BlobManager {\n\tprivate readonly mc: MonitoringContext;\n\n\tprivate readonly internalEvents = createEmitter<IBlobManagerInternalEvents>();\n\n\t/**\n\t * Map of local IDs to storage IDs. Also includes identity mappings of storage ID to storage ID for all known\n\t * storage IDs. All requested IDs must be a key in this map. Blobs created while the container is detached are\n\t * stored in IDetachedBlobStorage which gives pseudo storage IDs; the real storage IDs are filled in at attach\n\t * time via setRedirectTable().\n\t */\n\tprivate readonly redirectTable: Map<string, string>;\n\n\t/**\n\t * The localBlobCache has a dual role of caching locally-created blobs, as well as tracking their state as they\n\t * are shared. Keys are localIds.\n\t */\n\tprivate readonly localBlobCache: Map<string, LocalBlobRecord> = new Map();\n\t/**\n\t * Blobs with an attached handle that have not finished blob-attaching are the set we need to provide from\n\t * getPendingState(). This stores their local IDs, and then we can look them up against the localBlobCache.\n\t */\n\tprivate readonly pendingBlobsWithAttachedHandles: Set<string> = new Set();\n\t/**\n\t * Local IDs for any pending blobs we loaded with and have not yet started the upload/attach flow for.\n\t */\n\tprivate readonly pendingOnlyLocalIds: Set<string> = new Set();\n\n\tprivate readonly sendBlobAttachMessage: (localId: string, storageId: string) => void;\n\n\tprivate readonly routeContext: IFluidHandleContext;\n\tprivate readonly storage: Pick<IContainerStorageService, \"createBlob\" | \"readBlob\">;\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>/<localId>`.\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>/<localId>`.\n\tprivate readonly isBlobDeleted: (blobPath: string) => boolean;\n\tprivate readonly runtime: IBlobManagerRuntime;\n\n\tprivate readonly createBlobPayloadPending: boolean;\n\n\tpublic constructor(props: {\n\t\treadonly routeContext: IFluidHandleContext;\n\n\t\tblobManagerLoadInfo: IBlobManagerLoadInfo;\n\t\treadonly storage: Pick<IContainerStorageService, \"createBlob\" | \"readBlob\">;\n\t\t/**\n\t\t * Submit a BlobAttach message. When a blob is uploaded, there is a short grace period before which the blob is\n\t\t * deleted. The BlobAttach message 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 message.\n\t\t *\n\t\t * The message 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 message is sequenced\n\t\t * before any messages that reference the local ID, otherwise, an invalid handle could be added to the document.\n\t\t */\n\t\tsendBlobAttachMessage: (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>/<localId>`.\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>/<localId>`.\n\t\treadonly isBlobDeleted: (blobPath: string) => boolean;\n\t\treadonly runtime: IBlobManagerRuntime;\n\t\tpendingBlobs: IPendingBlobs | undefined;\n\t\treadonly createBlobPayloadPending: boolean;\n\t}) {\n\t\tconst {\n\t\t\trouteContext,\n\t\t\tblobManagerLoadInfo,\n\t\t\tstorage,\n\t\t\tsendBlobAttachMessage,\n\t\t\tblobRequested,\n\t\t\tisBlobDeleted,\n\t\t\truntime,\n\t\t\tpendingBlobs,\n\t\t\tcreateBlobPayloadPending,\n\t\t} = props;\n\t\tthis.routeContext = routeContext;\n\t\tthis.storage = storage;\n\t\tthis.sendBlobAttachMessage = sendBlobAttachMessage;\n\t\tthis.blobRequested = blobRequested;\n\t\tthis.isBlobDeleted = isBlobDeleted;\n\t\tthis.runtime = runtime;\n\t\tthis.createBlobPayloadPending = createBlobPayloadPending;\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(blobManagerLoadInfo, this.mc.logger);\n\n\t\t// We populate the localBlobCache with any pending blobs we are provided, which makes them available\n\t\t// to access even though they are not shared yet. However, we don't start the share flow until it is\n\t\t// explicitly invoked via sharePendingBlobs() in case we are loaded in a frozen container.\n\t\tif (pendingBlobs !== undefined) {\n\t\t\tfor (const [localId, serializableBlobRecord] of Object.entries(pendingBlobs)) {\n\t\t\t\tassert(\n\t\t\t\t\t!this.redirectTable.has(localId),\n\t\t\t\t\t0xc7e /* Pending blob already in redirect table */,\n\t\t\t\t);\n\t\t\t\tconst localBlobRecord = {\n\t\t\t\t\t...serializableBlobRecord,\n\t\t\t\t\tblob: stringToBuffer(serializableBlobRecord.blob, \"base64\"),\n\t\t\t\t};\n\t\t\t\tthis.localBlobCache.set(localId, localBlobRecord);\n\t\t\t\t// Since we received these blobs from pending state, we'll assume they were only added to the\n\t\t\t\t// pending state at generation time because their handles were attached. We add them back here\n\t\t\t\t// in case we need to round-trip them back out again due to another getPendingBlobs() call.\n\t\t\t\tthis.pendingBlobsWithAttachedHandles.add(localId);\n\t\t\t\tthis.pendingOnlyLocalIds.add(localId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns whether a blob with the given localId can be retrieved by the BlobManager via getBlob().\n\t */\n\tpublic hasBlob(localId: string): boolean {\n\t\treturn this.redirectTable.has(localId) || this.localBlobCache.has(localId);\n\t}\n\n\t/**\n\t * Lookup the blob storage ID for a given local blob id.\n\t * @param localId - The local blob id. Likely coming from a handle.\n\t * @returns The storage ID if found and the blob is not pending, undefined otherwise.\n\t * @remarks\n\t * For blobs with pending payloads (localId exists but upload hasn't finished), this is expected to return undefined.\n\t * Consumers should use the observability APIs on the handle (handle.payloadState, payloadShared event)\n\t * to understand/wait for storage ID availability.\n\t * Similarly, when the runtime is detached, this will return undefined as no blobs have been uploaded to storage.\n\t */\n\tpublic lookupTemporaryBlobStorageId(localId: string): string | undefined {\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\treturn undefined;\n\t\t}\n\t\t// Get the storage ID from the redirect table\n\t\treturn this.redirectTable.get(localId);\n\t}\n\n\t/**\n\t * Retrieve the blob with the given local blob id.\n\t * @param localId - The local blob id. Likely coming from a handle.\n\t * @param payloadPending - Whether we suspect the payload may be pending and not available yet.\n\t * @returns A promise which resolves to the blob contents\n\t */\n\tpublic async getBlob(localId: string, payloadPending: boolean): 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(localId);\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(getGCNodePathFromLocalId(localId));\n\n\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\tif (localBlobRecord !== undefined) {\n\t\t\treturn localBlobRecord.blob;\n\t\t}\n\n\t\tlet storageId = this.redirectTable.get(localId);\n\t\tif (storageId === undefined) {\n\t\t\t// Only blob handles explicitly marked with pending payload are permitted to exist without\n\t\t\t// yet knowing their storage id. Otherwise they must already be associated with a storage id.\n\t\t\t// Handles for detached blobs are not payload pending, though they should also always be present\n\t\t\t// in the localBlobCache and therefore should never need to refer to storage.\n\t\t\tassert(payloadPending, 0x11f /* \"requesting unknown blobs\" */);\n\t\t\t// If we didn't find it in the redirectTable and it's payloadPending, assume the attach message is coming\n\t\t\t// eventually and wait. We do this even if the local client doesn't have the blob payloadPending flag\n\t\t\t// enabled, in case a remote client does have it enabled. This wait may be infinite if the uploading\n\t\t\t// client failed the upload and doesn't exist anymore.\n\t\t\t// TODO: Fix this violation and remove the disable\n\t\t\t// eslint-disable-next-line require-atomic-updates\n\t\t\tstorageId = await new Promise<string>((resolve) => {\n\t\t\t\tconst onProcessBlobAttach = (_localId: string, _storageId: string): void => {\n\t\t\t\t\tif (_localId === localId) {\n\t\t\t\t\t\tthis.internalEvents.off(\"processedBlobAttach\", onProcessBlobAttach);\n\t\t\t\t\t\tresolve(_storageId);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tthis.internalEvents.on(\"processedBlobAttach\", onProcessBlobAttach);\n\t\t\t});\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 (event) => {\n\t\t\t\treturn this.storage.readBlob(storageId).catch((error) => {\n\t\t\t\t\tif (this.runtime.disposed) {\n\t\t\t\t\t\t// If the runtime is disposed, this is not an error we care to track, it's expected behavior.\n\t\t\t\t\t\tevent.cancel({ category: \"generic\" });\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t\t},\n\t\t\t{ end: true, cancel: \"error\" },\n\t\t);\n\t}\n\n\tprivate getNonPayloadPendingBlobHandle(localId: string): BlobHandle {\n\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\tassert(localBlobRecord !== undefined, 0x384 /* requesting handle for unknown blob */);\n\t\tassert(localBlobRecord.state === \"attached\", 0xc7f /* Expected blob to be attached */);\n\n\t\treturn new BlobHandle(\n\t\t\tgetGCNodePathFromLocalId(localId),\n\t\t\tthis.routeContext,\n\t\t\tasync () => this.getBlob(localId, false),\n\t\t\tfalse, // payloadPending\n\t\t);\n\t}\n\n\tpublic async createBlob(\n\t\tblob: ArrayBufferLike,\n\t\tsignal?: AbortSignal,\n\t): Promise<IFluidHandleInternalPayloadPending<ArrayBufferLike>> {\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\treturn this.createBlobDetached(blob, signal);\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\treturn this.createBlobPayloadPending\n\t\t\t? this.createBlobWithPayloadPending(blob, signal)\n\t\t\t: this.createBlobLegacy(blob, signal);\n\t}\n\n\tprivate async createBlobDetached(\n\t\tblob: ArrayBufferLike,\n\t\tsignal?: AbortSignal,\n\t): Promise<IFluidHandleInternalPayloadPending<ArrayBufferLike>> {\n\t\tif (signal?.aborted === true) {\n\t\t\tthrow createAbortError();\n\t\t}\n\t\tconst localId = uuid();\n\t\tthis.localBlobCache.set(localId, { state: \"uploading\", blob });\n\t\t// Blobs created while the container is detached are stored in IDetachedBlobStorage.\n\t\t// The 'IContainerStorageService.createBlob()' call below will respond with a pseudo storage ID.\n\t\t// That pseudo storage ID will be replaced with the real storage ID at attach time.\n\t\tconst { id: detachedStorageId } = await this.storage.createBlob(blob);\n\t\t// From the perspective of the BlobManager, the blob is now fully attached. The actual\n\t\t// upload/attach process at container attach time is treated as opaque to this tracking.\n\t\tthis.localBlobCache.set(localId, { state: \"attached\", blob });\n\t\tthis.redirectTable.set(localId, detachedStorageId);\n\t\treturn this.getNonPayloadPendingBlobHandle(localId);\n\t}\n\n\tprivate async createBlobLegacy(\n\t\tblob: ArrayBufferLike,\n\t\tsignal?: AbortSignal,\n\t): Promise<IFluidHandleInternalPayloadPending<ArrayBufferLike>> {\n\t\tconst localId = uuid();\n\t\tthis.localBlobCache.set(localId, { state: \"localOnly\", blob });\n\t\tawait this.uploadAndAttach(localId, signal);\n\t\treturn this.getNonPayloadPendingBlobHandle(localId);\n\t}\n\n\tprivate createBlobWithPayloadPending(\n\t\tblob: ArrayBufferLike,\n\t\tsignal?: AbortSignal,\n\t): IFluidHandleInternalPayloadPending<ArrayBufferLike> {\n\t\tconst localId = uuid();\n\t\tthis.localBlobCache.set(localId, { state: \"localOnly\", blob });\n\n\t\tconst blobHandle = new BlobHandle(\n\t\t\tgetGCNodePathFromLocalId(localId),\n\t\t\tthis.routeContext,\n\t\t\tasync () => blob,\n\t\t\ttrue, // payloadPending\n\t\t\t() => {\n\t\t\t\tthis.pendingBlobsWithAttachedHandles.add(localId);\n\t\t\t\tconst uploadAndAttachP = this.uploadAndAttach(localId, signal);\n\t\t\t\tuploadAndAttachP.then(blobHandle.notifyShared).catch((error) => {\n\t\t\t\t\t// TODO: notifyShared won't fail directly, but it emits an event to the customer.\n\t\t\t\t\t// Consider what to do if the customer's code throws. reportError is nice.\n\t\t\t\t});\n\t\t\t\tuploadAndAttachP.catch(blobHandle.notifyFailed);\n\t\t\t},\n\t\t);\n\n\t\treturn blobHandle;\n\t}\n\n\t/**\n\t * Upload and attach the localBlobCache entry for the given localId.\n\t *\n\t * Expects the localBlobCache entry for the given localId to be in either localOnly or uploaded state\n\t * when called. Returns a promise that resolves when the blob completes uploading and attaching, or else\n\t * rejects if an error is encountered or the signal is aborted.\n\t */\n\tprivate readonly uploadAndAttach = async (\n\t\tlocalId: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<void> => {\n\t\tif (signal?.aborted === true) {\n\t\t\tthis.localBlobCache.delete(localId);\n\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\tthrow createAbortError();\n\t\t}\n\t\tconst localBlobRecordInitial = this.localBlobCache.get(localId);\n\t\tassert(\n\t\t\tlocalBlobRecordInitial?.state === \"localOnly\" ||\n\t\t\t\tlocalBlobRecordInitial?.state === \"uploaded\",\n\t\t\t0xc80 /* Expect uploadAndAttach to be called with either localOnly or uploaded state */,\n\t\t);\n\t\tconst { blob } = localBlobRecordInitial;\n\n\t\t/**\n\t\t * Expects the localBlobCache entry for the given localId to be in either localOnly or uploaded state\n\t\t * when called. Returns a promise that resolves when the blob is in uploaded or attached state, or else\n\t\t * rejects on error during upload or if the signal is aborted.\n\t\t *\n\t\t * Most of the time this should be expected to exit in uploaded state, but if we are loading from pending\n\t\t * state we may see an attach message from the client that generated the pending state, which can complete the\n\t\t * attach while the upload is outstanding.\n\t\t */\n\t\tconst ensureUploaded = async (): Promise<void> => {\n\t\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\t\tif (localBlobRecord?.state === \"uploaded\") {\n\t\t\t\t// In normal creation flows, the blob will be in localOnly state here. But in the case of loading\n\t\t\t\t// with pending state we can call it with an uploaded-but-not-attached blob. Start the upload\n\t\t\t\t// flow only if it's localOnly.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tassert(\n\t\t\t\tlocalBlobRecord?.state === \"localOnly\",\n\t\t\t\t0xc81 /* Attempting to upload from unexpected state */,\n\t\t\t);\n\n\t\t\tthis.localBlobCache.set(localId, { state: \"uploading\", blob });\n\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\t// If we eventually have driver-level support for abort, then this can simplify a bit as we won't\n\t\t\t\t// need to track upload completion and abort separately. Until then, we need to handle the case that\n\t\t\t\t// the upload continues and settles after becoming irrelevant due to signal abort or blob attach.\n\t\t\t\tlet uploadHasBecomeIrrelevant = false;\n\t\t\t\tconst onSignalAbort = (): void => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tuploadHasBecomeIrrelevant = true;\n\t\t\t\t\tthis.localBlobCache.delete(localId);\n\t\t\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\t\t\treject(createAbortError());\n\t\t\t\t};\n\t\t\t\tconst onProcessedBlobAttach = (_localId: string, _storageId: string): void => {\n\t\t\t\t\tif (_localId === localId) {\n\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\tuploadHasBecomeIrrelevant = true;\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst removeListeners = (): void => {\n\t\t\t\t\tthis.internalEvents.off(\"processedBlobAttach\", onProcessedBlobAttach);\n\t\t\t\t\tsignal?.removeEventListener(\"abort\", onSignalAbort);\n\t\t\t\t};\n\t\t\t\tthis.internalEvents.on(\"processedBlobAttach\", onProcessedBlobAttach);\n\t\t\t\tsignal?.addEventListener(\"abort\", onSignalAbort);\n\n\t\t\t\tthis.storage\n\t\t\t\t\t.createBlob(blob)\n\t\t\t\t\t.then((createBlobResponse: ICreateBlobResponseWithTTL) => {\n\t\t\t\t\t\tif (!uploadHasBecomeIrrelevant) {\n\t\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\t\tthis.localBlobCache.set(localId, {\n\t\t\t\t\t\t\t\tstate: \"uploaded\",\n\t\t\t\t\t\t\t\tblob,\n\t\t\t\t\t\t\t\tstorageId: createBlobResponse.id,\n\t\t\t\t\t\t\t\tuploadTime: Date.now(),\n\t\t\t\t\t\t\t\tminTTLInSeconds: createBlobResponse.minTTLInSeconds,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error) => {\n\t\t\t\t\t\tif (!uploadHasBecomeIrrelevant) {\n\t\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\t\t// If the storage call errors, we can't recover. Reject to throw back to the caller.\n\t\t\t\t\t\t\tthis.localBlobCache.delete(localId);\n\t\t\t\t\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n\t\t\t\t\t\t\treject(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t});\n\t\t};\n\n\t\t/**\n\t\t * Expects the localBlobCache entry for the given localId to be in uploaded or attached state when called.\n\t\t * Returns a promise that resolves to true if the blob is successfully attached, or false if it cannot be\n\t\t * attached and the upload flow needs to be restarted from the top (currently only if the TTL expires before\n\t\t * attach can be completed). In the latter case, the localBlobRecord will also be reset to localOnly state.\n\t\t * The promise rejects if the signal is aborted.\n\t\t */\n\t\tconst tryAttach = async (): Promise<boolean> => {\n\t\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\t\tif (localBlobRecord?.state === \"attached\") {\n\t\t\t\t// In normal creation flows, the blob will be in uploaded state here. But if we are loading from pending\n\t\t\t\t// state and see an attach message from the client that generated the pending state, we may have reached\n\t\t\t\t// attached state in the middle of the upload attempt. In that case there's no more work to do and we\n\t\t\t\t// can just return.\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tassert(\n\t\t\t\tlocalBlobRecord?.state === \"uploaded\",\n\t\t\t\t0xc82 /* Attempting to attach from unexpected state */,\n\t\t\t);\n\n\t\t\t// If we just uploaded the blob TTL really shouldn't be expired at this location. But if we loaded from\n\t\t\t// pending state, the upload may have happened some time far in the past and could be expired here.\n\t\t\tif (isTTLTooCloseToExpiry(localBlobRecord)) {\n\t\t\t\t// If the TTL is expired, we assume it's gone from the storage and so is effectively localOnly again.\n\t\t\t\t// Then when we re-enter the loop, we'll re-upload it.\n\t\t\t\tthis.localBlobCache.set(localId, { state: \"localOnly\", blob });\n\t\t\t\t// Emitting here isn't really necessary since the only listener would be attached below. Including here\n\t\t\t\t// for completeness though, in case we add other listeners in the future.\n\t\t\t\tthis.internalEvents.emit(\"blobExpired\", localId);\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\tthis.localBlobCache.set(localId, {\n\t\t\t\t\t...localBlobRecord,\n\t\t\t\t\tstate: \"attaching\",\n\t\t\t\t});\n\n\t\t\t\t// Send and await a blob attach op. This serves two purposes:\n\t\t\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\t\t// until its storage ID is added to the next summary.\n\t\t\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\t\t// blob from the server via the storage ID.\n\t\t\t\treturn new Promise<boolean>((resolve, reject) => {\n\t\t\t\t\tconst onProcessedBlobAttach = (_localId: string, _storageId: string): void => {\n\t\t\t\t\t\tif (_localId === localId) {\n\t\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\t// Although we already checked for TTL expiry above, the message we're about to send may later be asked\n\t\t\t\t\t// to resubmit. Before we resubmit, we check again for TTL expiry - this listener is how we learn if\n\t\t\t\t\t// we discovered expiry in the resubmit flow.\n\t\t\t\t\tconst onBlobExpired = (_localId: string): void => {\n\t\t\t\t\t\tif (_localId === localId) {\n\t\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\t\tresolve(false);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\tconst onSignalAbort = (): void => {\n\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\tthis.localBlobCache.delete(localId);\n\t\t\t\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\t\t\t\treject(createAbortError());\n\t\t\t\t\t};\n\t\t\t\t\tconst removeListeners = (): void => {\n\t\t\t\t\t\tthis.internalEvents.off(\"processedBlobAttach\", onProcessedBlobAttach);\n\t\t\t\t\t\tthis.internalEvents.off(\"blobExpired\", onBlobExpired);\n\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onSignalAbort);\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.internalEvents.on(\"processedBlobAttach\", onProcessedBlobAttach);\n\t\t\t\t\tthis.internalEvents.on(\"blobExpired\", onBlobExpired);\n\t\t\t\t\tsignal?.addEventListener(\"abort\", onSignalAbort);\n\t\t\t\t\tthis.sendBlobAttachMessage(localId, localBlobRecord.storageId);\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\n\t\tlet attachCompleted = false;\n\t\twhile (!attachCompleted) {\n\t\t\tawait ensureUploaded();\n\t\t\tattachCompleted = await tryAttach();\n\n\t\t\t// If something stopped the attach from completing successfully (currently just TTL expiry),\n\t\t\t// we expect that the blob was already updated to reflect the updated state (i.e. back to localOnly)\n\t\t\t// and we'll try the loop again from the top.\n\t\t}\n\t\t// When the blob successfully attaches, the localBlobRecord will have been updated to attached state\n\t\t// at the time we processed the op, so there's nothing else to do here.\n\t};\n\n\t/**\n\t * Resubmit a BlobAttach op. Used to add storage IDs to messages that were\n\t * submitted to runtime while disconnected.\n\t * @param metadata - message metadata containing storage and/or local IDs\n\t */\n\tpublic reSubmit(metadata: Record<string, unknown> | undefined): void {\n\t\tassert(isBlobMetadata(metadata), 0xc01 /* Expected blob metadata for a BlobAttach op */);\n\t\tconst { localId, blobId: storageId } = metadata;\n\t\t// Any blob that we're actively trying to advance to attached state must be in attaching state.\n\t\t// Decline to resubmit for anything else.\n\t\t// For example, we might be asked to resubmit stashed messages for blobs that never had their handle\n\t\t// attached - these won't have a localBlobCache entry because we filter them out when generating\n\t\t// pending state. We shouldn't try to attach them since they won't be accessible to the customer\n\t\t// and would just be considered garbage immediately.\n\t\t// TODO: Is it possible that we'd be asked to resubmit for a pending blob before we call sharePendingBlobs?\n\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\tif (localBlobRecord?.state === \"attaching\") {\n\t\t\t// If the TTL is expired, we assume it's gone from the storage and so is effectively localOnly again.\n\t\t\tif (isTTLTooCloseToExpiry(localBlobRecord)) {\n\t\t\t\tthis.localBlobCache.set(localId, { state: \"localOnly\", blob: localBlobRecord.blob });\n\t\t\t\tthis.internalEvents.emit(\"blobExpired\", localId);\n\t\t\t} else {\n\t\t\t\tthis.sendBlobAttachMessage(localId, storageId);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic processBlobAttachMessage(message: ISequencedMessageEnvelope, local: boolean): void {\n\t\tassert(\n\t\t\tisBlobMetadata(message.metadata),\n\t\t\t0xc02 /* Expected blob metadata for a BlobAttach op */,\n\t\t);\n\t\tconst { localId, blobId: storageId } = message.metadata;\n\t\tconst maybeLocalBlobRecord = this.localBlobCache.get(localId);\n\t\tif (maybeLocalBlobRecord !== undefined) {\n\t\t\tconst attachedBlobRecord: AttachedBlob = {\n\t\t\t\tstate: \"attached\",\n\t\t\t\tblob: maybeLocalBlobRecord.blob,\n\t\t\t};\n\t\t\t// Processing a blob attach message is authoritative and may stomp on any existing state. Other\n\t\t\t// callsites that update localBlobCache entries must take proper caution to handle the case\n\t\t\t// that a blob attach message is processed concurrently.\n\t\t\tthis.localBlobCache.set(localId, attachedBlobRecord);\n\t\t\t// Note there may or may not be an entry in pendingBlobsWithAttachedHandles for this localId,\n\t\t\t// in particular for the non-payloadPending case since we should be reaching this point\n\t\t\t// before even returning a handle to the caller.\n\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\tthis.pendingOnlyLocalIds.delete(localId);\n\t\t}\n\t\tthis.redirectTable.set(localId, storageId);\n\t\t// set identity (id -> id) entry\n\t\tthis.redirectTable.set(storageId, storageId);\n\t\tthis.internalEvents.emit(\"processedBlobAttach\", localId, storageId);\n\t}\n\n\tpublic summarize(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {\n\t\treturn summarizeBlobManagerState(this.redirectTable);\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\t// Don't report the identity mappings to GC - these exist to service old handles that referenced the storage\n\t\t\t// IDs directly. We'll implicitly clean them up if all of their localId references get GC'd first.\n\t\t\tif (localId !== storageId) {\n\t\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\t// by adding its handle to a referenced DDS.\n\t\t\t\tgcData.gcNodes[getGCNodePathFromLocalId(localId)] = [];\n\t\t\t}\n\t\t}\n\t\treturn gcData;\n\t}\n\n\t/**\n\t * Delete blobs with the given routes from the redirect table.\n\t * @returns The routes of blobs that were deleted.\n\t *\n\t * @remarks\n\t * The routes are GC nodes paths of format -`/<blobManagerBasePath>/<localId>`.\n\t * Deleting the blobs involves 2 steps:\n\t *\n\t * 1. The redirect table entry for the local ids are deleted.\n\t *\n\t * 2. If the storage ids corresponding to the deleted local ids are not referenced by any further local ids, the\n\t * identity mappings in the redirect table 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 ensure we don't create an attachment blob for them at the next summary. The service would then delete them\n\t * some time in the future.\n\t */\n\tpublic deleteSweepReadyNodes(sweepReadyBlobRoutes: readonly string[]): readonly string[] {\n\t\t// maybeUnusedStorageIds is used to compute the set of storage IDs that *used to have a local ID*, but that\n\t\t// local ID is being deleted.\n\t\tconst maybeUnusedStorageIds: Set<string> = new Set();\n\t\tfor (const route of sweepReadyBlobRoutes) {\n\t\t\tconst localId = getLocalIdFromGCNodePath(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 messages 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\tconst storageId = this.redirectTable.get(localId);\n\t\t\tif (storageId === undefined) {\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: localId,\n\t\t\t\t\tdetails: { alreadyDeleted },\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tmaybeUnusedStorageIds.add(storageId);\n\t\t\tthis.redirectTable.delete(localId);\n\t\t}\n\n\t\t// Remove any storage IDs that still have local IDs referring to them (excluding the identity mapping).\n\t\tfor (const [localId, storageId] of this.redirectTable) {\n\t\t\tif (localId !== storageId) {\n\t\t\t\tmaybeUnusedStorageIds.delete(storageId);\n\t\t\t}\n\t\t}\n\n\t\t// Now delete any identity mappings (storage ID -> storage ID) from the redirect table that used to be\n\t\t// referenced by a distinct local ID. This way they'll be absent from the next summary, and the service\n\t\t// is free to delete them from storage.\n\t\t// WARNING: This can potentially delete identity mappings that are still referenced, if storage deduping\n\t\t// has let us add a local ID -> storage ID mapping that is later deleted. AB#47337 tracks this issue\n\t\t// and possible solutions.\n\t\tfor (const storageId of maybeUnusedStorageIds) {\n\t\t\tthis.redirectTable.delete(storageId);\n\t\t}\n\t\treturn [...sweepReadyBlobRoutes];\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(localId: string): void {\n\t\tif (!this.isBlobDeleted(getGCNodePathFromLocalId(localId))) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst request = { url: localId };\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\t/**\n\t * Called in detached state just prior to attaching, this will update the redirect table by\n\t * converting the pseudo storage IDs into real storage IDs using the provided detachedStorageTable.\n\t * The provided table must have exactly the same set of pseudo storage IDs as are found in the redirect table.\n\t * @param detachedStorageTable - A map of pseudo storage IDs to real storage IDs.\n\t */\n\tpublic readonly patchRedirectTable = (detachedStorageTable: Map<string, string>): void => {\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\t// The values of the redirect table are the pseudo storage IDs, which are the keys of the\n\t\t// detachedStorageTable. We expect to have a many:1 mapping from local IDs to pseudo\n\t\t// storage IDs (many in the case that the storage dedupes the blob).\n\t\tassert(\n\t\t\tnew Set(this.redirectTable.values()).size === detachedStorageTable.size,\n\t\t\t0x391 /* Redirect table size must match BlobManager's local ID count */,\n\t\t);\n\t\t// Taking a snapshot of the redirect table entries before iterating, because\n\t\t// we will be adding identity mappings to the the redirect table as we iterate\n\t\t// and we don't want to include those in the iteration.\n\t\tconst redirectTableEntries = [...this.redirectTable.entries()];\n\t\tfor (const [localId, detachedStorageId] of redirectTableEntries) {\n\t\t\tconst newStorageId = detachedStorageTable.get(detachedStorageId);\n\t\t\tassert(newStorageId !== undefined, 0xc53 /* Couldn't find a matching storage ID */);\n\t\t\tthis.redirectTable.set(localId, newStorageId);\n\t\t\t// set identity (id -> id) entry\n\t\t\tthis.redirectTable.set(newStorageId, newStorageId);\n\t\t}\n\t};\n\n\t/**\n\t * Upload and attach any pending blobs that the BlobManager was loaded with that have not already\n\t * been attached in the meantime.\n\t * @returns A promise that resolves when all the uploads and attaches have completed, or rejects\n\t * if any of them fail.\n\t */\n\tpublic readonly sharePendingBlobs = async (): Promise<void> => {\n\t\tconst localIdsToUpload = [...this.pendingOnlyLocalIds];\n\t\tthis.pendingOnlyLocalIds.clear();\n\t\tawait Promise.all<void>(\n\t\t\tlocalIdsToUpload.map(async (localId) => this.uploadAndAttach(localId)),\n\t\t);\n\t};\n\n\t/**\n\t * To be used in getPendingLocalState flow. Get a serializable record of the blobs that are\n\t * pending upload and/or their BlobAttach op, which can be given to a new BlobManager to\n\t * resume work.\n\t */\n\tpublic getPendingBlobs(): IPendingBlobs | undefined {\n\t\tconst pendingBlobs: IPendingBlobs = {};\n\t\tfor (const localId of this.pendingBlobsWithAttachedHandles) {\n\t\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\t\tassert(localBlobRecord !== undefined, 0xc83 /* Pending blob must be in local cache */);\n\t\t\tassert(\n\t\t\t\tlocalBlobRecord.state !== \"attached\",\n\t\t\t\t0xc84 /* Pending blob must not be in attached state */,\n\t\t\t);\n\t\t\t// We downgrade uploading blobs to localOnly, and attaching blobs to uploaded. In the case of\n\t\t\t// uploading blobs, we don't have a way to retrieve the eventual storageId so the upload will\n\t\t\t// need to be restarted anyway. In the case of attaching blobs, we can't know whether the\n\t\t\t// BlobAttach message will eventually be ack'd. So we assume we'll need to send another message, but also\n\t\t\t// remain prepared to handle seeing the ack of the original message after loading from pending state.\n\t\t\tpendingBlobs[localId] =\n\t\t\t\tlocalBlobRecord.state === \"localOnly\" || localBlobRecord.state === \"uploading\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tstate: \"localOnly\",\n\t\t\t\t\t\t\tblob: bufferToString(localBlobRecord.blob, \"base64\"),\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\t...localBlobRecord,\n\t\t\t\t\t\t\tstate: \"uploaded\",\n\t\t\t\t\t\t\tblob: bufferToString(localBlobRecord.blob, \"base64\"),\n\t\t\t\t\t\t};\n\t\t}\n\t\treturn Object.keys(pendingBlobs).length > 0 ? pendingBlobs : undefined;\n\t}\n}\n\n/**\n * For a localId, returns its path in GC's graph. The node path is of the format `/<blobManagerBasePath>/<localId>`.\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 */\nexport const getGCNodePathFromLocalId = (localId: string): string =>\n\t`/${blobManagerBasePath}/${localId}`;\n\n/**\n * For a given GC node path, return the localId. The node path is of the format `/<basePath>/<localId>`.\n */\nconst getLocalIdFromGCNodePath = (nodePath: string): 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\nconst 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,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC7F,OAAO,EACN,WAAW,GAEX,MAAM,gDAAgD,CAAC;AAexD,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAQ7D,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,GACnB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACN,YAAY,EAEZ,gBAAgB,EAChB,4BAA4B,GAC5B,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EACN,yBAAyB,EACzB,eAAe,GAEf,MAAM,yBAAyB,CAAC;AAEjC;;;;;;GAMG;AACH,MAAM,OAAO,UACZ,SAAQ,eAAgC;IAOxC,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,IAAI,IAAI,CAAC,QAAQ,CAAC;IACtD,CAAC;IAKD,IAAW,MAAM;QAChB,OAAO,CAAC,IAAI,CAAC,OAAO,KAAK,aAAa,EAA2B,CAAC,CAAC;IACpE,CAAC;IAGD,IAAW,YAAY;QACtB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;IAOD,IAAW,iBAAiB;QAC3B,OA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AG,CAAC,CAAC,CAAC;AAEnC,MAAM,gBAAgB,GAAG,CACxB,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 { bufferToString, createEmitter, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport {\n\tAttachState,\n\ttype IContainerStorageService,\n} from \"@fluidframework/container-definitions/internal\";\nimport type {\n\tIContainerRuntime,\n\tIContainerRuntimeEvents,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tIEmitter,\n\tIEventProvider,\n\tIFluidHandleContext,\n\tIFluidHandleInternalPayloadPending,\n\tILocalFluidHandle,\n\tILocalFluidHandleEvents,\n\tListenable,\n\tPayloadState,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { ICreateBlobResponse } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tIGarbageCollectionData,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tFluidHandleBase,\n\tcreateResponseError,\n\tgenerateHandleContextPath,\n\tresponseToException,\n} from \"@fluidframework/runtime-utils/internal\";\nimport {\n\tLoggingError,\n\ttype MonitoringContext,\n\tPerformanceEvent,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { isBlobMetadata } from \"../metadata.js\";\n\nimport {\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\n\textends FluidHandleBase<ArrayBufferLike>\n\timplements\n\t\tILocalFluidHandle<ArrayBufferLike>,\n\t\tIFluidHandleInternalPayloadPending<ArrayBufferLike>\n{\n\tprivate attached: boolean = false;\n\n\tpublic get isAttached(): boolean {\n\t\treturn this.routeContext.isAttached && this.attached;\n\t}\n\n\tprivate _events:\n\t\t| (Listenable<ILocalFluidHandleEvents> & IEmitter<ILocalFluidHandleEvents>)\n\t\t| undefined;\n\tpublic get events(): Listenable<ILocalFluidHandleEvents> {\n\t\treturn (this._events ??= createEmitter<ILocalFluidHandleEvents>());\n\t}\n\n\tprivate _payloadState: PayloadState;\n\tpublic get payloadState(): PayloadState {\n\t\treturn this._payloadState;\n\t}\n\n\t/**\n\t * The error property starts undefined, signalling that there has been no error yet.\n\t * If an error occurs, the property will contain the error.\n\t */\n\tprivate _payloadShareError: unknown;\n\tpublic get payloadShareError(): unknown {\n\t\treturn this._payloadShareError;\n\t}\n\n\tpublic readonly absolutePath: string;\n\n\tpublic constructor(\n\t\tpublic readonly path: string,\n\t\tpublic readonly routeContext: IFluidHandleContext,\n\t\t// TODO: just take the blob rather than a get function?\n\t\tpublic get: () => Promise<ArrayBufferLike>,\n\t\tpublic readonly payloadPending: boolean,\n\t\tprivate readonly onAttachGraph?: () => void,\n\t) {\n\t\tsuper();\n\t\tthis._payloadState = payloadPending ? \"pending\" : \"shared\";\n\t\tthis.absolutePath = generateHandleContextPath(path, this.routeContext);\n\t}\n\n\tpublic readonly notifyShared = (): void => {\n\t\tthis._payloadState = \"shared\";\n\t\tthis._events?.emit(\"payloadShared\");\n\t};\n\n\tpublic readonly notifyFailed = (error: unknown): void => {\n\t\tthis._payloadShareError = error;\n\t\tthis._events?.emit(\"payloadShareFailed\", error);\n\t};\n\n\tpublic attachGraph(): void {\n\t\tif (!this.attached) {\n\t\t\tthis.attached = true;\n\t\t\tthis.onAttachGraph?.();\n\t\t}\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\" | \"baseLogger\" | \"disposed\"\n> &\n\tIEventProvider<IContainerRuntimeEvents>;\n\nexport type ICreateBlobResponseWithTTL = ICreateBlobResponse &\n\tPartial<Record<\"minTTLInSeconds\", number>>;\n\n/**\n * A blob tracked by BlobManager that is only available on the local client. It is not currently\n * attempting an upload.\n */\ninterface LocalOnlyBlob {\n\tstate: \"localOnly\";\n\tblob: ArrayBufferLike;\n}\n\n/**\n * A blob tracked by BlobManager that is only known to be available on the local client, but is in\n * the process of being uploaded to storage.\n */\ninterface UploadingBlob {\n\tstate: \"uploading\";\n\tblob: ArrayBufferLike;\n}\n\n/**\n * A blob tracked by BlobManager that has been uploaded to storage. If the TTL has not expired, it\n * should still be available in storage. It is not currently attempting to send a BlobAttach op.\n */\ninterface UploadedBlob {\n\tstate: \"uploaded\";\n\tblob: ArrayBufferLike;\n\tstorageId: string;\n\tuploadTime: number;\n\tminTTLInSeconds: number | undefined;\n}\n\n/**\n * A blob tracked by BlobManager that has been uploaded to storage and is in the process of sending\n * a BlobAttach message and waiting for the ack.\n */\ninterface AttachingBlob {\n\tstate: \"attaching\";\n\tblob: ArrayBufferLike;\n\tstorageId: string;\n\tuploadTime: number;\n\tminTTLInSeconds: number | undefined;\n}\n\n/**\n * A blob tracked by BlobManager that has been uploaded to storage and its BlobAttach message has been\n * ack'd. It is fully shared and available to all clients, and is no longer considered pending.\n */\ninterface AttachedBlob {\n\tstate: \"attached\";\n\tblob: ArrayBufferLike;\n}\n\n/**\n * Blobs that were created locally are tracked, and may be in one of these states. When first\n * created, they are in localOnly state. The process of sharing has two steps, blob upload and\n * sending a BlobAttach op. Progress through the stages may regress back to localOnly if we\n * determine the storage may have deleted the blob before we could finish attaching it.\n */\ntype LocalBlobRecord =\n\t| LocalOnlyBlob\n\t| UploadingBlob\n\t| UploadedBlob\n\t| AttachingBlob\n\t| AttachedBlob;\n\n/**\n * Serializable form of the LocalBlobRecord that can be used to save and restore pending state.\n * Omits attached blobs since they are fully uploaded and don't need to be saved and restored.\n * Omits uploading and attaching states since upon restore we will need to restart those processes.\n */\nexport type SerializableLocalBlobRecord =\n\t| (Omit<LocalOnlyBlob, \"blob\"> & { blob: string })\n\t| (Omit<UploadedBlob, \"blob\"> & { blob: string });\n\nexport interface IPendingBlobs {\n\t[localId: string]: SerializableLocalBlobRecord;\n}\n\n/**\n * Check if for a given uploaded or attaching blob, the TTL is too close to expiry to safely attempt\n * an attach. Currently using a heuristic of half the TTL duration having passed since upload.\n */\nconst isTTLTooCloseToExpiry = (blobRecord: UploadedBlob | AttachingBlob): boolean =>\n\tblobRecord.minTTLInSeconds !== undefined &&\n\tDate.now() - blobRecord.uploadTime > (blobRecord.minTTLInSeconds / 2) * 1000;\n\ninterface IBlobManagerInternalEvents {\n\tblobExpired: (localId: string) => void;\n\thandleAttached: (pending: LocalBlobRecord) => void;\n\tprocessedBlobAttach: (localId: string, storageId: string) => void;\n}\n\nconst createAbortError = (): LoggingError => new LoggingError(\"uploadBlob aborted\");\n\n/**\n * @internal\n */\nexport const blobManagerBasePath = \"_blobs\";\n\nexport class BlobManager {\n\tprivate readonly mc: MonitoringContext;\n\n\tprivate readonly internalEvents = createEmitter<IBlobManagerInternalEvents>();\n\n\t/**\n\t * Map of local IDs to storage IDs. Also includes identity mappings of storage ID to storage ID for all known\n\t * storage IDs. All requested IDs must be a key in this map. Blobs created while the container is detached are\n\t * stored in IDetachedBlobStorage which gives pseudo storage IDs; the real storage IDs are filled in at attach\n\t * time via setRedirectTable().\n\t */\n\tprivate readonly redirectTable: Map<string, string>;\n\n\t/**\n\t * The localBlobCache has a dual role of caching locally-created blobs, as well as tracking their state as they\n\t * are shared. Keys are localIds.\n\t */\n\tprivate readonly localBlobCache: Map<string, LocalBlobRecord> = new Map();\n\t/**\n\t * Blobs with an attached handle that have not finished blob-attaching are the set we need to provide from\n\t * getPendingState(). This stores their local IDs, and then we can look them up against the localBlobCache.\n\t */\n\tprivate readonly pendingBlobsWithAttachedHandles: Set<string> = new Set();\n\t/**\n\t * Local IDs for any pending blobs we loaded with and have not yet started the upload/attach flow for.\n\t */\n\tprivate readonly pendingOnlyLocalIds: Set<string> = new Set();\n\n\tprivate readonly sendBlobAttachMessage: (localId: string, storageId: string) => void;\n\n\tprivate readonly routeContext: IFluidHandleContext;\n\tprivate readonly storage: Pick<IContainerStorageService, \"createBlob\" | \"readBlob\">;\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>/<localId>`.\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>/<localId>`.\n\tprivate readonly isBlobDeleted: (blobPath: string) => boolean;\n\tprivate readonly runtime: IBlobManagerRuntime;\n\n\tprivate readonly createBlobPayloadPending: boolean;\n\n\tpublic constructor(props: {\n\t\treadonly routeContext: IFluidHandleContext;\n\n\t\tblobManagerLoadInfo: IBlobManagerLoadInfo;\n\t\treadonly storage: Pick<IContainerStorageService, \"createBlob\" | \"readBlob\">;\n\t\t/**\n\t\t * Submit a BlobAttach message. When a blob is uploaded, there is a short grace period before which the blob is\n\t\t * deleted. The BlobAttach message 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 message.\n\t\t *\n\t\t * The message 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 message is sequenced\n\t\t * before any messages that reference the local ID, otherwise, an invalid handle could be added to the document.\n\t\t */\n\t\tsendBlobAttachMessage: (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>/<localId>`.\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>/<localId>`.\n\t\treadonly isBlobDeleted: (blobPath: string) => boolean;\n\t\treadonly runtime: IBlobManagerRuntime;\n\t\tpendingBlobs: IPendingBlobs | undefined;\n\t\treadonly createBlobPayloadPending: boolean;\n\t}) {\n\t\tconst {\n\t\t\trouteContext,\n\t\t\tblobManagerLoadInfo,\n\t\t\tstorage,\n\t\t\tsendBlobAttachMessage,\n\t\t\tblobRequested,\n\t\t\tisBlobDeleted,\n\t\t\truntime,\n\t\t\tpendingBlobs,\n\t\t\tcreateBlobPayloadPending,\n\t\t} = props;\n\t\tthis.routeContext = routeContext;\n\t\tthis.storage = storage;\n\t\tthis.sendBlobAttachMessage = sendBlobAttachMessage;\n\t\tthis.blobRequested = blobRequested;\n\t\tthis.isBlobDeleted = isBlobDeleted;\n\t\tthis.runtime = runtime;\n\t\tthis.createBlobPayloadPending = createBlobPayloadPending;\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(blobManagerLoadInfo, this.mc.logger);\n\n\t\t// We populate the localBlobCache with any pending blobs we are provided, which makes them available\n\t\t// to access even though they are not shared yet. However, we don't start the share flow until it is\n\t\t// explicitly invoked via sharePendingBlobs() in case we are loaded in a frozen container.\n\t\tif (pendingBlobs !== undefined) {\n\t\t\tfor (const [localId, serializableBlobRecord] of Object.entries(pendingBlobs)) {\n\t\t\t\tassert(\n\t\t\t\t\t!this.redirectTable.has(localId),\n\t\t\t\t\t0xc7e /* Pending blob already in redirect table */,\n\t\t\t\t);\n\t\t\t\tconst localBlobRecord = {\n\t\t\t\t\t...serializableBlobRecord,\n\t\t\t\t\tblob: stringToBuffer(serializableBlobRecord.blob, \"base64\"),\n\t\t\t\t};\n\t\t\t\tthis.localBlobCache.set(localId, localBlobRecord);\n\t\t\t\t// Since we received these blobs from pending state, we'll assume they were only added to the\n\t\t\t\t// pending state at generation time because their handles were attached. We add them back here\n\t\t\t\t// in case we need to round-trip them back out again due to another getPendingBlobs() call.\n\t\t\t\tthis.pendingBlobsWithAttachedHandles.add(localId);\n\t\t\t\tthis.pendingOnlyLocalIds.add(localId);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns whether a blob with the given localId can be retrieved by the BlobManager via getBlob().\n\t */\n\tpublic hasBlob(localId: string): boolean {\n\t\treturn this.redirectTable.has(localId) || this.localBlobCache.has(localId);\n\t}\n\n\t/**\n\t * Lookup the blob storage ID for a given local blob id.\n\t * @param localId - The local blob id. Likely coming from a handle.\n\t * @returns The storage ID if found and the blob is not pending, undefined otherwise.\n\t * @remarks\n\t * For blobs with pending payloads (localId exists but upload hasn't finished), this is expected to return undefined.\n\t * Consumers should use the observability APIs on the handle (handle.payloadState, payloadShared event)\n\t * to understand/wait for storage ID availability.\n\t * Similarly, when the runtime is detached, this will return undefined as no blobs have been uploaded to storage.\n\t */\n\tpublic lookupTemporaryBlobStorageId(localId: string): string | undefined {\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\treturn undefined;\n\t\t}\n\t\t// Get the storage ID from the redirect table\n\t\treturn this.redirectTable.get(localId);\n\t}\n\n\t/**\n\t * Retrieve the blob with the given local blob id.\n\t * @param localId - The local blob id. Likely coming from a handle.\n\t * @param payloadPending - Whether we suspect the payload may be pending and not available yet.\n\t * @returns A promise which resolves to the blob contents\n\t */\n\tpublic async getBlob(localId: string, payloadPending: boolean): 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(localId);\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(getGCNodePathFromLocalId(localId));\n\n\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\tif (localBlobRecord !== undefined) {\n\t\t\treturn localBlobRecord.blob;\n\t\t}\n\n\t\tlet storageId = this.redirectTable.get(localId);\n\t\tif (storageId === undefined) {\n\t\t\t// Only blob handles explicitly marked with pending payload are permitted to exist without\n\t\t\t// yet knowing their storage id. Otherwise they must already be associated with a storage id.\n\t\t\t// Handles for detached blobs are not payload pending, though they should also always be present\n\t\t\t// in the localBlobCache and therefore should never need to refer to storage.\n\t\t\tassert(payloadPending, 0x11f /* \"requesting unknown blobs\" */);\n\t\t\t// If we didn't find it in the redirectTable and it's payloadPending, assume the attach message is coming\n\t\t\t// eventually and wait. We do this even if the local client doesn't have the blob payloadPending flag\n\t\t\t// enabled, in case a remote client does have it enabled. This wait may be infinite if the uploading\n\t\t\t// client failed the upload and doesn't exist anymore.\n\t\t\t// TODO: Fix this violation and remove the disable\n\t\t\t// eslint-disable-next-line require-atomic-updates\n\t\t\tstorageId = await new Promise<string>((resolve) => {\n\t\t\t\tconst onProcessBlobAttach = (_localId: string, _storageId: string): void => {\n\t\t\t\t\tif (_localId === localId) {\n\t\t\t\t\t\tthis.internalEvents.off(\"processedBlobAttach\", onProcessBlobAttach);\n\t\t\t\t\t\tresolve(_storageId);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tthis.internalEvents.on(\"processedBlobAttach\", onProcessBlobAttach);\n\t\t\t});\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 (event) => {\n\t\t\t\treturn this.storage.readBlob(storageId).catch((error) => {\n\t\t\t\t\tif (this.runtime.disposed) {\n\t\t\t\t\t\t// If the runtime is disposed, this is not an error we care to track, it's expected behavior.\n\t\t\t\t\t\tevent.cancel({ category: \"generic\" });\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t\t},\n\t\t\t{ end: true, cancel: \"error\" },\n\t\t);\n\t}\n\n\tprivate getNonPayloadPendingBlobHandle(localId: string): BlobHandle {\n\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\tassert(localBlobRecord !== undefined, 0x384 /* requesting handle for unknown blob */);\n\t\tassert(localBlobRecord.state === \"attached\", 0xc7f /* Expected blob to be attached */);\n\n\t\treturn new BlobHandle(\n\t\t\tgetGCNodePathFromLocalId(localId),\n\t\t\tthis.routeContext,\n\t\t\tasync () => this.getBlob(localId, false),\n\t\t\tfalse, // payloadPending\n\t\t);\n\t}\n\n\tpublic async createBlob(\n\t\tblob: ArrayBufferLike,\n\t\tsignal?: AbortSignal,\n\t): Promise<IFluidHandleInternalPayloadPending<ArrayBufferLike>> {\n\t\tif (this.runtime.attachState === AttachState.Detached) {\n\t\t\treturn this.createBlobDetached(blob, signal);\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\treturn this.createBlobPayloadPending\n\t\t\t? this.createBlobWithPayloadPending(blob, signal)\n\t\t\t: this.createBlobLegacy(blob, signal);\n\t}\n\n\tprivate async createBlobDetached(\n\t\tblob: ArrayBufferLike,\n\t\tsignal?: AbortSignal,\n\t): Promise<IFluidHandleInternalPayloadPending<ArrayBufferLike>> {\n\t\tif (signal?.aborted === true) {\n\t\t\tthrow createAbortError();\n\t\t}\n\t\tconst localId = uuid();\n\t\tthis.localBlobCache.set(localId, { state: \"uploading\", blob });\n\t\t// Blobs created while the container is detached are stored in IDetachedBlobStorage.\n\t\t// The 'IContainerStorageService.createBlob()' call below will respond with a pseudo storage ID.\n\t\t// That pseudo storage ID will be replaced with the real storage ID at attach time.\n\t\tconst { id: detachedStorageId } = await this.storage.createBlob(blob);\n\t\t// From the perspective of the BlobManager, the blob is now fully attached. The actual\n\t\t// upload/attach process at container attach time is treated as opaque to this tracking.\n\t\tthis.localBlobCache.set(localId, { state: \"attached\", blob });\n\t\tthis.redirectTable.set(localId, detachedStorageId);\n\t\treturn this.getNonPayloadPendingBlobHandle(localId);\n\t}\n\n\tprivate async createBlobLegacy(\n\t\tblob: ArrayBufferLike,\n\t\tsignal?: AbortSignal,\n\t): Promise<IFluidHandleInternalPayloadPending<ArrayBufferLike>> {\n\t\tconst localId = uuid();\n\t\tthis.localBlobCache.set(localId, { state: \"localOnly\", blob });\n\t\tawait this.uploadAndAttach(localId, signal);\n\t\treturn this.getNonPayloadPendingBlobHandle(localId);\n\t}\n\n\tprivate createBlobWithPayloadPending(\n\t\tblob: ArrayBufferLike,\n\t\tsignal?: AbortSignal,\n\t): IFluidHandleInternalPayloadPending<ArrayBufferLike> {\n\t\tconst localId = uuid();\n\t\tthis.localBlobCache.set(localId, { state: \"localOnly\", blob });\n\n\t\tconst blobHandle = new BlobHandle(\n\t\t\tgetGCNodePathFromLocalId(localId),\n\t\t\tthis.routeContext,\n\t\t\tasync () => blob,\n\t\t\ttrue, // payloadPending\n\t\t\t() => {\n\t\t\t\tthis.pendingBlobsWithAttachedHandles.add(localId);\n\t\t\t\tconst uploadAndAttachP = this.uploadAndAttach(localId, signal);\n\t\t\t\tuploadAndAttachP.then(blobHandle.notifyShared).catch((error) => {\n\t\t\t\t\t// TODO: notifyShared won't fail directly, but it emits an event to the customer.\n\t\t\t\t\t// Consider what to do if the customer's code throws. reportError is nice.\n\t\t\t\t});\n\t\t\t\tuploadAndAttachP.catch(blobHandle.notifyFailed);\n\t\t\t},\n\t\t);\n\n\t\treturn blobHandle;\n\t}\n\n\t/**\n\t * Upload and attach the localBlobCache entry for the given localId.\n\t *\n\t * Expects the localBlobCache entry for the given localId to be in either localOnly or uploaded state\n\t * when called. Returns a promise that resolves when the blob completes uploading and attaching, or else\n\t * rejects if an error is encountered or the signal is aborted.\n\t */\n\tprivate readonly uploadAndAttach = async (\n\t\tlocalId: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<void> => {\n\t\tif (signal?.aborted === true) {\n\t\t\tthis.localBlobCache.delete(localId);\n\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\tthrow createAbortError();\n\t\t}\n\t\tconst localBlobRecordInitial = this.localBlobCache.get(localId);\n\t\tassert(\n\t\t\tlocalBlobRecordInitial?.state === \"localOnly\" ||\n\t\t\t\tlocalBlobRecordInitial?.state === \"uploaded\",\n\t\t\t0xc80 /* Expect uploadAndAttach to be called with either localOnly or uploaded state */,\n\t\t);\n\t\tconst { blob } = localBlobRecordInitial;\n\n\t\t/**\n\t\t * Expects the localBlobCache entry for the given localId to be in either localOnly or uploaded state\n\t\t * when called. Returns a promise that resolves when the blob is in uploaded or attached state, or else\n\t\t * rejects on error during upload or if the signal is aborted.\n\t\t *\n\t\t * Most of the time this should be expected to exit in uploaded state, but if we are loading from pending\n\t\t * state we may see an attach message from the client that generated the pending state, which can complete the\n\t\t * attach while the upload is outstanding.\n\t\t */\n\t\tconst ensureUploaded = async (): Promise<void> => {\n\t\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\t\tif (localBlobRecord?.state === \"uploaded\") {\n\t\t\t\t// In normal creation flows, the blob will be in localOnly state here. But in the case of loading\n\t\t\t\t// with pending state we can call it with an uploaded-but-not-attached blob. Start the upload\n\t\t\t\t// flow only if it's localOnly.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tassert(\n\t\t\t\tlocalBlobRecord?.state === \"localOnly\",\n\t\t\t\t0xc81 /* Attempting to upload from unexpected state */,\n\t\t\t);\n\n\t\t\tthis.localBlobCache.set(localId, { state: \"uploading\", blob });\n\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\t// If we eventually have driver-level support for abort, then this can simplify a bit as we won't\n\t\t\t\t// need to track upload completion and abort separately. Until then, we need to handle the case that\n\t\t\t\t// the upload continues and settles after becoming irrelevant due to signal abort or blob attach.\n\t\t\t\tlet uploadHasBecomeIrrelevant = false;\n\t\t\t\tconst onSignalAbort = (): void => {\n\t\t\t\t\tremoveListeners();\n\t\t\t\t\tuploadHasBecomeIrrelevant = true;\n\t\t\t\t\tthis.localBlobCache.delete(localId);\n\t\t\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\t\t\treject(createAbortError());\n\t\t\t\t};\n\t\t\t\tconst onProcessedBlobAttach = (_localId: string, _storageId: string): void => {\n\t\t\t\t\tif (_localId === localId) {\n\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\tuploadHasBecomeIrrelevant = true;\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst removeListeners = (): void => {\n\t\t\t\t\tthis.internalEvents.off(\"processedBlobAttach\", onProcessedBlobAttach);\n\t\t\t\t\tsignal?.removeEventListener(\"abort\", onSignalAbort);\n\t\t\t\t};\n\t\t\t\tthis.internalEvents.on(\"processedBlobAttach\", onProcessedBlobAttach);\n\t\t\t\tsignal?.addEventListener(\"abort\", onSignalAbort);\n\n\t\t\t\tthis.storage\n\t\t\t\t\t.createBlob(blob)\n\t\t\t\t\t.then((createBlobResponse: ICreateBlobResponseWithTTL) => {\n\t\t\t\t\t\tif (!uploadHasBecomeIrrelevant) {\n\t\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\t\tthis.localBlobCache.set(localId, {\n\t\t\t\t\t\t\t\tstate: \"uploaded\",\n\t\t\t\t\t\t\t\tblob,\n\t\t\t\t\t\t\t\tstorageId: createBlobResponse.id,\n\t\t\t\t\t\t\t\tuploadTime: Date.now(),\n\t\t\t\t\t\t\t\tminTTLInSeconds: createBlobResponse.minTTLInSeconds,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error) => {\n\t\t\t\t\t\tif (!uploadHasBecomeIrrelevant) {\n\t\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\t\t// If the storage call errors, we can't recover. Reject to throw back to the caller.\n\t\t\t\t\t\t\tthis.localBlobCache.delete(localId);\n\t\t\t\t\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n\t\t\t\t\t\t\treject(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t});\n\t\t};\n\n\t\t/**\n\t\t * Expects the localBlobCache entry for the given localId to be in uploaded or attached state when called.\n\t\t * Returns a promise that resolves to true if the blob is successfully attached, or false if it cannot be\n\t\t * attached and the upload flow needs to be restarted from the top (currently only if the TTL expires before\n\t\t * attach can be completed). In the latter case, the localBlobRecord will also be reset to localOnly state.\n\t\t * The promise rejects if the signal is aborted.\n\t\t */\n\t\tconst tryAttach = async (): Promise<boolean> => {\n\t\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\t\tif (localBlobRecord?.state === \"attached\") {\n\t\t\t\t// In normal creation flows, the blob will be in uploaded state here. But if we are loading from pending\n\t\t\t\t// state and see an attach message from the client that generated the pending state, we may have reached\n\t\t\t\t// attached state in the middle of the upload attempt. In that case there's no more work to do and we\n\t\t\t\t// can just return.\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tassert(\n\t\t\t\tlocalBlobRecord?.state === \"uploaded\",\n\t\t\t\t0xc82 /* Attempting to attach from unexpected state */,\n\t\t\t);\n\n\t\t\t// If we just uploaded the blob TTL really shouldn't be expired at this location. But if we loaded from\n\t\t\t// pending state, the upload may have happened some time far in the past and could be expired here.\n\t\t\tif (isTTLTooCloseToExpiry(localBlobRecord)) {\n\t\t\t\t// If the TTL is expired, we assume it's gone from the storage and so is effectively localOnly again.\n\t\t\t\t// Then when we re-enter the loop, we'll re-upload it.\n\t\t\t\tthis.localBlobCache.set(localId, { state: \"localOnly\", blob });\n\t\t\t\t// Emitting here isn't really necessary since the only listener would be attached below. Including here\n\t\t\t\t// for completeness though, in case we add other listeners in the future.\n\t\t\t\tthis.internalEvents.emit(\"blobExpired\", localId);\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\tthis.localBlobCache.set(localId, {\n\t\t\t\t\t...localBlobRecord,\n\t\t\t\t\tstate: \"attaching\",\n\t\t\t\t});\n\n\t\t\t\t// Send and await a blob attach op. This serves two purposes:\n\t\t\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\t\t// until its storage ID is added to the next summary.\n\t\t\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\t\t// blob from the server via the storage ID.\n\t\t\t\treturn new Promise<boolean>((resolve, reject) => {\n\t\t\t\t\tconst onProcessedBlobAttach = (_localId: string, _storageId: string): void => {\n\t\t\t\t\t\tif (_localId === localId) {\n\t\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\t// Although we already checked for TTL expiry above, the message we're about to send may later be asked\n\t\t\t\t\t// to resubmit. Before we resubmit, we check again for TTL expiry - this listener is how we learn if\n\t\t\t\t\t// we discovered expiry in the resubmit flow.\n\t\t\t\t\tconst onBlobExpired = (_localId: string): void => {\n\t\t\t\t\t\tif (_localId === localId) {\n\t\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\t\tresolve(false);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\tconst onSignalAbort = (): void => {\n\t\t\t\t\t\tremoveListeners();\n\t\t\t\t\t\tthis.localBlobCache.delete(localId);\n\t\t\t\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\t\t\t\treject(createAbortError());\n\t\t\t\t\t};\n\t\t\t\t\tconst removeListeners = (): void => {\n\t\t\t\t\t\tthis.internalEvents.off(\"processedBlobAttach\", onProcessedBlobAttach);\n\t\t\t\t\t\tthis.internalEvents.off(\"blobExpired\", onBlobExpired);\n\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onSignalAbort);\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.internalEvents.on(\"processedBlobAttach\", onProcessedBlobAttach);\n\t\t\t\t\tthis.internalEvents.on(\"blobExpired\", onBlobExpired);\n\t\t\t\t\tsignal?.addEventListener(\"abort\", onSignalAbort);\n\t\t\t\t\tthis.sendBlobAttachMessage(localId, localBlobRecord.storageId);\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\n\t\tlet attachCompleted = false;\n\t\twhile (!attachCompleted) {\n\t\t\tawait ensureUploaded();\n\t\t\tattachCompleted = await tryAttach();\n\n\t\t\t// If something stopped the attach from completing successfully (currently just TTL expiry),\n\t\t\t// we expect that the blob was already updated to reflect the updated state (i.e. back to localOnly)\n\t\t\t// and we'll try the loop again from the top.\n\t\t}\n\t\t// When the blob successfully attaches, the localBlobRecord will have been updated to attached state\n\t\t// at the time we processed the op, so there's nothing else to do here.\n\t};\n\n\t/**\n\t * Resubmit a BlobAttach op. Used to add storage IDs to messages that were\n\t * submitted to runtime while disconnected.\n\t * @param metadata - message metadata containing storage and/or local IDs\n\t */\n\tpublic reSubmit(metadata: Record<string, unknown> | undefined): void {\n\t\tassert(isBlobMetadata(metadata), 0xc01 /* Expected blob metadata for a BlobAttach op */);\n\t\tconst { localId, blobId: storageId } = metadata;\n\t\t// Any blob that we're actively trying to advance to attached state must be in attaching state.\n\t\t// Decline to resubmit for anything else.\n\t\t// For example, we might be asked to resubmit stashed messages for blobs that never had their handle\n\t\t// attached - these won't have a localBlobCache entry because we filter them out when generating\n\t\t// pending state. We shouldn't try to attach them since they won't be accessible to the customer\n\t\t// and would just be considered garbage immediately.\n\t\t// TODO: Is it possible that we'd be asked to resubmit for a pending blob before we call sharePendingBlobs?\n\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\tif (localBlobRecord?.state === \"attaching\") {\n\t\t\t// If the TTL is expired, we assume it's gone from the storage and so is effectively localOnly again.\n\t\t\tif (isTTLTooCloseToExpiry(localBlobRecord)) {\n\t\t\t\tthis.localBlobCache.set(localId, { state: \"localOnly\", blob: localBlobRecord.blob });\n\t\t\t\tthis.internalEvents.emit(\"blobExpired\", localId);\n\t\t\t} else {\n\t\t\t\tthis.sendBlobAttachMessage(localId, storageId);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic processBlobAttachMessage(message: ISequencedMessageEnvelope, local: boolean): void {\n\t\tassert(\n\t\t\tisBlobMetadata(message.metadata),\n\t\t\t0xc02 /* Expected blob metadata for a BlobAttach op */,\n\t\t);\n\t\tconst { localId, blobId: storageId } = message.metadata;\n\t\tconst maybeLocalBlobRecord = this.localBlobCache.get(localId);\n\t\tif (maybeLocalBlobRecord !== undefined) {\n\t\t\tconst attachedBlobRecord: AttachedBlob = {\n\t\t\t\tstate: \"attached\",\n\t\t\t\tblob: maybeLocalBlobRecord.blob,\n\t\t\t};\n\t\t\t// Processing a blob attach message is authoritative and may stomp on any existing state. Other\n\t\t\t// callsites that update localBlobCache entries must take proper caution to handle the case\n\t\t\t// that a blob attach message is processed concurrently.\n\t\t\tthis.localBlobCache.set(localId, attachedBlobRecord);\n\t\t\t// Note there may or may not be an entry in pendingBlobsWithAttachedHandles for this localId,\n\t\t\t// in particular for the non-payloadPending case since we should be reaching this point\n\t\t\t// before even returning a handle to the caller.\n\t\t\tthis.pendingBlobsWithAttachedHandles.delete(localId);\n\t\t\tthis.pendingOnlyLocalIds.delete(localId);\n\t\t}\n\t\tthis.redirectTable.set(localId, storageId);\n\t\t// set identity (id -> id) entry\n\t\tthis.redirectTable.set(storageId, storageId);\n\t\tthis.internalEvents.emit(\"processedBlobAttach\", localId, storageId);\n\t}\n\n\tpublic summarize(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {\n\t\treturn summarizeBlobManagerState(this.redirectTable);\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\t// Don't report the identity mappings to GC - these exist to service old handles that referenced the storage\n\t\t\t// IDs directly. We'll implicitly clean them up if all of their localId references get GC'd first.\n\t\t\tif (localId !== storageId) {\n\t\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\t// by adding its handle to a referenced DDS.\n\t\t\t\tgcData.gcNodes[getGCNodePathFromLocalId(localId)] = [];\n\t\t\t}\n\t\t}\n\t\treturn gcData;\n\t}\n\n\t/**\n\t * Delete blobs with the given routes from the redirect table.\n\t * @returns The routes of blobs that were deleted.\n\t *\n\t * @remarks\n\t * The routes are GC nodes paths of format -`/<blobManagerBasePath>/<localId>`.\n\t * Deleting the blobs involves 2 steps:\n\t *\n\t * 1. The redirect table entry for the local ids are deleted.\n\t *\n\t * 2. If the storage ids corresponding to the deleted local ids are not referenced by any further local ids, the\n\t * identity mappings in the redirect table 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 ensure we don't create an attachment blob for them at the next summary. The service would then delete them\n\t * some time in the future.\n\t */\n\tpublic deleteSweepReadyNodes(sweepReadyBlobRoutes: readonly string[]): readonly string[] {\n\t\t// maybeUnusedStorageIds is used to compute the set of storage IDs that *used to have a local ID*, but that\n\t\t// local ID is being deleted.\n\t\tconst maybeUnusedStorageIds: Set<string> = new Set();\n\t\tfor (const route of sweepReadyBlobRoutes) {\n\t\t\tconst localId = getLocalIdFromGCNodePath(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 messages 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\tconst storageId = this.redirectTable.get(localId);\n\t\t\tif (storageId === undefined) {\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: localId,\n\t\t\t\t\tdetails: { alreadyDeleted },\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tmaybeUnusedStorageIds.add(storageId);\n\t\t\tthis.redirectTable.delete(localId);\n\t\t}\n\n\t\t// Remove any storage IDs that still have local IDs referring to them (excluding the identity mapping).\n\t\tfor (const [localId, storageId] of this.redirectTable) {\n\t\t\tif (localId !== storageId) {\n\t\t\t\tmaybeUnusedStorageIds.delete(storageId);\n\t\t\t}\n\t\t}\n\n\t\t// Now delete any identity mappings (storage ID -> storage ID) from the redirect table that used to be\n\t\t// referenced by a distinct local ID. This way they'll be absent from the next summary, and the service\n\t\t// is free to delete them from storage.\n\t\t// WARNING: This can potentially delete identity mappings that are still referenced, if storage deduping\n\t\t// has let us add a local ID -> storage ID mapping that is later deleted. AB#47337 tracks this issue\n\t\t// and possible solutions.\n\t\tfor (const storageId of maybeUnusedStorageIds) {\n\t\t\tthis.redirectTable.delete(storageId);\n\t\t}\n\t\treturn [...sweepReadyBlobRoutes];\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(localId: string): void {\n\t\tif (!this.isBlobDeleted(getGCNodePathFromLocalId(localId))) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst request = { url: localId };\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\t/**\n\t * Called in detached state just prior to attaching, this will update the redirect table by\n\t * converting the pseudo storage IDs into real storage IDs using the provided detachedStorageTable.\n\t * The provided table must have exactly the same set of pseudo storage IDs as are found in the redirect table.\n\t * @param detachedStorageTable - A map of pseudo storage IDs to real storage IDs.\n\t */\n\tpublic readonly patchRedirectTable = (detachedStorageTable: Map<string, string>): void => {\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\t// The values of the redirect table are the pseudo storage IDs, which are the keys of the\n\t\t// detachedStorageTable. We expect to have a many:1 mapping from local IDs to pseudo\n\t\t// storage IDs (many in the case that the storage dedupes the blob).\n\t\tassert(\n\t\t\tnew Set(this.redirectTable.values()).size === detachedStorageTable.size,\n\t\t\t0x391 /* Redirect table size must match BlobManager's local ID count */,\n\t\t);\n\t\t// Taking a snapshot of the redirect table entries before iterating, because\n\t\t// we will be adding identity mappings to the the redirect table as we iterate\n\t\t// and we don't want to include those in the iteration.\n\t\tconst redirectTableEntries = [...this.redirectTable.entries()];\n\t\tfor (const [localId, detachedStorageId] of redirectTableEntries) {\n\t\t\tconst newStorageId = detachedStorageTable.get(detachedStorageId);\n\t\t\tassert(newStorageId !== undefined, 0xc53 /* Couldn't find a matching storage ID */);\n\t\t\tthis.redirectTable.set(localId, newStorageId);\n\t\t\t// set identity (id -> id) entry\n\t\t\tthis.redirectTable.set(newStorageId, newStorageId);\n\t\t}\n\t};\n\n\t/**\n\t * Upload and attach any pending blobs that the BlobManager was loaded with that have not already\n\t * been attached in the meantime.\n\t * @returns A promise that resolves when all the uploads and attaches have completed, or rejects\n\t * if any of them fail.\n\t */\n\tpublic readonly sharePendingBlobs = async (): Promise<void> => {\n\t\tconst localIdsToUpload = [...this.pendingOnlyLocalIds];\n\t\tthis.pendingOnlyLocalIds.clear();\n\t\tawait Promise.all<void>(\n\t\t\tlocalIdsToUpload.map(async (localId) => this.uploadAndAttach(localId)),\n\t\t);\n\t};\n\n\t/**\n\t * To be used in getPendingLocalState flow. Get a serializable record of the blobs that are\n\t * pending upload and/or their BlobAttach op, which can be given to a new BlobManager to\n\t * resume work.\n\t */\n\tpublic getPendingBlobs(): IPendingBlobs | undefined {\n\t\tconst pendingBlobs: IPendingBlobs = {};\n\t\tfor (const localId of this.pendingBlobsWithAttachedHandles) {\n\t\t\tconst localBlobRecord = this.localBlobCache.get(localId);\n\t\t\tassert(localBlobRecord !== undefined, 0xc83 /* Pending blob must be in local cache */);\n\t\t\tassert(\n\t\t\t\tlocalBlobRecord.state !== \"attached\",\n\t\t\t\t0xc84 /* Pending blob must not be in attached state */,\n\t\t\t);\n\t\t\t// We downgrade uploading blobs to localOnly, and attaching blobs to uploaded. In the case of\n\t\t\t// uploading blobs, we don't have a way to retrieve the eventual storageId so the upload will\n\t\t\t// need to be restarted anyway. In the case of attaching blobs, we can't know whether the\n\t\t\t// BlobAttach message will eventually be ack'd. So we assume we'll need to send another message, but also\n\t\t\t// remain prepared to handle seeing the ack of the original message after loading from pending state.\n\t\t\tpendingBlobs[localId] =\n\t\t\t\tlocalBlobRecord.state === \"localOnly\" || localBlobRecord.state === \"uploading\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tstate: \"localOnly\",\n\t\t\t\t\t\t\tblob: bufferToString(localBlobRecord.blob, \"base64\"),\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\t...localBlobRecord,\n\t\t\t\t\t\t\tstate: \"uploaded\",\n\t\t\t\t\t\t\tblob: bufferToString(localBlobRecord.blob, \"base64\"),\n\t\t\t\t\t\t};\n\t\t}\n\t\treturn Object.keys(pendingBlobs).length > 0 ? pendingBlobs : undefined;\n\t}\n}\n\n/**\n * For a localId, returns its path in GC's graph. The node path is of the format `/<blobManagerBasePath>/<localId>`.\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 */\nexport const getGCNodePathFromLocalId = (localId: string): string =>\n\t`/${blobManagerBasePath}/${localId}`;\n\n/**\n * For a given GC node path, return the localId. The node path is of the format `/<basePath>/<localId>`.\n */\nconst getLocalIdFromGCNodePath = (nodePath: string): 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\nconst areBlobPathParts = (\n\tpathParts: string[],\n): pathParts is [\"\", typeof blobManagerBasePath, string] =>\n\tpathParts.length === 3 && pathParts[1] === blobManagerBasePath;\n"]}
@@ -13,6 +13,9 @@ export interface IBlobManagerLoadInfo {
13
13
  ids?: string[];
14
14
  redirectTable?: [string, string][];
15
15
  }
16
+ /**
17
+ * @internal
18
+ */
16
19
  export declare const redirectTableBlobName = ".redirectTable";
17
20
  /**
18
21
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"blobManagerSnapSum.d.ts","sourceRoot":"","sources":["../../src/blobManager/blobManagerSnapSum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AAExF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAE1F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAEpF;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACpC,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,aAAa,CAAC,EAAE,CAAC,MAAM,E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sBpD,eAAO,MAAM,eAAe,wBACN,oBAAoB,UACjC,mBAAmB,KACzB,IAAI,MAAM,EAAE,MAAM,CAsBpB,CAAC;AAEF,eAAO,MAAM,yBAAyB,kBACtB,IAAI,MAAM,EAAE,MAAM,CAAC,KAChC,qBAAmD,CAAC;AA0BvD,eAAO,MAAM,aAAa,kBAAmB,IAAI,MAAM,EAAE,MAAM,CAAC,KAAG,IAAI,MAAM,CAE5E,CAAC"}
@@ -4,6 +4,9 @@
4
4
  */
5
5
  import { readAndParse } from "@fluidframework/driver-utils/internal";
6
6
  import { SummaryTreeBuilder } from "@fluidframework/runtime-utils/internal";
7
+ /**
8
+ * @internal
9
+ */
7
10
  export const redirectTableBlobName = ".redirectTable";
8
11
  /**
9
12
  * @internal
@@ -30,11 +33,15 @@ const loadV1 = async (context) => {
30
33
  return { ids, redirectTable: redirectTableEntries };
31
34
  };
32
35
  export const toRedirectTable = (blobManagerLoadInfo, logger) => {
33
- logger.sendTelemetryEvent({
34
- eventName: "AttachmentBlobsLoaded",
35
- count: blobManagerLoadInfo.ids?.length ?? 0,
36
- redirectTable: blobManagerLoadInfo.redirectTable?.length,
37
- });
36
+ const count = blobManagerLoadInfo.ids?.length ?? 0;
37
+ const redirectTableLength = blobManagerLoadInfo.redirectTable?.length ?? 0;
38
+ if (count > 0 || redirectTableLength > 0) {
39
+ logger.sendTelemetryEvent({
40
+ eventName: "AttachmentBlobsLoaded",
41
+ count,
42
+ redirectTable: redirectTableLength,
43
+ });
44
+ }
38
45
  const redirectTable = new Map(blobManagerLoadInfo.redirectTable);
39
46
  if (blobManagerLoadInfo.ids !== undefined) {
40
47
  for (const storageId of blobManagerLoadInfo.ids) {
@@ -1 +1 @@
1
- {"version":3,"file":"blobManagerSnapSum.js","sourceRoot":"","sources":["../../src/blobManager/blobManagerSnapSum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAErE,OAAO,EAAE,kBA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SAAS,CAAC,+BAA+B,CAAC,CAAC,CAAC;IACzF,CAAC;IAED,OAAO,OAAO,CAAC,cAAc,EAAE,CAAC;AACjC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,aAAkC,EAAe,EAAE;IAChF,OAAO,IAAI,GAAG,CAAS,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC;AAChD,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IContainerContext } from \"@fluidframework/container-definitions/internal\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport type { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport type { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Information from a snapshot needed to load BlobManager\n * @internal\n */\nexport interface IBlobManagerLoadInfo {\n\tids?: string[];\n\tredirectTable?: [string, string][];\n}\n\nexport const redirectTableBlobName = \".redirectTable\";\n\n/**\n * @internal\n */\nexport const blobsTreeName = \".blobs\";\n\n/**\n * Reads blobs needed to load BlobManager from storage.\n *\n */\nexport const loadBlobManagerLoadInfo = async (\n\tcontext: Pick<IContainerContext, \"baseSnapshot\" | \"storage\" | \"attachState\">,\n): Promise<IBlobManagerLoadInfo> => loadV1(context);\n\nconst loadV1 = async (\n\tcontext: Pick<IContainerContext, \"baseSnapshot\" | \"storage\" | \"attachState\">,\n): Promise<IBlobManagerLoadInfo> => {\n\tconst blobsTree = context.baseSnapshot?.trees[blobsTreeName];\n\n\tif (!blobsTree) {\n\t\treturn {};\n\t}\n\tlet redirectTableEntries: [string, string][] = [];\n\tconst tableId: string | undefined = blobsTree.blobs[redirectTableBlobName];\n\tif (tableId) {\n\t\tredirectTableEntries = await readAndParse(context.storage, tableId);\n\t}\n\tconst ids = Object.entries(blobsTree.blobs)\n\t\t.filter(([k, _]) => k !== redirectTableBlobName)\n\t\t.map(([_, v]) => v);\n\n\treturn { ids, redirectTable: redirectTableEntries };\n};\n\nexport const toRedirectTable = (\n\tblobManagerLoadInfo: IBlobManagerLoadInfo,\n\tlogger: ITelemetryLoggerExt,\n): Map<string, string> => {\n\tlogger.sendTelemetryEvent({\n\t\teventName: \"AttachmentBlobsLoaded\",\n\t\tcount: blobManagerLoadInfo.ids?.length ?? 0,\n\t\tredirectTable: blobManagerLoadInfo.redirectTable?.length,\n\t});\n\tconst redirectTable = new Map<string, string>(blobManagerLoadInfo.redirectTable);\n\tif (blobManagerLoadInfo.ids !== undefined) {\n\t\tfor (const storageId of blobManagerLoadInfo.ids) {\n\t\t\t// Older versions of the runtime used the storage ID directly in the handle,\n\t\t\t// rather than routing through the redirectTable. To support old handles that\n\t\t\t// were created in this way but unify handling through the redirectTable, we\n\t\t\t// add identity mappings to the redirect table at load. These identity entries\n\t\t\t// will be excluded during summarization.\n\t\t\tredirectTable.set(storageId, storageId);\n\t\t}\n\t}\n\treturn redirectTable;\n};\n\nexport const summarizeBlobManagerState = (\n\tredirectTable: Map<string, string>,\n): ISummaryTreeWithStats => summarizeV1(redirectTable);\n\nconst summarizeV1 = (redirectTable: Map<string, string>): ISummaryTreeWithStats => {\n\tconst builder = new SummaryTreeBuilder();\n\tconst storageIds = getStorageIds(redirectTable);\n\tfor (const storageId of storageIds) {\n\t\t// The Attachment is inspectable by storage, which lets it detect that the blob is referenced\n\t\t// and therefore should not be GC'd.\n\t\tbuilder.addAttachment(storageId);\n\t}\n\n\t// Exclude identity mappings from the redirectTable summary. Note that\n\t// the storageIds of the identity mappings are still included in the Attachments\n\t// above, so we expect these identity mappings will be recreated at load\n\t// time in toRedirectTable even if there is no non-identity mapping in\n\t// the redirectTable.\n\tconst nonIdentityRedirectTableEntries = [...redirectTable.entries()].filter(\n\t\t([localId, storageId]) => localId !== storageId,\n\t);\n\tif (nonIdentityRedirectTableEntries.length > 0) {\n\t\tbuilder.addBlob(redirectTableBlobName, JSON.stringify(nonIdentityRedirectTableEntries));\n\t}\n\n\treturn builder.getSummaryTree();\n};\n\nexport const getStorageIds = (redirectTable: Map<string, string>): Set<string> => {\n\treturn new Set<string>(redirectTable.values());\n};\n"]}
1
+ {"version":3,"file":"blobManagerSnapSum.js","sourceRoot":"","sources":["../../src/blobManager/blobManagerSnapSum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAY5E;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAEtD;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CAAC;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAC3C,OAA4E,EAC5C,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAEpD,MAAM,MAAM,GAAG,KAAK,EACnB,OAA4E,EAC5C,EAAE;IAClC,MAAM,SAAS,GAAG,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAE7D,IAAI,CAAC,SAAS,EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACX,CAAC;IACD,IAAI,oBAAoB,GAAuB,EAAE,CAAC;IAClD,MAAM,OAAO,GAAuB,SAAS,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC3E,IAAI,OAAO,EAAE,CAAC;QACb,oBAAoB,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC;SACzC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,qBAAqB,CAAC;SAC/C,G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,CAAC;IAChD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACpC,6FAA6F;QAC7F,oCAAoC;QACpC,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;IAED,sEAAsE;IACtE,gFAAgF;IAChF,wEAAwE;IACxE,sEAAsE;IACtE,qBAAqB;IACrB,MAAM,+BAA+B,GAAG,CAAC,GAAG,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAC1E,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,OAAO,KAAK,SAAS,CAC/C,CAAC;IACF,IAAI,+BAA+B,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChD,OAAO,CAAC,OAAO,CAAC,qBAAqB,EAAE,IAAI,CAAC,SAAS,CAAC,+BAA+B,CAAC,CAAC,CAAC;IACzF,CAAC;IAED,OAAO,OAAO,CAAC,cAAc,EAAE,CAAC;AACjC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,aAAkC,EAAe,EAAE;IAChF,OAAO,IAAI,GAAG,CAAS,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC;AAChD,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IContainerContext } from \"@fluidframework/container-definitions/internal\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport type { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\nimport type { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * Information from a snapshot needed to load BlobManager\n * @internal\n */\nexport interface IBlobManagerLoadInfo {\n\tids?: string[];\n\tredirectTable?: [string, string][];\n}\n\n/**\n * @internal\n */\nexport const redirectTableBlobName = \".redirectTable\";\n\n/**\n * @internal\n */\nexport const blobsTreeName = \".blobs\";\n\n/**\n * Reads blobs needed to load BlobManager from storage.\n *\n */\nexport const loadBlobManagerLoadInfo = async (\n\tcontext: Pick<IContainerContext, \"baseSnapshot\" | \"storage\" | \"attachState\">,\n): Promise<IBlobManagerLoadInfo> => loadV1(context);\n\nconst loadV1 = async (\n\tcontext: Pick<IContainerContext, \"baseSnapshot\" | \"storage\" | \"attachState\">,\n): Promise<IBlobManagerLoadInfo> => {\n\tconst blobsTree = context.baseSnapshot?.trees[blobsTreeName];\n\n\tif (!blobsTree) {\n\t\treturn {};\n\t}\n\tlet redirectTableEntries: [string, string][] = [];\n\tconst tableId: string | undefined = blobsTree.blobs[redirectTableBlobName];\n\tif (tableId) {\n\t\tredirectTableEntries = await readAndParse(context.storage, tableId);\n\t}\n\tconst ids = Object.entries(blobsTree.blobs)\n\t\t.filter(([k, _]) => k !== redirectTableBlobName)\n\t\t.map(([_, v]) => v);\n\n\treturn { ids, redirectTable: redirectTableEntries };\n};\n\nexport const toRedirectTable = (\n\tblobManagerLoadInfo: IBlobManagerLoadInfo,\n\tlogger: ITelemetryLoggerExt,\n): Map<string, string> => {\n\tconst count = blobManagerLoadInfo.ids?.length ?? 0;\n\tconst redirectTableLength = blobManagerLoadInfo.redirectTable?.length ?? 0;\n\tif (count > 0 || redirectTableLength > 0) {\n\t\tlogger.sendTelemetryEvent({\n\t\t\teventName: \"AttachmentBlobsLoaded\",\n\t\t\tcount,\n\t\t\tredirectTable: redirectTableLength,\n\t\t});\n\t}\n\tconst redirectTable = new Map<string, string>(blobManagerLoadInfo.redirectTable);\n\tif (blobManagerLoadInfo.ids !== undefined) {\n\t\tfor (const storageId of blobManagerLoadInfo.ids) {\n\t\t\t// Older versions of the runtime used the storage ID directly in the handle,\n\t\t\t// rather than routing through the redirectTable. To support old handles that\n\t\t\t// were created in this way but unify handling through the redirectTable, we\n\t\t\t// add identity mappings to the redirect table at load. These identity entries\n\t\t\t// will be excluded during summarization.\n\t\t\tredirectTable.set(storageId, storageId);\n\t\t}\n\t}\n\treturn redirectTable;\n};\n\nexport const summarizeBlobManagerState = (\n\tredirectTable: Map<string, string>,\n): ISummaryTreeWithStats => summarizeV1(redirectTable);\n\nconst summarizeV1 = (redirectTable: Map<string, string>): ISummaryTreeWithStats => {\n\tconst builder = new SummaryTreeBuilder();\n\tconst storageIds = getStorageIds(redirectTable);\n\tfor (const storageId of storageIds) {\n\t\t// The Attachment is inspectable by storage, which lets it detect that the blob is referenced\n\t\t// and therefore should not be GC'd.\n\t\tbuilder.addAttachment(storageId);\n\t}\n\n\t// Exclude identity mappings from the redirectTable summary. Note that\n\t// the storageIds of the identity mappings are still included in the Attachments\n\t// above, so we expect these identity mappings will be recreated at load\n\t// time in toRedirectTable even if there is no non-identity mapping in\n\t// the redirectTable.\n\tconst nonIdentityRedirectTableEntries = [...redirectTable.entries()].filter(\n\t\t([localId, storageId]) => localId !== storageId,\n\t);\n\tif (nonIdentityRedirectTableEntries.length > 0) {\n\t\tbuilder.addBlob(redirectTableBlobName, JSON.stringify(nonIdentityRedirectTableEntries));\n\t}\n\n\treturn builder.getSummaryTree();\n};\n\nexport const getStorageIds = (redirectTable: Map<string, string>): Set<string> => {\n\treturn new Set<string>(redirectTable.values());\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"connectionTelemetry.d.ts","sourceRoot":"","sources":["../src/connectionTelemetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wDAAwD,CAAC;AACtG,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAiB5F;;GAEG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAC;AA+arC;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACpC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,YAAY,EAAE,iBAAiB,EAC/B,sBAAsB,EAAE,cAAc,CAAC,uBAAuB,CAAC,EAC/D,MAAM,EAAE,oBAAoB,GAC1B,IAAI,CAON"}
1
+ {"version":3,"file":"connectionTelemetry.d.ts","sourceRoot":"","sources":["../src/connectionTelemetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wDAAwD,CAAC;AACtG,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAkB5F;;GAEG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAmbrC;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACpC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,YAAY,EAAE,iBAAiB,EAC/B,sBAAsB,EAAE,cAAc,CAAC,uBAAuB,CAAC,EAC/D,MAAM,EAAE,oBAAoB,GAC1B,IAAI,CAON"}
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { performanceNow } from "@fluid-internal/client-utils";
6
+ import { LogLevel } from "@fluidframework/core-interfaces";
6
7
  import { assert } from "@fluidframework/core-utils/internal";
7
8
  import { MessageType, } from "@fluidframework/driver-definitions/internal";
8
9
  import { isRuntimeMessage } from "@fluidframework/driver-utils/internal";
@@ -184,7 +185,8 @@ class OpPerfTelemetry {
184
185
  ? formatTick(this.connectionStartTime - this.bootTime)
185
186
  : undefined,
186
187
  firstConnection: this.firstConnection,
187
- });
188
+ }, undefined, // error
189
+ LogLevel.info);
188
190
  }
189
191
  recordPingTime(latency) {
190
192
  this.pingLatency = latency;
@@ -1 +1 @@
1
- {"version":3,"file":"connectionTelemetry.js","sourceRoot":"","sources":["../src/connectionTelemetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAI9D,OAAO,EAAE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AQ;gBACR,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,WAAW,EACV,IAAI,CAAC,YAAY,CAAC,kBAAkB,GAAG,IAAI,CAAC,YAAY,CAAC,qBAAqB;gBAC/E,GAAG,WAAW,CAAC,UAAU;aACzB,CAAC,CAAC;YAEH,IAAI,CAAC,wCAAwC,GAAG,SAAS,CAAC;YAC1D,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;QAC7D,CAAC;QAED,IAAI,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,+FAA+F;YAC/F,0EAA0E;YAC1E,gHAAgH;YAChH,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;gBACnC,SAAS,EAAE,SAAS;gBACpB,qFAAqF;gBACrF,OAAO,EAAE;oBACR,iFAAiF;oBACjF,yDAAyD;oBACzD,gBAAgB,EAAE,eAAe,CAAC,yBAAyB;oBAC3D,kGAAkG;oBAClG,eAAe,EAAE,IAAI,CAAC,2BAA2B;oBACjD,oFAAoF;oBACpF,iBAAiB,EAAE,IAAI,CAAC,qBAAqB;iBAC7C;aACD,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;;AA5VuB,sCAAsB,GAAG,GAAG,AAAN,CAAO;AAG7B,yCAAyB,GAAG,GAAG,AAAN,CAAO;AAGhC,yCAAyB,GAAG,GAAG,AAAN,CAAO;AAyVzD;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACpC,QAA4B,EAC5B,YAA+B,EAC/B,sBAA+D,EAC/D,MAA4B;IAE5B,IAAI,eAAe,CAClB,QAAQ,EACR,YAAY,EACZ,sBAAsB,EACtB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC,CAC7B,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performanceNow } from \"@fluid-internal/client-utils\";\nimport type { IDeltaManagerFull } from \"@fluidframework/container-definitions/internal\";\nimport type { IContainerRuntimeEvents } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type { ITelemetryBaseLogger, IEventProvider } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype IDocumentMessage,\n\tMessageType,\n\ttype ISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { isRuntimeMessage } from \"@fluidframework/driver-utils/internal\";\nimport {\n\ttype IEventSampler,\n\ttype ITelemetryLoggerExt,\n\ttype ISampledTelemetryLogger,\n\tcreateChildLogger,\n\tcreateSampledLogger,\n\tformatTick,\n} from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * We report various latency-related errors when waiting for op roundtrip takes longer than that amout of time.\n */\nexport const latencyThreshold = 5000;\n\n// Phases in OpPerfTelemetry:\n// 1.\tOp is added to DeltaManager (DM) buffer.\n// 2.\tOp is sent to service (op leaves outbound queue).\n// \t - Note: We do not know for sure when op is sent, we only track when it is added to outbound queue.\n// If outbound queue is paused, time queue is paused is counted as network time.\n// 3.\tOp received from service back (pushed to inbound queue).\n// 4.\tOp is processed.\ninterface IOpPerfTelemetryProperties {\n\t/**\n\t * Measure time between (1) and (2) - Measure time outbound op is sitting in queue due to active batch\n\t */\n\tdurationOutboundBatching: number; // was durationOutboundQueue in previous versions\n\t/**\n\t * Measure time between (2) and (3) - Track how long it took for op to be acked by service\n\t */\n\tdurationNetwork: number; // was durationInboundQueue\n\t/**\n\t * Measure time between (3) and (4) - Time between DM's inbound \"push\" event until DM's \"op\" event\n\t */\n\tdurationInboundToProcessing: number;\n\t/**\n\t * Length of the DeltaManager's inbound queue at the time of the DM's inbound \"push\" event (3)\n\t */\n\tlengthInboundQueue: number;\n}\n\n/**\n * Timings collected at various moments during the op processing.\n */\ninterface IOpPerfTimings {\n\t/**\n\t * Starting time for (1)\n\t */\n\tsubmitOpEventTime: number;\n\t/**\n\t * Starting time for (2)\n\t */\n\toutboundPushEventTime: number;\n\t/**\n\t * Starting time for (3)\n\t */\n\tinboundPushEventTime: number;\n}\n\nclass OpPerfTelemetry {\n\tprivate pingLatency: number | undefined;\n\n\t// Collab window tracking. This is timestamp of %1000 message.\n\tprivate sequenceNumberForMsnTracking: number | undefined;\n\tprivate msnTrackingTimestamp: number = 0;\n\t// To track round trip time for every %500 client message.\n\tprivate clientSequenceNumberForLatencyStatistics: number | undefined;\n\t// Performance Data to be reported for ops round trips and processing.\n\tprivate readonly latencyStatistics = new Map<\n\t\tnumber,\n\t\t{\n\t\t\topProcessingTimes: Partial<IOpPerfTimings>;\n\t\t\topPerfData: Partial<IOpPerfTelemetryProperties>;\n\t\t}\n\t>();\n\n\tprivate firstConnection = true;\n\tprivate connectionOpSeqNumber: number | undefined;\n\tprivate readonly bootTime = performanceNow();\n\tprivate connectionStartTime = 0;\n\tprivate gap = 0;\n\n\t/**\n\t * Count of no-ops sent by this client. This variable is reset everytime the OpStats sampled event is logged\n\t */\n\tprivate noOpCountForTelemetry = 0;\n\t/**\n\t * Cumulative size of the ops processed by this client. This variable is reset everytime the OpStats sampled event is logged\n\t */\n\tprivate processedOpSizeForTelemetry = 0;\n\n\tprivate readonly logger: ITelemetryLoggerExt;\n\n\tprivate static readonly OP_LATENCY_SAMPLE_RATE = 500;\n\tprivate readonly opLatencyLogger: ISampledTelemetryLogger;\n\n\tprivate static readonly DELTA_LATENCY_SAMPLE_RATE = 100;\n\tprivate readonly deltaLatencyLogger: ISampledTelemetryLogger;\n\n\tprivate static readonly PROCESSED_OPS_SAMPLE_RATE = 500;\n\n\t/**\n\t * A sampled logger to log Ops that have been processed by the current client, the NoOp sent and the\n\t * size of the ops processed within one sampling window of this log event.\n\t * The data from this logger will be used to monitor the efficiency of NoOp-heuristics or to get approximate collab window size.\n\t * Note: no log events are sent when sampling is disabled, because logging at every op will be too noisy.\n\t */\n\tprivate readonly opsLogger: ISampledTelemetryLogger;\n\n\t/**\n\t * Create an instance of OpPerfTelemetry which starts monitoring and generating telemetry related to op performance.\n\t *\n\t * @param clientId - The clientId of the current container.\n\t * @param deltaManager - DeltaManager instance to monitor.\n\t * @param containerRuntimeEvents - Emitter of events for the container runtime.\n\t * @param logger - Telemetry logger to write events to.\n\t */\n\tpublic constructor(\n\t\t/**\n\t\t * The clientId of the current container.\n\t\t *\n\t\t * @remarks Until the container connects to the server and receives an ack for its own join op, this can be undefined.\n\t\t * It gets updated in response to event changes once the value provided by the server is available.\n\t\t * If the container loses its connection, this could be the last known clientId.\n\t\t */\n\t\tprivate clientId: string | undefined,\n\t\t/**\n\t\t * DeltaManager instance to monitor.\n\t\t */\n\t\tprivate readonly deltaManager: IDeltaManagerFull,\n\t\t/**\n\t\t * Emitter of events for the container runtime.\n\t\t */\n\t\tcontainerRuntimeEvents: IEventProvider<IContainerRuntimeEvents>,\n\t\t/**\n\t\t * Telemetry logger to write events to.\n\t\t */\n\t\tlogger: ITelemetryLoggerExt,\n\t) {\n\t\tthis.logger = createChildLogger({ logger, namespace: \"OpPerf\" });\n\n\t\tconst deltaLatencyEventSampler: IEventSampler = (() => {\n\t\t\tlet eventCount = -1;\n\t\t\treturn {\n\t\t\t\tsample: () => {\n\t\t\t\t\teventCount++;\n\t\t\t\t\tconst shouldSample = eventCount % OpPerfTelemetry.DELTA_LATENCY_SAMPLE_RATE === 0;\n\t\t\t\t\tif (shouldSample) {\n\t\t\t\t\t\teventCount = 0;\n\t\t\t\t\t}\n\t\t\t\t\treturn shouldSample;\n\t\t\t\t},\n\t\t\t};\n\t\t})();\n\n\t\tthis.deltaLatencyLogger = createSampledLogger(logger, deltaLatencyEventSampler);\n\n\t\t// The SampledLogger here is used get access to the isSamplingDisabled property derived from\n\t\t// telemetry config properties. The actual sampling logic for op messages happens outside this SampledLogger\n\t\t// due to complexity of the different asynchronus scenarios of the op message lifecycle.\n\t\tthis.opLatencyLogger = createSampledLogger(logger);\n\n\t\tconst opsEventSampler: IEventSampler = (() => {\n\t\t\tlet eventCount = 0;\n\t\t\treturn {\n\t\t\t\tsample: () => {\n\t\t\t\t\teventCount++;\n\t\t\t\t\tconst shouldSample = eventCount % OpPerfTelemetry.PROCESSED_OPS_SAMPLE_RATE === 0;\n\t\t\t\t\tif (shouldSample) {\n\t\t\t\t\t\teventCount = 0;\n\t\t\t\t\t\tthis.noOpCountForTelemetry = 0;\n\t\t\t\t\t\tthis.processedOpSizeForTelemetry = 0;\n\t\t\t\t\t}\n\t\t\t\t\treturn shouldSample;\n\t\t\t\t},\n\t\t\t};\n\t\t})();\n\t\tthis.opsLogger = createSampledLogger(\n\t\t\tlogger,\n\t\t\topsEventSampler,\n\t\t\ttrue /* skipLoggingWhenSamplingIsDisabled */,\n\t\t);\n\n\t\tthis.deltaManager.on(\"pong\", (latency) => this.recordPingTime(latency));\n\t\tthis.deltaManager.on(\"submitOp\", (message) => this.beforeOpSubmit(message));\n\t\tthis.deltaManager.on(\"op\", (message) => this.afterProcessingOp(message));\n\t\tthis.deltaManager.on(\"connect\", (details, opsBehind) => {\n\t\t\tif (opsBehind !== undefined) {\n\t\t\t\tthis.connectionOpSeqNumber = this.deltaManager.lastKnownSeqNumber;\n\t\t\t\tthis.gap = opsBehind;\n\t\t\t\tthis.connectionStartTime = performanceNow();\n\n\t\t\t\t// We might be already up-today. If so, report it right away.\n\t\t\t\tif (this.gap <= 0) {\n\t\t\t\t\tthis.reportGettingUpToDate();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tthis.deltaManager.on(\"disconnect\", () => {\n\t\t\tthis.sequenceNumberForMsnTracking = undefined;\n\t\t\tthis.clientSequenceNumberForLatencyStatistics = undefined;\n\t\t\tthis.connectionOpSeqNumber = undefined;\n\t\t\tthis.firstConnection = false;\n\t\t\tthis.latencyStatistics.clear();\n\t\t});\n\n\t\tthis.deltaManager.outbound.on(\"push\", (messages) => {\n\t\t\tfor (const msg of messages) {\n\t\t\t\tif (\n\t\t\t\t\tmsg.type === MessageType.Operation &&\n\t\t\t\t\t(this.opLatencyLogger.isSamplingDisabled ||\n\t\t\t\t\t\tthis.clientSequenceNumberForLatencyStatistics === msg.clientSequenceNumber)\n\t\t\t\t) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tconst latencyStats = this.latencyStatistics.get(msg.clientSequenceNumber)!;\n\t\t\t\t\tassert(latencyStats !== undefined, 0x7c2 /* Latency stats for op should exist */);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tlatencyStats.opProcessingTimes.outboundPushEventTime === undefined,\n\t\t\t\t\t\t0x2c8 /* \"outboundPushEventTime should be undefined\" */,\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tlatencyStats.opPerfData.durationNetwork === undefined,\n\t\t\t\t\t\t0x2c9 /* \"durationNetwork should be undefined\" */,\n\t\t\t\t\t);\n\t\t\t\t\tlatencyStats.opProcessingTimes.outboundPushEventTime = Date.now();\n\n\t\t\t\t\tassert(\n\t\t\t\t\t\tlatencyStats.opPerfData.durationOutboundBatching === undefined,\n\t\t\t\t\t\t0x2ca /* \"durationOutboundBatching should be undefined\" */,\n\t\t\t\t\t);\n\n\t\t\t\t\tassert(\n\t\t\t\t\t\tlatencyStats.opProcessingTimes.submitOpEventTime !== undefined,\n\t\t\t\t\t\t0x2cb /* \"submitOpEventTime should be undefined\" */,\n\t\t\t\t\t);\n\n\t\t\t\t\tlatencyStats.opPerfData.durationOutboundBatching =\n\t\t\t\t\t\tlatencyStats.opProcessingTimes.outboundPushEventTime -\n\t\t\t\t\t\tlatencyStats.opProcessingTimes.submitOpEventTime;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis.deltaManager.inbound.on(\"push\", (message: ISequencedDocumentMessage) => {\n\t\t\tif (\n\t\t\t\tthis.clientId === message.clientId &&\n\t\t\t\tmessage.type === MessageType.Operation &&\n\t\t\t\t(this.opLatencyLogger.isSamplingDisabled ||\n\t\t\t\t\tthis.clientSequenceNumberForLatencyStatistics === message.clientSequenceNumber)\n\t\t\t) {\n\t\t\t\t// We do an explicit check for undefined right after this\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst latencyStats = this.latencyStatistics.get(message.clientSequenceNumber)!;\n\t\t\t\tassert(latencyStats !== undefined, 0x7c3 /* Latency stats for op should exist */);\n\t\t\t\tif (latencyStats.opProcessingTimes.outboundPushEventTime !== undefined) {\n\t\t\t\t\tlatencyStats.opProcessingTimes.inboundPushEventTime = Date.now();\n\t\t\t\t\tlatencyStats.opPerfData.durationNetwork =\n\t\t\t\t\t\tlatencyStats.opProcessingTimes.inboundPushEventTime -\n\t\t\t\t\t\tlatencyStats.opProcessingTimes.outboundPushEventTime;\n\t\t\t\t\tlatencyStats.opPerfData.lengthInboundQueue = this.deltaManager.inbound.length;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (isRuntimeMessage(message) && typeof message.contents === \"string\") {\n\t\t\t\tthis.processedOpSizeForTelemetry += message.contents.length;\n\t\t\t}\n\t\t});\n\n\t\tthis.deltaManager.inbound.on(\"idle\", (count: number, duration: number) => {\n\t\t\t// Do not want to log zero for sure.\n\t\t\t// We are more interested in aggregates, so logging only if we are processing some number of ops\n\t\t\t// Cut-off is arbitrary - can be increased or decreased based on amount of data collected and questions we\n\t\t\t// want to get answered\n\t\t\t// back-compat: Once 0.36 loader version saturates (count & duration args were added there),\n\t\t\t// we can remove typeof check.\n\t\t\tif (typeof count === \"number\" && count >= 100) {\n\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\teventName: \"GetDeltas_OpProcessing\",\n\t\t\t\t\tcount,\n\t\t\t\t\tduration,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tcontainerRuntimeEvents.on(\"connected\", (newClientId) => {\n\t\t\tthis.clientId = newClientId;\n\t\t});\n\t}\n\n\tprivate reportGettingUpToDate(): void {\n\t\tthis.connectionOpSeqNumber = undefined;\n\t\tthis.logger.sendPerformanceEvent({\n\t\t\teventName: \"ConnectionSpeed\",\n\t\t\tduration: performanceNow() - this.connectionStartTime,\n\t\t\tops: this.gap,\n\t\t\t// track time to connect only for first connection.\n\t\t\ttimeToConnect: this.firstConnection\n\t\t\t\t? formatTick(this.connectionStartTime - this.bootTime)\n\t\t\t\t: undefined,\n\t\t\tfirstConnection: this.firstConnection,\n\t\t});\n\t}\n\n\tprivate recordPingTime(latency: number): void {\n\t\tthis.pingLatency = latency;\n\n\t\t// Log if latency is longer than 1 min\n\t\tif (latency > 1000 * 60) {\n\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\teventName: \"LatencyTooLong\",\n\t\t\t\tduration: latency,\n\t\t\t});\n\t\t}\n\n\t\t// logging one in every DELTA_LATENCY_SAMPLE_RATE pongs, including the first time, if it is a \"write\" client.\n\t\tif (this.deltaManager.active) {\n\t\t\tthis.deltaLatencyLogger.sendPerformanceEvent({\n\t\t\t\teventName: \"DeltaLatency\",\n\t\t\t\tduration: latency,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate beforeOpSubmit(message: IDocumentMessage): void {\n\t\t// start with first client op and measure latency every 500 client ops\n\t\tif (\n\t\t\tthis.opLatencyLogger.isSamplingDisabled ||\n\t\t\t(this.clientSequenceNumberForLatencyStatistics === undefined &&\n\t\t\t\tmessage.clientSequenceNumber % OpPerfTelemetry.OP_LATENCY_SAMPLE_RATE === 1)\n\t\t) {\n\t\t\tassert(\n\t\t\t\tthis.latencyStatistics.get(message.clientSequenceNumber) === undefined,\n\t\t\t\t0x7c4 /* Existing op perf data for client sequence number */,\n\t\t\t);\n\t\t\tthis.clientSequenceNumberForLatencyStatistics = message.clientSequenceNumber;\n\t\t\tthis.latencyStatistics.set(message.clientSequenceNumber, {\n\t\t\t\topProcessingTimes: {\n\t\t\t\t\tsubmitOpEventTime: Date.now(),\n\t\t\t\t},\n\t\t\t\topPerfData: {},\n\t\t\t});\n\t\t}\n\n\t\tif (message.type === MessageType.NoOp) {\n\t\t\t// Count the number of no-ops submitted by this client.\n\t\t\t// The value is reset when we log the OpStats sampled event.\n\t\t\tthis.noOpCountForTelemetry++;\n\t\t}\n\t}\n\n\tprivate afterProcessingOp(message: ISequencedDocumentMessage): void {\n\t\tconst sequenceNumber = message.sequenceNumber;\n\n\t\tif (sequenceNumber === this.connectionOpSeqNumber) {\n\t\t\tthis.reportGettingUpToDate();\n\t\t}\n\n\t\t// Record collab window max size after every 1000th op.\n\t\tif (this.sequenceNumberForMsnTracking === undefined && sequenceNumber % 1000 === 0) {\n\t\t\tthis.sequenceNumberForMsnTracking = sequenceNumber;\n\t\t\tthis.msnTrackingTimestamp = message.timestamp;\n\t\t}\n\t\tif (\n\t\t\tthis.sequenceNumberForMsnTracking !== undefined &&\n\t\t\tmessage.minimumSequenceNumber >= this.sequenceNumberForMsnTracking\n\t\t) {\n\t\t\tassert(\n\t\t\t\tthis.msnTrackingTimestamp !== undefined,\n\t\t\t\t0x2ce /* \"msnTrackingTimestamp should not be undefined\" */,\n\t\t\t);\n\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\teventName: \"MsnStatistics\",\n\t\t\t\tsequenceNumber,\n\t\t\t\tmsnDistance: sequenceNumber - this.sequenceNumberForMsnTracking,\n\t\t\t\tduration: message.timestamp - this.msnTrackingTimestamp,\n\t\t\t});\n\t\t\tthis.sequenceNumberForMsnTracking = undefined;\n\t\t}\n\n\t\tif (\n\t\t\tthis.clientId === message.clientId &&\n\t\t\tmessage.type === MessageType.Operation &&\n\t\t\t(this.opLatencyLogger.isSamplingDisabled ||\n\t\t\t\tthis.clientSequenceNumberForLatencyStatistics === message.clientSequenceNumber)\n\t\t) {\n\t\t\t// We do an explicit check for undefined right after this\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst latencyData = this.latencyStatistics.get(message.clientSequenceNumber)!;\n\t\t\tassert(latencyData !== undefined, 0x7c5 /* Undefined latency statistics for op */);\n\t\t\tassert(\n\t\t\t\tlatencyData.opProcessingTimes.submitOpEventTime !== undefined,\n\t\t\t\t0x120 /* \"Undefined latency statistics for op (op send time)\" */,\n\t\t\t);\n\t\t\tconst currentTime = Date.now();\n\t\t\tif (latencyData.opProcessingTimes.inboundPushEventTime !== undefined) {\n\t\t\t\tlatencyData.opPerfData.durationInboundToProcessing =\n\t\t\t\t\tcurrentTime - latencyData.opProcessingTimes.inboundPushEventTime;\n\t\t\t}\n\t\t\tconst duration = currentTime - latencyData.opProcessingTimes.submitOpEventTime;\n\n\t\t\t// One of the core expectations for Fluid service is to be fast.\n\t\t\t// When it's not the case, we want to learn about it and be able to investigate, so\n\t\t\t// raise awareness.\n\t\t\t// This also helps identify cases where it's due to client behavior (sending too many ops)\n\t\t\t// that results in overwhelming ordering service and thus starting to see long latencies.\n\t\t\t// The threshold could be adjusted, but ideally it stays workload-agnostic, as service\n\t\t\t// performance impacts all workloads relying on service.\n\t\t\tconst category = duration > latencyThreshold ? \"error\" : \"performance\";\n\t\t\tthis.opLatencyLogger.sendPerformanceEvent({\n\t\t\t\teventName: \"OpRoundtripTime\",\n\t\t\t\tsequenceNumber,\n\t\t\t\treferenceSequenceNumber: message.referenceSequenceNumber,\n\t\t\t\tduration,\n\t\t\t\tcategory,\n\t\t\t\tpingLatency: this.pingLatency,\n\t\t\t\tmsnDistance:\n\t\t\t\t\tthis.deltaManager.lastSequenceNumber - this.deltaManager.minimumSequenceNumber,\n\t\t\t\t...latencyData.opPerfData,\n\t\t\t});\n\n\t\t\tthis.clientSequenceNumberForLatencyStatistics = undefined;\n\t\t\tthis.latencyStatistics.delete(message.clientSequenceNumber);\n\t\t}\n\n\t\tif (isRuntimeMessage(message)) {\n\t\t\t// Sampled logging of Ops that have been processed by the current client, the NoOp sent and the\n\t\t\t// size of the ops processed within one sampling window of this log event.\n\t\t\t// This data will be used to monitor the efficiency of NoOp-heuristics or to get approximate collab window size.\n\t\t\tthis.opsLogger.sendPerformanceEvent({\n\t\t\t\teventName: \"OpStats\",\n\t\t\t\t// Logging as 'details' property to avoid adding new column name to the log tables */\n\t\t\t\tdetails: {\n\t\t\t\t\t// Count of the ops processed by the current client. Note: these counts are after\n\t\t\t\t\t// compression/grouping/chunking (if enabled) of the ops.\n\t\t\t\t\tprocessedOpCount: OpPerfTelemetry.PROCESSED_OPS_SAMPLE_RATE,\n\t\t\t\t\t// Cumulative size of all the ops processed by the current client since the last OpStats event log\n\t\t\t\t\tprocessedOpSize: this.processedOpSizeForTelemetry,\n\t\t\t\t\t// Count of all the NoOp sent by the current client since the last OpStats event log\n\t\t\t\t\tsubmitedNoOpCount: this.noOpCountForTelemetry,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Starts monitoring and generation of telemetry related to op performance.\n *\n * @param clientId - The clientId of the current container.\n * @param deltaManager - DeltaManager instance to monitor.\n * @param containerRuntimeEvents - Emitter of events for the container runtime.\n * @param logger - Telemetry logger to write events to.\n */\nexport function ReportOpPerfTelemetry(\n\tclientId: string | undefined,\n\tdeltaManager: IDeltaManagerFull,\n\tcontainerRuntimeEvents: IEventProvider<IContainerRuntimeEvents>,\n\tlogger: ITelemetryBaseLogger,\n): void {\n\tnew OpPerfTelemetry(\n\t\tclientId,\n\t\tdeltaManager,\n\t\tcontainerRuntimeEvents,\n\t\tcreateChildLogger({ logger }),\n\t);\n}\n"]}
1
+ {"version":3,"file":"connectionTelemetry.js","sourceRoot":"","sources":["../src/connectionTelemetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAI9D,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAEN,WAAW,GAEX,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAIN,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,GACV,MAAM,0CAA0C,CAAC;AAElD;;GAEG;AACH,MAAM,CA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AC,wCAAwC,GAAG,SAAS,CAAC;YAC1D,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;QAC7D,CAAC;QAED,IAAI,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,+FAA+F;YAC/F,0EAA0E;YAC1E,gHAAgH;YAChH,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;gBACnC,SAAS,EAAE,SAAS;gBACpB,qFAAqF;gBACrF,OAAO,EAAE;oBACR,iFAAiF;oBACjF,yDAAyD;oBACzD,gBAAgB,EAAE,eAAe,CAAC,yBAAyB;oBAC3D,kGAAkG;oBAClG,eAAe,EAAE,IAAI,CAAC,2BAA2B;oBACjD,oFAAoF;oBACpF,iBAAiB,EAAE,IAAI,CAAC,qBAAqB;iBAC7C;aACD,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;;AAhWuB,sCAAsB,GAAG,GAAG,AAAN,CAAO;AAG7B,yCAAyB,GAAG,GAAG,AAAN,CAAO;AAGhC,yCAAyB,GAAG,GAAG,AAAN,CAAO;AA6VzD;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACpC,QAA4B,EAC5B,YAA+B,EAC/B,sBAA+D,EAC/D,MAA4B;IAE5B,IAAI,eAAe,CAClB,QAAQ,EACR,YAAY,EACZ,sBAAsB,EACtB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC,CAC7B,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performanceNow } from \"@fluid-internal/client-utils\";\nimport type { IDeltaManagerFull } from \"@fluidframework/container-definitions/internal\";\nimport type { IContainerRuntimeEvents } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type { ITelemetryBaseLogger, IEventProvider } from \"@fluidframework/core-interfaces\";\nimport { LogLevel } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype IDocumentMessage,\n\tMessageType,\n\ttype ISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { isRuntimeMessage } from \"@fluidframework/driver-utils/internal\";\nimport {\n\ttype IEventSampler,\n\ttype ITelemetryLoggerExt,\n\ttype ISampledTelemetryLogger,\n\tcreateChildLogger,\n\tcreateSampledLogger,\n\tformatTick,\n} from \"@fluidframework/telemetry-utils/internal\";\n\n/**\n * We report various latency-related errors when waiting for op roundtrip takes longer than that amout of time.\n */\nexport const latencyThreshold = 5000;\n\n// Phases in OpPerfTelemetry:\n// 1.\tOp is added to DeltaManager (DM) buffer.\n// 2.\tOp is sent to service (op leaves outbound queue).\n// \t - Note: We do not know for sure when op is sent, we only track when it is added to outbound queue.\n// If outbound queue is paused, time queue is paused is counted as network time.\n// 3.\tOp received from service back (pushed to inbound queue).\n// 4.\tOp is processed.\ninterface IOpPerfTelemetryProperties {\n\t/**\n\t * Measure time between (1) and (2) - Measure time outbound op is sitting in queue due to active batch\n\t */\n\tdurationOutboundBatching: number; // was durationOutboundQueue in previous versions\n\t/**\n\t * Measure time between (2) and (3) - Track how long it took for op to be acked by service\n\t */\n\tdurationNetwork: number; // was durationInboundQueue\n\t/**\n\t * Measure time between (3) and (4) - Time between DM's inbound \"push\" event until DM's \"op\" event\n\t */\n\tdurationInboundToProcessing: number;\n\t/**\n\t * Length of the DeltaManager's inbound queue at the time of the DM's inbound \"push\" event (3)\n\t */\n\tlengthInboundQueue: number;\n}\n\n/**\n * Timings collected at various moments during the op processing.\n */\ninterface IOpPerfTimings {\n\t/**\n\t * Starting time for (1)\n\t */\n\tsubmitOpEventTime: number;\n\t/**\n\t * Starting time for (2)\n\t */\n\toutboundPushEventTime: number;\n\t/**\n\t * Starting time for (3)\n\t */\n\tinboundPushEventTime: number;\n}\n\nclass OpPerfTelemetry {\n\tprivate pingLatency: number | undefined;\n\n\t// Collab window tracking. This is timestamp of %1000 message.\n\tprivate sequenceNumberForMsnTracking: number | undefined;\n\tprivate msnTrackingTimestamp: number = 0;\n\t// To track round trip time for every %500 client message.\n\tprivate clientSequenceNumberForLatencyStatistics: number | undefined;\n\t// Performance Data to be reported for ops round trips and processing.\n\tprivate readonly latencyStatistics = new Map<\n\t\tnumber,\n\t\t{\n\t\t\topProcessingTimes: Partial<IOpPerfTimings>;\n\t\t\topPerfData: Partial<IOpPerfTelemetryProperties>;\n\t\t}\n\t>();\n\n\tprivate firstConnection = true;\n\tprivate connectionOpSeqNumber: number | undefined;\n\tprivate readonly bootTime = performanceNow();\n\tprivate connectionStartTime = 0;\n\tprivate gap = 0;\n\n\t/**\n\t * Count of no-ops sent by this client. This variable is reset everytime the OpStats sampled event is logged\n\t */\n\tprivate noOpCountForTelemetry = 0;\n\t/**\n\t * Cumulative size of the ops processed by this client. This variable is reset everytime the OpStats sampled event is logged\n\t */\n\tprivate processedOpSizeForTelemetry = 0;\n\n\tprivate readonly logger: ITelemetryLoggerExt;\n\n\tprivate static readonly OP_LATENCY_SAMPLE_RATE = 500;\n\tprivate readonly opLatencyLogger: ISampledTelemetryLogger;\n\n\tprivate static readonly DELTA_LATENCY_SAMPLE_RATE = 100;\n\tprivate readonly deltaLatencyLogger: ISampledTelemetryLogger;\n\n\tprivate static readonly PROCESSED_OPS_SAMPLE_RATE = 500;\n\n\t/**\n\t * A sampled logger to log Ops that have been processed by the current client, the NoOp sent and the\n\t * size of the ops processed within one sampling window of this log event.\n\t * The data from this logger will be used to monitor the efficiency of NoOp-heuristics or to get approximate collab window size.\n\t * Note: no log events are sent when sampling is disabled, because logging at every op will be too noisy.\n\t */\n\tprivate readonly opsLogger: ISampledTelemetryLogger;\n\n\t/**\n\t * Create an instance of OpPerfTelemetry which starts monitoring and generating telemetry related to op performance.\n\t *\n\t * @param clientId - The clientId of the current container.\n\t * @param deltaManager - DeltaManager instance to monitor.\n\t * @param containerRuntimeEvents - Emitter of events for the container runtime.\n\t * @param logger - Telemetry logger to write events to.\n\t */\n\tpublic constructor(\n\t\t/**\n\t\t * The clientId of the current container.\n\t\t *\n\t\t * @remarks Until the container connects to the server and receives an ack for its own join op, this can be undefined.\n\t\t * It gets updated in response to event changes once the value provided by the server is available.\n\t\t * If the container loses its connection, this could be the last known clientId.\n\t\t */\n\t\tprivate clientId: string | undefined,\n\t\t/**\n\t\t * DeltaManager instance to monitor.\n\t\t */\n\t\tprivate readonly deltaManager: IDeltaManagerFull,\n\t\t/**\n\t\t * Emitter of events for the container runtime.\n\t\t */\n\t\tcontainerRuntimeEvents: IEventProvider<IContainerRuntimeEvents>,\n\t\t/**\n\t\t * Telemetry logger to write events to.\n\t\t */\n\t\tlogger: ITelemetryLoggerExt,\n\t) {\n\t\tthis.logger = createChildLogger({ logger, namespace: \"OpPerf\" });\n\n\t\tconst deltaLatencyEventSampler: IEventSampler = (() => {\n\t\t\tlet eventCount = -1;\n\t\t\treturn {\n\t\t\t\tsample: () => {\n\t\t\t\t\teventCount++;\n\t\t\t\t\tconst shouldSample = eventCount % OpPerfTelemetry.DELTA_LATENCY_SAMPLE_RATE === 0;\n\t\t\t\t\tif (shouldSample) {\n\t\t\t\t\t\teventCount = 0;\n\t\t\t\t\t}\n\t\t\t\t\treturn shouldSample;\n\t\t\t\t},\n\t\t\t};\n\t\t})();\n\n\t\tthis.deltaLatencyLogger = createSampledLogger(logger, deltaLatencyEventSampler);\n\n\t\t// The SampledLogger here is used get access to the isSamplingDisabled property derived from\n\t\t// telemetry config properties. The actual sampling logic for op messages happens outside this SampledLogger\n\t\t// due to complexity of the different asynchronus scenarios of the op message lifecycle.\n\t\tthis.opLatencyLogger = createSampledLogger(logger);\n\n\t\tconst opsEventSampler: IEventSampler = (() => {\n\t\t\tlet eventCount = 0;\n\t\t\treturn {\n\t\t\t\tsample: () => {\n\t\t\t\t\teventCount++;\n\t\t\t\t\tconst shouldSample = eventCount % OpPerfTelemetry.PROCESSED_OPS_SAMPLE_RATE === 0;\n\t\t\t\t\tif (shouldSample) {\n\t\t\t\t\t\teventCount = 0;\n\t\t\t\t\t\tthis.noOpCountForTelemetry = 0;\n\t\t\t\t\t\tthis.processedOpSizeForTelemetry = 0;\n\t\t\t\t\t}\n\t\t\t\t\treturn shouldSample;\n\t\t\t\t},\n\t\t\t};\n\t\t})();\n\t\tthis.opsLogger = createSampledLogger(\n\t\t\tlogger,\n\t\t\topsEventSampler,\n\t\t\ttrue /* skipLoggingWhenSamplingIsDisabled */,\n\t\t);\n\n\t\tthis.deltaManager.on(\"pong\", (latency) => this.recordPingTime(latency));\n\t\tthis.deltaManager.on(\"submitOp\", (message) => this.beforeOpSubmit(message));\n\t\tthis.deltaManager.on(\"op\", (message) => this.afterProcessingOp(message));\n\t\tthis.deltaManager.on(\"connect\", (details, opsBehind) => {\n\t\t\tif (opsBehind !== undefined) {\n\t\t\t\tthis.connectionOpSeqNumber = this.deltaManager.lastKnownSeqNumber;\n\t\t\t\tthis.gap = opsBehind;\n\t\t\t\tthis.connectionStartTime = performanceNow();\n\n\t\t\t\t// We might be already up-today. If so, report it right away.\n\t\t\t\tif (this.gap <= 0) {\n\t\t\t\t\tthis.reportGettingUpToDate();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tthis.deltaManager.on(\"disconnect\", () => {\n\t\t\tthis.sequenceNumberForMsnTracking = undefined;\n\t\t\tthis.clientSequenceNumberForLatencyStatistics = undefined;\n\t\t\tthis.connectionOpSeqNumber = undefined;\n\t\t\tthis.firstConnection = false;\n\t\t\tthis.latencyStatistics.clear();\n\t\t});\n\n\t\tthis.deltaManager.outbound.on(\"push\", (messages) => {\n\t\t\tfor (const msg of messages) {\n\t\t\t\tif (\n\t\t\t\t\tmsg.type === MessageType.Operation &&\n\t\t\t\t\t(this.opLatencyLogger.isSamplingDisabled ||\n\t\t\t\t\t\tthis.clientSequenceNumberForLatencyStatistics === msg.clientSequenceNumber)\n\t\t\t\t) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tconst latencyStats = this.latencyStatistics.get(msg.clientSequenceNumber)!;\n\t\t\t\t\tassert(latencyStats !== undefined, 0x7c2 /* Latency stats for op should exist */);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tlatencyStats.opProcessingTimes.outboundPushEventTime === undefined,\n\t\t\t\t\t\t0x2c8 /* \"outboundPushEventTime should be undefined\" */,\n\t\t\t\t\t);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tlatencyStats.opPerfData.durationNetwork === undefined,\n\t\t\t\t\t\t0x2c9 /* \"durationNetwork should be undefined\" */,\n\t\t\t\t\t);\n\t\t\t\t\tlatencyStats.opProcessingTimes.outboundPushEventTime = Date.now();\n\n\t\t\t\t\tassert(\n\t\t\t\t\t\tlatencyStats.opPerfData.durationOutboundBatching === undefined,\n\t\t\t\t\t\t0x2ca /* \"durationOutboundBatching should be undefined\" */,\n\t\t\t\t\t);\n\n\t\t\t\t\tassert(\n\t\t\t\t\t\tlatencyStats.opProcessingTimes.submitOpEventTime !== undefined,\n\t\t\t\t\t\t0x2cb /* \"submitOpEventTime should be undefined\" */,\n\t\t\t\t\t);\n\n\t\t\t\t\tlatencyStats.opPerfData.durationOutboundBatching =\n\t\t\t\t\t\tlatencyStats.opProcessingTimes.outboundPushEventTime -\n\t\t\t\t\t\tlatencyStats.opProcessingTimes.submitOpEventTime;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis.deltaManager.inbound.on(\"push\", (message: ISequencedDocumentMessage) => {\n\t\t\tif (\n\t\t\t\tthis.clientId === message.clientId &&\n\t\t\t\tmessage.type === MessageType.Operation &&\n\t\t\t\t(this.opLatencyLogger.isSamplingDisabled ||\n\t\t\t\t\tthis.clientSequenceNumberForLatencyStatistics === message.clientSequenceNumber)\n\t\t\t) {\n\t\t\t\t// We do an explicit check for undefined right after this\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst latencyStats = this.latencyStatistics.get(message.clientSequenceNumber)!;\n\t\t\t\tassert(latencyStats !== undefined, 0x7c3 /* Latency stats for op should exist */);\n\t\t\t\tif (latencyStats.opProcessingTimes.outboundPushEventTime !== undefined) {\n\t\t\t\t\tlatencyStats.opProcessingTimes.inboundPushEventTime = Date.now();\n\t\t\t\t\tlatencyStats.opPerfData.durationNetwork =\n\t\t\t\t\t\tlatencyStats.opProcessingTimes.inboundPushEventTime -\n\t\t\t\t\t\tlatencyStats.opProcessingTimes.outboundPushEventTime;\n\t\t\t\t\tlatencyStats.opPerfData.lengthInboundQueue = this.deltaManager.inbound.length;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (isRuntimeMessage(message) && typeof message.contents === \"string\") {\n\t\t\t\tthis.processedOpSizeForTelemetry += message.contents.length;\n\t\t\t}\n\t\t});\n\n\t\tthis.deltaManager.inbound.on(\"idle\", (count: number, duration: number) => {\n\t\t\t// Do not want to log zero for sure.\n\t\t\t// We are more interested in aggregates, so logging only if we are processing some number of ops\n\t\t\t// Cut-off is arbitrary - can be increased or decreased based on amount of data collected and questions we\n\t\t\t// want to get answered\n\t\t\t// back-compat: Once 0.36 loader version saturates (count & duration args were added there),\n\t\t\t// we can remove typeof check.\n\t\t\tif (typeof count === \"number\" && count >= 100) {\n\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\teventName: \"GetDeltas_OpProcessing\",\n\t\t\t\t\tcount,\n\t\t\t\t\tduration,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tcontainerRuntimeEvents.on(\"connected\", (newClientId) => {\n\t\t\tthis.clientId = newClientId;\n\t\t});\n\t}\n\n\tprivate reportGettingUpToDate(): void {\n\t\tthis.connectionOpSeqNumber = undefined;\n\t\tthis.logger.sendPerformanceEvent(\n\t\t\t{\n\t\t\t\teventName: \"ConnectionSpeed\",\n\t\t\t\tduration: performanceNow() - this.connectionStartTime,\n\t\t\t\tops: this.gap,\n\t\t\t\t// track time to connect only for first connection.\n\t\t\t\ttimeToConnect: this.firstConnection\n\t\t\t\t\t? formatTick(this.connectionStartTime - this.bootTime)\n\t\t\t\t\t: undefined,\n\t\t\t\tfirstConnection: this.firstConnection,\n\t\t\t},\n\t\t\tundefined, // error\n\t\t\tLogLevel.info,\n\t\t);\n\t}\n\n\tprivate recordPingTime(latency: number): void {\n\t\tthis.pingLatency = latency;\n\n\t\t// Log if latency is longer than 1 min\n\t\tif (latency > 1000 * 60) {\n\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\teventName: \"LatencyTooLong\",\n\t\t\t\tduration: latency,\n\t\t\t});\n\t\t}\n\n\t\t// logging one in every DELTA_LATENCY_SAMPLE_RATE pongs, including the first time, if it is a \"write\" client.\n\t\tif (this.deltaManager.active) {\n\t\t\tthis.deltaLatencyLogger.sendPerformanceEvent({\n\t\t\t\teventName: \"DeltaLatency\",\n\t\t\t\tduration: latency,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate beforeOpSubmit(message: IDocumentMessage): void {\n\t\t// start with first client op and measure latency every 500 client ops\n\t\tif (\n\t\t\tthis.opLatencyLogger.isSamplingDisabled ||\n\t\t\t(this.clientSequenceNumberForLatencyStatistics === undefined &&\n\t\t\t\tmessage.clientSequenceNumber % OpPerfTelemetry.OP_LATENCY_SAMPLE_RATE === 1)\n\t\t) {\n\t\t\tassert(\n\t\t\t\tthis.latencyStatistics.get(message.clientSequenceNumber) === undefined,\n\t\t\t\t0x7c4 /* Existing op perf data for client sequence number */,\n\t\t\t);\n\t\t\tthis.clientSequenceNumberForLatencyStatistics = message.clientSequenceNumber;\n\t\t\tthis.latencyStatistics.set(message.clientSequenceNumber, {\n\t\t\t\topProcessingTimes: {\n\t\t\t\t\tsubmitOpEventTime: Date.now(),\n\t\t\t\t},\n\t\t\t\topPerfData: {},\n\t\t\t});\n\t\t}\n\n\t\tif (message.type === MessageType.NoOp) {\n\t\t\t// Count the number of no-ops submitted by this client.\n\t\t\t// The value is reset when we log the OpStats sampled event.\n\t\t\tthis.noOpCountForTelemetry++;\n\t\t}\n\t}\n\n\tprivate afterProcessingOp(message: ISequencedDocumentMessage): void {\n\t\tconst sequenceNumber = message.sequenceNumber;\n\n\t\tif (sequenceNumber === this.connectionOpSeqNumber) {\n\t\t\tthis.reportGettingUpToDate();\n\t\t}\n\n\t\t// Record collab window max size after every 1000th op.\n\t\tif (this.sequenceNumberForMsnTracking === undefined && sequenceNumber % 1000 === 0) {\n\t\t\tthis.sequenceNumberForMsnTracking = sequenceNumber;\n\t\t\tthis.msnTrackingTimestamp = message.timestamp;\n\t\t}\n\t\tif (\n\t\t\tthis.sequenceNumberForMsnTracking !== undefined &&\n\t\t\tmessage.minimumSequenceNumber >= this.sequenceNumberForMsnTracking\n\t\t) {\n\t\t\tassert(\n\t\t\t\tthis.msnTrackingTimestamp !== undefined,\n\t\t\t\t0x2ce /* \"msnTrackingTimestamp should not be undefined\" */,\n\t\t\t);\n\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\teventName: \"MsnStatistics\",\n\t\t\t\tsequenceNumber,\n\t\t\t\tmsnDistance: sequenceNumber - this.sequenceNumberForMsnTracking,\n\t\t\t\tduration: message.timestamp - this.msnTrackingTimestamp,\n\t\t\t});\n\t\t\tthis.sequenceNumberForMsnTracking = undefined;\n\t\t}\n\n\t\tif (\n\t\t\tthis.clientId === message.clientId &&\n\t\t\tmessage.type === MessageType.Operation &&\n\t\t\t(this.opLatencyLogger.isSamplingDisabled ||\n\t\t\t\tthis.clientSequenceNumberForLatencyStatistics === message.clientSequenceNumber)\n\t\t) {\n\t\t\t// We do an explicit check for undefined right after this\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst latencyData = this.latencyStatistics.get(message.clientSequenceNumber)!;\n\t\t\tassert(latencyData !== undefined, 0x7c5 /* Undefined latency statistics for op */);\n\t\t\tassert(\n\t\t\t\tlatencyData.opProcessingTimes.submitOpEventTime !== undefined,\n\t\t\t\t0x120 /* \"Undefined latency statistics for op (op send time)\" */,\n\t\t\t);\n\t\t\tconst currentTime = Date.now();\n\t\t\tif (latencyData.opProcessingTimes.inboundPushEventTime !== undefined) {\n\t\t\t\tlatencyData.opPerfData.durationInboundToProcessing =\n\t\t\t\t\tcurrentTime - latencyData.opProcessingTimes.inboundPushEventTime;\n\t\t\t}\n\t\t\tconst duration = currentTime - latencyData.opProcessingTimes.submitOpEventTime;\n\n\t\t\t// One of the core expectations for Fluid service is to be fast.\n\t\t\t// When it's not the case, we want to learn about it and be able to investigate, so\n\t\t\t// raise awareness.\n\t\t\t// This also helps identify cases where it's due to client behavior (sending too many ops)\n\t\t\t// that results in overwhelming ordering service and thus starting to see long latencies.\n\t\t\t// The threshold could be adjusted, but ideally it stays workload-agnostic, as service\n\t\t\t// performance impacts all workloads relying on service.\n\t\t\tconst category = duration > latencyThreshold ? \"error\" : \"performance\";\n\t\t\tthis.opLatencyLogger.sendPerformanceEvent({\n\t\t\t\teventName: \"OpRoundtripTime\",\n\t\t\t\tsequenceNumber,\n\t\t\t\treferenceSequenceNumber: message.referenceSequenceNumber,\n\t\t\t\tduration,\n\t\t\t\tcategory,\n\t\t\t\tpingLatency: this.pingLatency,\n\t\t\t\tmsnDistance:\n\t\t\t\t\tthis.deltaManager.lastSequenceNumber - this.deltaManager.minimumSequenceNumber,\n\t\t\t\t...latencyData.opPerfData,\n\t\t\t});\n\n\t\t\tthis.clientSequenceNumberForLatencyStatistics = undefined;\n\t\t\tthis.latencyStatistics.delete(message.clientSequenceNumber);\n\t\t}\n\n\t\tif (isRuntimeMessage(message)) {\n\t\t\t// Sampled logging of Ops that have been processed by the current client, the NoOp sent and the\n\t\t\t// size of the ops processed within one sampling window of this log event.\n\t\t\t// This data will be used to monitor the efficiency of NoOp-heuristics or to get approximate collab window size.\n\t\t\tthis.opsLogger.sendPerformanceEvent({\n\t\t\t\teventName: \"OpStats\",\n\t\t\t\t// Logging as 'details' property to avoid adding new column name to the log tables */\n\t\t\t\tdetails: {\n\t\t\t\t\t// Count of the ops processed by the current client. Note: these counts are after\n\t\t\t\t\t// compression/grouping/chunking (if enabled) of the ops.\n\t\t\t\t\tprocessedOpCount: OpPerfTelemetry.PROCESSED_OPS_SAMPLE_RATE,\n\t\t\t\t\t// Cumulative size of all the ops processed by the current client since the last OpStats event log\n\t\t\t\t\tprocessedOpSize: this.processedOpSizeForTelemetry,\n\t\t\t\t\t// Count of all the NoOp sent by the current client since the last OpStats event log\n\t\t\t\t\tsubmitedNoOpCount: this.noOpCountForTelemetry,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Starts monitoring and generation of telemetry related to op performance.\n *\n * @param clientId - The clientId of the current container.\n * @param deltaManager - DeltaManager instance to monitor.\n * @param containerRuntimeEvents - Emitter of events for the container runtime.\n * @param logger - Telemetry logger to write events to.\n */\nexport function ReportOpPerfTelemetry(\n\tclientId: string | undefined,\n\tdeltaManager: IDeltaManagerFull,\n\tcontainerRuntimeEvents: IEventProvider<IContainerRuntimeEvents>,\n\tlogger: ITelemetryBaseLogger,\n): void {\n\tnew OpPerfTelemetry(\n\t\tclientId,\n\t\tdeltaManager,\n\t\tcontainerRuntimeEvents,\n\t\tcreateChildLogger({ logger }),\n\t);\n}\n"]}
@@ -434,7 +434,11 @@ export declare class ContainerRuntime extends TypedEventEmitter<IContainerRuntim
434
434
  private readonly submitSummaryFn;
435
435
  private readonly submitSignalFn;
436
436
  readonly disposeFn: (error?: ICriticalContainerError) => void;
437
- readonly closeFn: (error?: ICriticalContainerError) => void;
437
+ /**
438
+ * Initiate closing of the container due to a critical error.
439
+ * @param error - The critical error that caused the container to close.
440
+ */
441
+ private readonly closeFn;
438
442
  get flushMode(): FlushMode;
439
443
  get scope(): FluidObject;
440
444
  get IFluidDataStoreRegistry(): IFluidDataStoreRegistry;
@@ -603,6 +607,7 @@ export declare class ContainerRuntime extends TypedEventEmitter<IContainerRuntim
603
607
  */
604
608
  private initializeBaseState;
605
609
  private initializeSummarizer;
610
+ close(): void;
606
611
  dispose(error?: Error): void;
607
612
  /**
608
613
  * Api to fetch the snapshot from the service for a loadingGroupIds.