@fluidframework/odsp-driver 0.59.4002 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +1 -1
- package/dist/compactSnapshotParser.d.ts.map +1 -1
- package/dist/compactSnapshotParser.js +4 -1
- package/dist/compactSnapshotParser.js.map +1 -1
- package/dist/compactSnapshotWriter.d.ts.map +1 -1
- package/dist/compactSnapshotWriter.js +6 -3
- package/dist/compactSnapshotWriter.js.map +1 -1
- package/dist/epochTracker.d.ts +3 -2
- package/dist/epochTracker.d.ts.map +1 -1
- package/dist/epochTracker.js +10 -4
- package/dist/epochTracker.js.map +1 -1
- package/dist/fetchSnapshot.js +2 -2
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/odspDocumentDeltaConnection.js +2 -1
- package/dist/odspDocumentDeltaConnection.js.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.js +2 -2
- package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
- package/dist/odspDocumentStorageManager.d.ts +0 -1
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.js +0 -4
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/odspSnapshotParser.d.ts +1 -1
- package/dist/odspSnapshotParser.js +3 -3
- package/dist/odspSnapshotParser.js.map +1 -1
- package/dist/odspSummaryUploadManager.d.ts.map +1 -1
- package/dist/odspSummaryUploadManager.js +1 -4
- package/dist/odspSummaryUploadManager.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/retryErrorsStorageAdapter.d.ts +1 -2
- package/dist/retryErrorsStorageAdapter.d.ts.map +1 -1
- package/dist/retryErrorsStorageAdapter.js +0 -3
- package/dist/retryErrorsStorageAdapter.js.map +1 -1
- package/dist/retryUtils.d.ts.map +1 -1
- package/dist/retryUtils.js +2 -3
- package/dist/retryUtils.js.map +1 -1
- package/lib/compactSnapshotParser.d.ts.map +1 -1
- package/lib/compactSnapshotParser.js +4 -1
- package/lib/compactSnapshotParser.js.map +1 -1
- package/lib/compactSnapshotWriter.d.ts.map +1 -1
- package/lib/compactSnapshotWriter.js +6 -3
- package/lib/compactSnapshotWriter.js.map +1 -1
- package/lib/epochTracker.d.ts +3 -2
- package/lib/epochTracker.d.ts.map +1 -1
- package/lib/epochTracker.js +10 -4
- package/lib/epochTracker.js.map +1 -1
- package/lib/fetchSnapshot.js +3 -3
- package/lib/fetchSnapshot.js.map +1 -1
- package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/lib/odspDocumentDeltaConnection.js +2 -1
- package/lib/odspDocumentDeltaConnection.js.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.js +2 -2
- package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
- package/lib/odspDocumentStorageManager.d.ts +0 -1
- package/lib/odspDocumentStorageManager.d.ts.map +1 -1
- package/lib/odspDocumentStorageManager.js +0 -4
- package/lib/odspDocumentStorageManager.js.map +1 -1
- package/lib/odspSnapshotParser.d.ts +1 -1
- package/lib/odspSnapshotParser.js +1 -1
- package/lib/odspSnapshotParser.js.map +1 -1
- package/lib/odspSummaryUploadManager.d.ts.map +1 -1
- package/lib/odspSummaryUploadManager.js +1 -4
- package/lib/odspSummaryUploadManager.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/retryErrorsStorageAdapter.d.ts +1 -2
- package/lib/retryErrorsStorageAdapter.d.ts.map +1 -1
- package/lib/retryErrorsStorageAdapter.js +0 -3
- package/lib/retryErrorsStorageAdapter.js.map +1 -1
- package/lib/retryUtils.d.ts.map +1 -1
- package/lib/retryUtils.js +3 -4
- package/lib/retryUtils.js.map +1 -1
- package/package.json +12 -25
- package/src/compactSnapshotParser.ts +3 -1
- package/src/compactSnapshotWriter.ts +6 -3
- package/src/epochTracker.ts +10 -3
- package/src/fetchSnapshot.ts +3 -3
- package/src/odspDocumentDeltaConnection.ts +2 -1
- package/src/odspDocumentServiceFactoryCore.ts +4 -2
- package/src/odspDocumentStorageManager.ts +0 -6
- package/src/odspSnapshotParser.ts +1 -1
- package/src/odspSummaryUploadManager.ts +1 -4
- package/src/packageVersion.ts +1 -1
- package/src/retryErrorsStorageAdapter.ts +0 -8
- package/src/retryUtils.ts +3 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentStorageManager.js","sourceRoot":"","sources":["../src/odspDocumentStorageManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,+DAGsC;AACtC,qEAEyC;AAEzC,2EAK4C;AAC5C,+DAA8E;AAC9E,qFAKiD;AAOjD,mDAAsH;AACtH,yEAAsE;AAEtE,2CAIqB;AACrB,iDAA2E;AAC3E,yEAAsE;AAEtE,qDAA+D;AAElD,QAAA,mCAAmC,GAAW,EAAE,GAAG,IAAI,CAAC,CAAC,cAAc;AAEpF,4BAA4B;AAE5B,kFAAkF;AAClF,KAAK,UAAU,qBAAqB,CAAI,QAAsB;IAC1D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YAC1B,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC;AAED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,0CAAE,sCAAsC,CAAA,EACxE,IAAI,CAAC,MAAM,EACX,kBAAkB,CACrB,CAAC;gBACF,IAAI,MAAM,GAAG,EAAE,CAAC;gBAChB,IAAI,QAAQ,CAAC,YAAY,EAAE;oBACvB,IAAA,qBAAM,EAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,KAAK,SAAS,EAAE,KAAK,CAAC,yCAAyC,CAAC,CAAC;oBAChG,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;oBAClC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;iBACnD;gBACD,IAAI,QAAQ,CAAC,KAAK,EAAE;oBAChB,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;iBACvC;gBACD,4GAA4G;gBAC5G,+CAA+C;gBAC/C,OAAO,MAAA,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,mCAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACpE,CAAC,CAAC,CAAC;SACN;QAED,IAAI,CAAC,IAAI,EAAE;YACP,OAAO,IAAI,CAAC;SACf;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,iCAAiC,CACrC,mBAAsC,EACtC,wBAA2C;QAE3C,MAAM,mBAAmB,GAAsB;YAC3C,KAAK,oBACE,mBAAmB,CAAC,KAAK,CAC/B;YACD,KAAK,kCACE,mBAAmB,CAAC,KAAK;gBAC5B,sCAAsC;gBACtC,yDAAyD;gBACzD,WAAW,EAAE,wBAAwB,GACxC;SACJ,CAAC;QAEF,OAAO,mBAAmB,CAAC;IAC/B,CAAC;CACJ;AAxnBD,gEAwnBC;AAED,2BAA2B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n assert,\n delay,\n} from \"@fluidframework/common-utils\";\nimport {\n PerformanceEvent,\n} from \"@fluidframework/telemetry-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport {\n ISummaryContext,\n IDocumentStorageService,\n LoaderCachingPolicy,\n DriverErrorType,\n} from \"@fluidframework/driver-definitions\";\nimport { RateLimiter, NonRetryableError } from \"@fluidframework/driver-utils\";\nimport {\n IOdspResolvedUrl,\n ISnapshotOptions,\n OdspErrorType,\n InstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport {\n IDocumentStorageGetVersionsResponse,\n HostStoragePolicyInternal,\n IVersionedValueWithEpoch,\n ISnapshotCachedEntry,\n} from \"./contracts\";\nimport { downloadSnapshot, fetchSnapshot, fetchSnapshotWithRedeem, SnapshotFormatSupportType } from \"./fetchSnapshot\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { IOdspCache } from \"./odspCache\";\nimport {\n createCacheSnapshotKey,\n getWithRetryForTokenRefresh,\n ISnapshotContents,\n} from \"./odspUtils\";\nimport { defaultCacheExpiryTimeoutMs, EpochTracker } from \"./epochTracker\";\nimport { OdspSummaryUploadManager } from \"./odspSummaryUploadManager\";\nimport { FlushResult } from \"./odspDocumentDeltaConnection\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\nexport const defaultSummarizerCacheExpiryTimeout: number = 60 * 1000; // 60 seconds.\n\n/* eslint-disable max-len */\n\n// An implementation of Promise.race that gives you the winner of the promise race\nasync function promiseRaceWithWinner<T>(promises: Promise<T>[]): Promise<{ index: number; value: T; }> {\n return new Promise((resolve, reject) => {\n promises.forEach((p, index) => {\n p.then((v) => resolve({ index, value: v })).catch(reject);\n });\n });\n}\n\nclass BlobCache {\n // Save the timeout so we can cancel and reschedule it as needed\n private blobCacheTimeout: ReturnType<typeof setTimeout> | undefined;\n // If the defer flag is set when the timeout fires, we'll reschedule rather than clear immediately\n // This deferral approach is used (rather than clearing/resetting the timer) as current calling patterns trigger\n // too many calls to setTimeout/clearTimeout.\n private deferBlobCacheClear: boolean = false;\n\n private readonly _blobCache: Map<string, ArrayBuffer> = new Map();\n\n // Tracks all blob IDs evicted from cache\n private readonly blobsEvicted: Set<string> = new Set();\n\n // Initial time-out to purge data from cache\n // If this time out is very small, then we purge blobs from cache too soon and that results in a lot of\n // requests to storage, which brings down perf and may trip protection limits causing 429s\n private blobCacheTimeoutDuration = 2 * 60 * 1000;\n\n // SPO does not keep old snapshots around for long, so we are running chances of not\n // being able to rehydrate data store / DDS in the future if we purge anything (and with blob de-duping,\n // even if blob read by runtime, it could be read again in the future)\n // So for now, purging is disabled.\n private readonly purgeEnabled = false;\n\n public get value() {\n return this._blobCache;\n }\n\n public addBlobs(blobs: Map<string, ArrayBuffer>) {\n blobs.forEach((value, blobId) => {\n this._blobCache.set(blobId, value);\n });\n // Reset the timer on cache set\n this.scheduleClearBlobsCache();\n }\n\n /**\n * Schedule a timer for clearing the blob cache or defer the current one.\n */\n private scheduleClearBlobsCache() {\n if (this.blobCacheTimeout !== undefined) {\n // If we already have an outstanding timer, just signal that we should defer the clear\n this.deferBlobCacheClear = true;\n } else if (this.purgeEnabled) {\n // If we don't have an outstanding timer, set a timer\n // When the timer runs out, we'll decide whether to proceed with the cache clear or reset the timer\n const clearCacheOrDefer = () => {\n this.blobCacheTimeout = undefined;\n if (this.deferBlobCacheClear) {\n this.deferBlobCacheClear = false;\n this.scheduleClearBlobsCache();\n } else {\n // NOTE: Slightly better algorithm here would be to purge either only big blobs,\n // or sort them by size and purge enough big blobs to leave only 256Kb of small blobs in cache\n // Purging is optimizing memory footprint. But count controls potential number of storage requests\n // We want to optimize both - memory footprint and number of future requests to storage.\n // Note that Container can realize data store or DDS on-demand at any point in time, so we do not\n // control when blobs will be used.\n this._blobCache.forEach((_, blobId) => this.blobsEvicted.add(blobId));\n this._blobCache.clear();\n }\n };\n this.blobCacheTimeout = setTimeout(clearCacheOrDefer, this.blobCacheTimeoutDuration);\n // any future storage reads that get into the cache should be cleared from cache rather quickly -\n // there is not much value in keeping them longer\n this.blobCacheTimeoutDuration = 10 * 1000;\n }\n }\n\n public getBlob(blobId: string) {\n // Reset the timer on attempted cache read\n this.scheduleClearBlobsCache();\n const blobContent = this._blobCache.get(blobId);\n const evicted = this.blobsEvicted.has(blobId);\n return { blobContent, evicted };\n }\n\n public setBlob(blobId: string, blob: ArrayBuffer) {\n // This API is called as result of cache miss and reading blob from storage.\n // Runtime never reads same blob twice.\n // The only reason we may get read request for same blob is blob de-duping in summaries.\n // Note that the bigger the size, the less likely blobs are the same, so there is very little benefit of caching big blobs.\n // Images are the only exception - user may insert same image twice. But we currently do not de-dup them - only snapshot\n // blobs are de-duped.\n const size = blob.byteLength;\n if (size < 256 * 1024) {\n // Reset the timer on cache set\n this.scheduleClearBlobsCache();\n return this._blobCache.set(blobId, blob);\n } else {\n // we evicted it here by not caching.\n this.blobsEvicted.add(blobId);\n }\n }\n}\n\ninterface GetVersionsTelemetryProps {\n cacheEntryAge?: number;\n cacheSummarizerExpired?: boolean;\n}\nexport class OdspDocumentStorageService implements IDocumentStorageService {\n readonly policies = {\n // By default, ODSP tells the container not to prefetch/cache.\n caching: LoaderCachingPolicy.NoCaching,\n\n // ODSP storage works better if it has less number of blobs / edges\n // Runtime creating many small blobs results in sub-optimal perf.\n // 2K seems like the sweat spot:\n // The smaller the number, less blobs we aggregate. Most storages are very likely to have notion\n // of minimal \"cluster\" size, so having small blobs is wasteful\n // At the same time increasing the limit ensure that more blobs with user content are aggregated,\n // reducing possibility for de-duping of same blobs (i.e. .attributes rolled into aggregate blob\n // are not reused across data stores, or even within data store, resulting in duplication of content)\n // Note that duplication of content should not have significant impact for bytes over wire as\n // compression of http payload mostly takes care of it, but it does impact storage size and in-memory sizes.\n minBlobSize: 2048,\n maximumCacheDurationMs: defaultCacheExpiryTimeoutMs,\n };\n\n private readonly commitCache: Map<string, api.ISnapshotTree> = new Map();\n\n private readonly attributesBlobHandles: Set<string> = new Set();\n\n private readonly odspSummaryUploadManager: OdspSummaryUploadManager;\n private _ops: api.ISequencedDocumentMessage[] | undefined;\n\n private firstVersionCall = true;\n private _snapshotSequenceNumber: number | undefined;\n\n private readonly documentId: string;\n private readonly snapshotUrl: string | undefined;\n private readonly attachmentPOSTUrl: string | undefined;\n private readonly attachmentGETUrl: string | undefined;\n // Driver specified limits for snapshot size and time.\n /**\n * NOTE: While commit cfff6e3 added restrictions to prevent large payloads, snapshot failures will continue to\n * happen until blob request throttling is implemented. Until then, as a temporary fix we set arbitrarily large\n * snapshot size and timeout limits so that such failures are unlikely to occur.\n */\n private readonly maxSnapshotSizeLimit = 500000000; // 500 MB\n private readonly maxSnapshotFetchTimeout = 120000; // 2 min\n\n // limits the amount of parallel \"attachment\" blob uploads\n private readonly createBlobRateLimiter = new RateLimiter(1);\n\n private readonly blobCache = new BlobCache();\n\n public set ops(ops: api.ISequencedDocumentMessage[] | undefined) {\n assert(this._ops === undefined, 0x0a5 /* \"Trying to set ops when they are already set!\" */);\n this._ops = ops;\n }\n\n public get ops(): api.ISequencedDocumentMessage[] | undefined {\n return this._ops;\n }\n\n public get snapshotSequenceNumber() {\n return this._snapshotSequenceNumber;\n }\n\n constructor(\n private readonly odspResolvedUrl: IOdspResolvedUrl,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n private readonly logger: ITelemetryLogger,\n private readonly fetchFullSnapshot: boolean,\n private readonly cache: IOdspCache,\n private readonly hostPolicy: HostStoragePolicyInternal,\n private readonly epochTracker: EpochTracker,\n private readonly flushCallback: () => Promise<FlushResult>,\n private readonly snapshotFormatFetchType?: SnapshotFormatSupportType,\n ) {\n this.documentId = this.odspResolvedUrl.hashedDocumentId;\n this.snapshotUrl = this.odspResolvedUrl.endpoints.snapshotStorageUrl;\n this.attachmentPOSTUrl = this.odspResolvedUrl.endpoints.attachmentPOSTStorageUrl;\n this.attachmentGETUrl = this.odspResolvedUrl.endpoints.attachmentGETStorageUrl;\n this.odspSummaryUploadManager = new OdspSummaryUploadManager(\n this.snapshotUrl,\n getStorageToken,\n logger,\n epochTracker,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n );\n }\n\n public get repositoryUrl(): string {\n return \"\";\n }\n\n public async createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse> {\n this.checkAttachmentPOSTUrl();\n\n const response = await getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"CreateBlob\");\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${this.attachmentPOSTUrl}/content`,\n storageToken,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n );\n headers[\"Content-Type\"] = \"application/octet-stream\";\n\n return PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"createBlob\",\n size: file.byteLength,\n waitQueueLength: this.createBlobRateLimiter.waitQueueLength,\n },\n async (event) => {\n const res = await this.createBlobRateLimiter.schedule(async () =>\n this.epochTracker.fetchAndParseAsJSON<api.ICreateBlobResponse>(\n url,\n {\n body: file,\n headers,\n method: \"POST\",\n },\n \"createBlob\",\n ));\n event.end({\n blobId: res.content.id,\n ...res.propsToLog,\n });\n return res;\n },\n );\n });\n\n return response.content;\n }\n\n private async readBlobCore(blobId: string): Promise<ArrayBuffer> {\n const { blobContent, evicted } = this.blobCache.getBlob(blobId);\n let blob = blobContent;\n\n if (blob === undefined) {\n this.checkAttachmentGETUrl();\n\n blob = await getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"GetBlob\");\n const unAuthedUrl = `${this.attachmentGETUrl}/${encodeURIComponent(blobId)}/content`;\n const { url, headers } = getUrlAndHeadersWithAuth(\n unAuthedUrl,\n storageToken,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n );\n\n return PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"readDataBlob\",\n blobId,\n evicted,\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n waitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,\n },\n async (event) => {\n const res = await this.epochTracker.fetchArray(url, { headers }, \"blob\");\n event.end({\n waitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,\n ...res.propsToLog,\n attempts: options.refresh ? 2 : 1,\n });\n const cacheControl = res.headers.get(\"cache-control\");\n if (cacheControl === undefined || !(cacheControl.includes(\"private\") || cacheControl.includes(\"public\"))) {\n this.logger.sendErrorEvent({\n eventName: \"NonCacheableBlob\",\n cacheControl,\n blobId,\n ...res.propsToLog,\n });\n }\n return res.content;\n },\n );\n });\n this.blobCache.setBlob(blobId, blob);\n }\n\n return blob;\n }\n\n public async readBlob(blobId: string): Promise<ArrayBufferLike> {\n return this.readBlobCore(blobId);\n }\n\n public async getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null> {\n if (!this.snapshotUrl) {\n return null;\n }\n\n let id: string;\n if (!version || !version.id) {\n const versions = await this.getVersions(null, 1);\n if (!versions || versions.length === 0) {\n return null;\n }\n id = versions[0].id;\n } else {\n id = version.id;\n }\n\n const snapshotTree = await this.readTree(id);\n if (!snapshotTree) {\n return null;\n }\n\n if (snapshotTree.blobs) {\n const attributesBlob = snapshotTree.blobs.attributes;\n if (attributesBlob) {\n this.attributesBlobHandles.add(attributesBlob);\n }\n }\n\n // When we upload the container snapshot, we upload appTree in \".app\" and protocol tree in \".protocol\"\n // So when we request the snapshot we get \".app\" as tree and not as commit node as in the case just above.\n const appTree = snapshotTree.trees[\".app\"];\n const protocolTree = snapshotTree.trees[\".protocol\"];\n\n return this.combineProtocolAndAppSnapshotTree(appTree, protocolTree);\n }\n\n public async getVersions(blobid: string | null, count: number): Promise<api.IVersion[]> {\n // Regular load workflow uses blobId === documentID to indicate \"latest\".\n if (blobid !== this.documentId && blobid) {\n // FluidFetch & FluidDebugger tools use empty sting to query for versions\n // In such case we need to make a call against SPO to give full picture to the tool.\n // Otherwise, each commit calls getVersions but odsp doesn't have a history for each commit\n // return the blobid as is\n return [\n {\n id: blobid,\n treeId: undefined!,\n },\n ];\n }\n\n // Can't really make a call if we do not have URL\n if (!this.snapshotUrl) {\n return [];\n }\n\n // If count is one, we can use the trees/latest API, which returns the latest version and trees in a single request for better performance\n // Do it only once - we might get more here due to summarizer - it needs only container tree, not full snapshot.\n if (this.firstVersionCall && count === 1 && (blobid === null || blobid === this.documentId)) {\n const hostSnapshotOptions = this.hostPolicy.snapshotOptions;\n const odspSnapshotCacheValue: ISnapshotContents = await PerformanceEvent.timedExecAsync(\n this.logger,\n { eventName: \"ObtainSnapshot\" },\n async (event: PerformanceEvent) => {\n const props: GetVersionsTelemetryProps = {};\n let retrievedSnapshot: ISnapshotContents | undefined;\n // Here's the logic to grab the persistent cache snapshot implemented by the host\n // Epoch tracker is responsible for communicating with the persistent cache, handling epochs and cache versions\n const cachedSnapshotP: Promise<ISnapshotContents | undefined> =\n this.epochTracker.get(createCacheSnapshotKey(this.odspResolvedUrl))\n .then(async (snapshotCachedEntry: ISnapshotCachedEntry) => {\n if (snapshotCachedEntry !== undefined) {\n // If the cached entry does not contain the entry time, then assign it a default of 30 days old.\n const age = Date.now() - (snapshotCachedEntry.cacheEntryTime ??\n (Date.now() - 30 * 24 * 60 * 60 * 1000));\n\n // In order to decrease the number of times we have to execute a snapshot refresh,\n // if this is the summarizer and we have a cache entry but it is past the defaultSummarizerCacheExpiryTimeout,\n // force the network retrieval instead as there might be a more recent snapshot available.\n // See: https://github.com/microsoft/FluidFramework/issues/8995 for additional information.\n if (this.hostPolicy.summarizerClient) {\n if (age > defaultSummarizerCacheExpiryTimeout) {\n props.cacheSummarizerExpired = true;\n return undefined;\n } else {\n props.cacheSummarizerExpired = false;\n }\n }\n\n // Record the cache age\n props.cacheEntryAge = age;\n }\n\n return snapshotCachedEntry;\n });\n\n // Based on the concurrentSnapshotFetch policy:\n // Either retrieve both the network and cache snapshots concurrently and pick the first to return,\n // or grab the cache value and then the network value if the cache value returns undefined.\n let method: string;\n if (this.hostPolicy.concurrentSnapshotFetch && !this.hostPolicy.summarizerClient) {\n const networkSnapshotP = this.fetchSnapshot(hostSnapshotOptions);\n\n // Ensure that failures on both paths are ignored initially.\n // I.e. if cache fails for some reason, we will proceed with network result.\n // And vice versa - if (for example) client is offline and network request fails first, we\n // do want to attempt to succeed with cached data!\n const promiseRaceWinner = await promiseRaceWithWinner([\n cachedSnapshotP.catch(() => undefined),\n networkSnapshotP.catch(() => undefined),\n ]);\n retrievedSnapshot = promiseRaceWinner.value;\n method = promiseRaceWinner.index === 0 ? \"cache\" : \"network\";\n\n if (retrievedSnapshot === undefined) {\n // if network failed -> wait for cache ( then return network failure)\n // If cache returned empty or failed -> wait for network (success of failure)\n if (promiseRaceWinner.index === 1) {\n retrievedSnapshot = await cachedSnapshotP;\n method = \"cache\";\n }\n if (retrievedSnapshot === undefined) {\n retrievedSnapshot = await networkSnapshotP;\n method = \"network\";\n }\n }\n } else {\n // Note: There's a race condition here - another caller may come past the undefined check\n // while the first caller is awaiting later async code in this block.\n\n retrievedSnapshot = await cachedSnapshotP;\n\n method = retrievedSnapshot !== undefined ? \"cache\" : \"network\";\n\n if (retrievedSnapshot === undefined) {\n retrievedSnapshot = await this.fetchSnapshot(hostSnapshotOptions);\n }\n }\n if (method === \"network\") {\n props.cacheEntryAge = undefined;\n }\n event.end({ ...props, method });\n return retrievedSnapshot;\n },\n );\n\n // Successful call, make network calls only\n this.firstVersionCall = false;\n\n this._snapshotSequenceNumber = odspSnapshotCacheValue.sequenceNumber;\n const { snapshotTree, blobs, ops } = odspSnapshotCacheValue;\n // id should be undefined in case of just ops in snapshot.\n let id: string | undefined;\n if (snapshotTree) {\n id = snapshotTree.id;\n assert(id !== undefined, 0x221 /* \"Root tree should contain the id\" */);\n this.setRootTree(id, snapshotTree);\n }\n if (blobs) {\n this.initBlobsCache(blobs);\n }\n\n this.ops = ops;\n return id ? [{ id, treeId: undefined! }] : [];\n }\n\n return getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"GetVersions\");\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${this.snapshotUrl}/versions?top=${count}`,\n storageToken,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n );\n\n // Fetch the latest snapshot versions for the document\n const response = await PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"getVersions\",\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n },\n async () => this.epochTracker.fetchAndParseAsJSON<IDocumentStorageGetVersionsResponse>(url, { headers }, \"versions\"),\n );\n const versionsResponse = response.content;\n if (!versionsResponse) {\n throw new NonRetryableError(\n \"No response from /versions endpoint\",\n DriverErrorType.genericNetworkError,\n { driverVersion });\n }\n if (!Array.isArray(versionsResponse.value)) {\n throw new NonRetryableError(\n \"Incorrect response from /versions endpoint, expected an array\",\n DriverErrorType.genericNetworkError,\n { driverVersion });\n }\n return versionsResponse.value.map((version) => {\n return {\n id: version.id,\n treeId: undefined!,\n };\n });\n });\n }\n\n private async fetchSnapshot(hostSnapshotOptions: ISnapshotOptions | undefined) {\n return this.fetchSnapshotCore(hostSnapshotOptions).catch((error) => {\n // Issue #5895:\n // If we are offline, this error is retryable. But that means that RetriableDocumentStorageService\n // will run in circles calling getSnapshotTree, which would result in OdspDocumentStorageService class\n // going getVersions / individual blob download path. This path is very slow, and will not work with\n // delay-loaded data stores and ODSP storage deleting old snapshots and blobs.\n if (typeof error === \"object\" && error !== null) {\n error.canRetry = false;\n }\n throw error;\n });\n }\n\n private async fetchSnapshotCore(hostSnapshotOptions: ISnapshotOptions | undefined) {\n const snapshotOptions: ISnapshotOptions = {\n mds: this.maxSnapshotSizeLimit,\n ...hostSnapshotOptions,\n timeout: hostSnapshotOptions?.timeout ? Math.min(hostSnapshotOptions.timeout, this.maxSnapshotFetchTimeout) : this.maxSnapshotFetchTimeout,\n };\n\n // No limit on size of snapshot or time to fetch, as otherwise we fail all clients to summarize\n if (this.hostPolicy.summarizerClient) {\n snapshotOptions.mds = undefined;\n snapshotOptions.timeout = undefined;\n }\n\n const snapshotDownloader = async (\n finalOdspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n options: ISnapshotOptions | undefined,\n controller?: AbortController,\n ) => {\n return downloadSnapshot(\n finalOdspResolvedUrl,\n storageToken,\n this.logger,\n options,\n this.snapshotFormatFetchType,\n controller,\n this.epochTracker,\n );\n };\n const putInCache = async (valueWithEpoch: IVersionedValueWithEpoch) => {\n return this.cache.persistedCache.put(\n createCacheSnapshotKey(this.odspResolvedUrl),\n // Epoch tracker will add the epoch and version to the value here. So just send value to cache.\n valueWithEpoch.value,\n );\n };\n const removeEntries = async () => this.cache.persistedCache.removeEntries();\n try {\n const odspSnapshot = await fetchSnapshotWithRedeem(\n this.odspResolvedUrl,\n this.getStorageToken,\n snapshotOptions,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n this.logger,\n snapshotDownloader,\n putInCache,\n removeEntries,\n this.hostPolicy.enableRedeemFallback,\n );\n return odspSnapshot;\n } catch (error: any) {\n const errorType = error.errorType;\n // If the snapshot size is too big and the host specified the size limitation(specified in hostSnapshotOptions), then don't try to fetch the snapshot again.\n if ((errorType === OdspErrorType.snapshotTooBig && hostSnapshotOptions?.mds !== undefined) && (this.hostPolicy.summarizerClient !== true)) {\n throw error;\n }\n // If the first snapshot request was with blobs and we either timed out or the size was too big, then try to fetch without blobs.\n if ((errorType === OdspErrorType.snapshotTooBig || errorType === OdspErrorType.fetchTimeout) && snapshotOptions.blobs) {\n this.logger.sendErrorEvent({\n eventName: \"TreeLatest_SecondCall\",\n errorType,\n });\n const snapshotOptionsWithoutBlobs: ISnapshotOptions = { ...snapshotOptions, blobs: 0, mds: undefined, timeout: undefined };\n const odspSnapshot = await fetchSnapshotWithRedeem(\n this.odspResolvedUrl,\n this.getStorageToken,\n snapshotOptionsWithoutBlobs,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n this.logger,\n snapshotDownloader,\n putInCache,\n removeEntries,\n this.hostPolicy.enableRedeemFallback,\n );\n return odspSnapshot;\n }\n throw error;\n }\n }\n\n public async write(tree: api.ITree, parents: string[], message: string): Promise<api.IVersion> {\n this.checkSnapshotUrl();\n\n throw new Error(\"Not supported\");\n }\n\n public async uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string> {\n this.checkSnapshotUrl();\n\n // Enable flushing only if we have single commit summary and this is not the initial summary for an empty file\n if (\".protocol\" in summary.tree && context.ackHandle !== undefined) {\n let retry = 0;\n for (;;) {\n const result = await this.flushCallback();\n const seq = result.lastPersistedSequenceNumber;\n if (seq !== undefined && seq >= context.referenceSequenceNumber) {\n break;\n }\n\n retry++;\n if (retry > 3) {\n this.logger.sendErrorEvent({\n eventName: \"FlushFailure\",\n ...result,\n retry,\n referenceSequenceNumber: context.referenceSequenceNumber,\n });\n break;\n }\n\n this.logger.sendPerformanceEvent({\n eventName: \"FlushExtraCall\",\n ...result,\n retry,\n referenceSequenceNumber: context.referenceSequenceNumber,\n });\n\n await delay(1000 * (result.retryAfter ?? 1));\n }\n }\n\n const id = await this.odspSummaryUploadManager.writeSummaryTree(summary, context);\n return id;\n }\n\n public async downloadSummary(commit: api.ISummaryHandle): Promise<api.ISummaryTree> {\n throw new Error(\"Not implemented yet\");\n }\n\n private setRootTree(id: string, tree: api.ISnapshotTree) {\n this.commitCache.set(id, tree);\n }\n\n private initBlobsCache(blobs: Map<string, ArrayBuffer>) {\n this.blobCache.addBlobs(blobs);\n }\n\n private checkSnapshotUrl() {\n if (!this.snapshotUrl) {\n throw new NonRetryableError(\n \"Method failed because no snapshot url was available\",\n DriverErrorType.genericError,\n { driverVersion });\n }\n }\n\n private checkAttachmentPOSTUrl() {\n if (!this.attachmentPOSTUrl) {\n throw new NonRetryableError(\n \"Method failed because no attachment POST url was available\",\n DriverErrorType.genericError,\n { driverVersion });\n }\n }\n\n private checkAttachmentGETUrl() {\n if (!this.attachmentGETUrl) {\n throw new NonRetryableError(\n \"Method failed because no attachment GET url was available\",\n DriverErrorType.genericError,\n { driverVersion });\n }\n }\n\n private async readTree(id: string): Promise<api.ISnapshotTree | null> {\n if (!this.snapshotUrl) {\n return null;\n }\n let tree = this.commitCache.get(id);\n if (!tree) {\n tree = await getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"ReadCommit\");\n const snapshotDownloader = async (url: string, fetchOptions: { [index: string]: any; }) => {\n return this.epochTracker.fetchAndParseAsJSON(\n url,\n fetchOptions,\n \"snapshotTree\",\n );\n };\n const snapshot = await fetchSnapshot(\n this.snapshotUrl!,\n storageToken,\n id,\n this.fetchFullSnapshot,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n this.logger,\n snapshotDownloader,\n );\n let treeId = \"\";\n if (snapshot.snapshotTree) {\n assert(snapshot.snapshotTree.id !== undefined, 0x222 /* \"Root tree should contain the id!!\" */);\n treeId = snapshot.snapshotTree.id;\n this.setRootTree(treeId, snapshot.snapshotTree);\n }\n if (snapshot.blobs) {\n this.initBlobsCache(snapshot.blobs);\n }\n // If the version id doesn't match with the id of the tree, then use the id of first tree which in that case\n // will be the actual id of tree to be fetched.\n return this.commitCache.get(id) ?? this.commitCache.get(treeId);\n });\n }\n\n if (!tree) {\n return null;\n }\n\n return tree;\n }\n\n private combineProtocolAndAppSnapshotTree(\n hierarchicalAppTree: api.ISnapshotTree,\n hierarchicalProtocolTree: api.ISnapshotTree,\n ) {\n const summarySnapshotTree: api.ISnapshotTree = {\n blobs: {\n ...hierarchicalAppTree.blobs,\n },\n trees: {\n ...hierarchicalAppTree.trees,\n // the app tree could have a .protocol\n // in that case we want to server protocol to override it\n \".protocol\": hierarchicalProtocolTree,\n },\n };\n\n return summarySnapshotTree;\n }\n}\n\n/* eslint-enable max-len */\n"]}
|
|
1
|
+
{"version":3,"file":"odspDocumentStorageManager.js","sourceRoot":"","sources":["../src/odspDocumentStorageManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAI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I,CAAC;SACf;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,iCAAiC,CACrC,mBAAsC,EACtC,wBAA2C;QAE3C,MAAM,mBAAmB,GAAsB;YAC3C,KAAK,oBACE,mBAAmB,CAAC,KAAK,CAC/B;YACD,KAAK,kCACE,mBAAmB,CAAC,KAAK;gBAC5B,sCAAsC;gBACtC,yDAAyD;gBACzD,WAAW,EAAE,wBAAwB,GACxC;SACJ,CAAC;QAEF,OAAO,mBAAmB,CAAC;IAC/B,CAAC;CACJ;AAlnBD,gEAknBC;AAED,2BAA2B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n assert,\n delay,\n} from \"@fluidframework/common-utils\";\nimport {\n PerformanceEvent,\n} from \"@fluidframework/telemetry-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport {\n ISummaryContext,\n IDocumentStorageService,\n LoaderCachingPolicy,\n DriverErrorType,\n} from \"@fluidframework/driver-definitions\";\nimport { RateLimiter, NonRetryableError } from \"@fluidframework/driver-utils\";\nimport {\n IOdspResolvedUrl,\n ISnapshotOptions,\n OdspErrorType,\n InstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport {\n IDocumentStorageGetVersionsResponse,\n HostStoragePolicyInternal,\n IVersionedValueWithEpoch,\n ISnapshotCachedEntry,\n} from \"./contracts\";\nimport { downloadSnapshot, fetchSnapshot, fetchSnapshotWithRedeem, SnapshotFormatSupportType } from \"./fetchSnapshot\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { IOdspCache } from \"./odspCache\";\nimport {\n createCacheSnapshotKey,\n getWithRetryForTokenRefresh,\n ISnapshotContents,\n} from \"./odspUtils\";\nimport { defaultCacheExpiryTimeoutMs, EpochTracker } from \"./epochTracker\";\nimport { OdspSummaryUploadManager } from \"./odspSummaryUploadManager\";\nimport { FlushResult } from \"./odspDocumentDeltaConnection\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\nexport const defaultSummarizerCacheExpiryTimeout: number = 60 * 1000; // 60 seconds.\n\n/* eslint-disable max-len */\n\n// An implementation of Promise.race that gives you the winner of the promise race\nasync function promiseRaceWithWinner<T>(promises: Promise<T>[]): Promise<{ index: number; value: T; }> {\n return new Promise((resolve, reject) => {\n promises.forEach((p, index) => {\n p.then((v) => resolve({ index, value: v })).catch(reject);\n });\n });\n}\n\nclass BlobCache {\n // Save the timeout so we can cancel and reschedule it as needed\n private blobCacheTimeout: ReturnType<typeof setTimeout> | undefined;\n // If the defer flag is set when the timeout fires, we'll reschedule rather than clear immediately\n // This deferral approach is used (rather than clearing/resetting the timer) as current calling patterns trigger\n // too many calls to setTimeout/clearTimeout.\n private deferBlobCacheClear: boolean = false;\n\n private readonly _blobCache: Map<string, ArrayBuffer> = new Map();\n\n // Tracks all blob IDs evicted from cache\n private readonly blobsEvicted: Set<string> = new Set();\n\n // Initial time-out to purge data from cache\n // If this time out is very small, then we purge blobs from cache too soon and that results in a lot of\n // requests to storage, which brings down perf and may trip protection limits causing 429s\n private blobCacheTimeoutDuration = 2 * 60 * 1000;\n\n // SPO does not keep old snapshots around for long, so we are running chances of not\n // being able to rehydrate data store / DDS in the future if we purge anything (and with blob de-duping,\n // even if blob read by runtime, it could be read again in the future)\n // So for now, purging is disabled.\n private readonly purgeEnabled = false;\n\n public get value() {\n return this._blobCache;\n }\n\n public addBlobs(blobs: Map<string, ArrayBuffer>) {\n blobs.forEach((value, blobId) => {\n this._blobCache.set(blobId, value);\n });\n // Reset the timer on cache set\n this.scheduleClearBlobsCache();\n }\n\n /**\n * Schedule a timer for clearing the blob cache or defer the current one.\n */\n private scheduleClearBlobsCache() {\n if (this.blobCacheTimeout !== undefined) {\n // If we already have an outstanding timer, just signal that we should defer the clear\n this.deferBlobCacheClear = true;\n } else if (this.purgeEnabled) {\n // If we don't have an outstanding timer, set a timer\n // When the timer runs out, we'll decide whether to proceed with the cache clear or reset the timer\n const clearCacheOrDefer = () => {\n this.blobCacheTimeout = undefined;\n if (this.deferBlobCacheClear) {\n this.deferBlobCacheClear = false;\n this.scheduleClearBlobsCache();\n } else {\n // NOTE: Slightly better algorithm here would be to purge either only big blobs,\n // or sort them by size and purge enough big blobs to leave only 256Kb of small blobs in cache\n // Purging is optimizing memory footprint. But count controls potential number of storage requests\n // We want to optimize both - memory footprint and number of future requests to storage.\n // Note that Container can realize data store or DDS on-demand at any point in time, so we do not\n // control when blobs will be used.\n this._blobCache.forEach((_, blobId) => this.blobsEvicted.add(blobId));\n this._blobCache.clear();\n }\n };\n this.blobCacheTimeout = setTimeout(clearCacheOrDefer, this.blobCacheTimeoutDuration);\n // any future storage reads that get into the cache should be cleared from cache rather quickly -\n // there is not much value in keeping them longer\n this.blobCacheTimeoutDuration = 10 * 1000;\n }\n }\n\n public getBlob(blobId: string) {\n // Reset the timer on attempted cache read\n this.scheduleClearBlobsCache();\n const blobContent = this._blobCache.get(blobId);\n const evicted = this.blobsEvicted.has(blobId);\n return { blobContent, evicted };\n }\n\n public setBlob(blobId: string, blob: ArrayBuffer) {\n // This API is called as result of cache miss and reading blob from storage.\n // Runtime never reads same blob twice.\n // The only reason we may get read request for same blob is blob de-duping in summaries.\n // Note that the bigger the size, the less likely blobs are the same, so there is very little benefit of caching big blobs.\n // Images are the only exception - user may insert same image twice. But we currently do not de-dup them - only snapshot\n // blobs are de-duped.\n const size = blob.byteLength;\n if (size < 256 * 1024) {\n // Reset the timer on cache set\n this.scheduleClearBlobsCache();\n return this._blobCache.set(blobId, blob);\n } else {\n // we evicted it here by not caching.\n this.blobsEvicted.add(blobId);\n }\n }\n}\n\ninterface GetVersionsTelemetryProps {\n cacheEntryAge?: number;\n cacheSummarizerExpired?: boolean;\n}\nexport class OdspDocumentStorageService implements IDocumentStorageService {\n readonly policies = {\n // By default, ODSP tells the container not to prefetch/cache.\n caching: LoaderCachingPolicy.NoCaching,\n\n // ODSP storage works better if it has less number of blobs / edges\n // Runtime creating many small blobs results in sub-optimal perf.\n // 2K seems like the sweat spot:\n // The smaller the number, less blobs we aggregate. Most storages are very likely to have notion\n // of minimal \"cluster\" size, so having small blobs is wasteful\n // At the same time increasing the limit ensure that more blobs with user content are aggregated,\n // reducing possibility for de-duping of same blobs (i.e. .attributes rolled into aggregate blob\n // are not reused across data stores, or even within data store, resulting in duplication of content)\n // Note that duplication of content should not have significant impact for bytes over wire as\n // compression of http payload mostly takes care of it, but it does impact storage size and in-memory sizes.\n minBlobSize: 2048,\n maximumCacheDurationMs: defaultCacheExpiryTimeoutMs,\n };\n\n private readonly commitCache: Map<string, api.ISnapshotTree> = new Map();\n\n private readonly attributesBlobHandles: Set<string> = new Set();\n\n private readonly odspSummaryUploadManager: OdspSummaryUploadManager;\n private _ops: api.ISequencedDocumentMessage[] | undefined;\n\n private firstVersionCall = true;\n private _snapshotSequenceNumber: number | undefined;\n\n private readonly documentId: string;\n private readonly snapshotUrl: string | undefined;\n private readonly attachmentPOSTUrl: string | undefined;\n private readonly attachmentGETUrl: string | undefined;\n // Driver specified limits for snapshot size and time.\n /**\n * NOTE: While commit cfff6e3 added restrictions to prevent large payloads, snapshot failures will continue to\n * happen until blob request throttling is implemented. Until then, as a temporary fix we set arbitrarily large\n * snapshot size and timeout limits so that such failures are unlikely to occur.\n */\n private readonly maxSnapshotSizeLimit = 500000000; // 500 MB\n private readonly maxSnapshotFetchTimeout = 120000; // 2 min\n\n // limits the amount of parallel \"attachment\" blob uploads\n private readonly createBlobRateLimiter = new RateLimiter(1);\n\n private readonly blobCache = new BlobCache();\n\n public set ops(ops: api.ISequencedDocumentMessage[] | undefined) {\n assert(this._ops === undefined, 0x0a5 /* \"Trying to set ops when they are already set!\" */);\n this._ops = ops;\n }\n\n public get ops(): api.ISequencedDocumentMessage[] | undefined {\n return this._ops;\n }\n\n public get snapshotSequenceNumber() {\n return this._snapshotSequenceNumber;\n }\n\n constructor(\n private readonly odspResolvedUrl: IOdspResolvedUrl,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n private readonly logger: ITelemetryLogger,\n private readonly fetchFullSnapshot: boolean,\n private readonly cache: IOdspCache,\n private readonly hostPolicy: HostStoragePolicyInternal,\n private readonly epochTracker: EpochTracker,\n private readonly flushCallback: () => Promise<FlushResult>,\n private readonly snapshotFormatFetchType?: SnapshotFormatSupportType,\n ) {\n this.documentId = this.odspResolvedUrl.hashedDocumentId;\n this.snapshotUrl = this.odspResolvedUrl.endpoints.snapshotStorageUrl;\n this.attachmentPOSTUrl = this.odspResolvedUrl.endpoints.attachmentPOSTStorageUrl;\n this.attachmentGETUrl = this.odspResolvedUrl.endpoints.attachmentGETStorageUrl;\n this.odspSummaryUploadManager = new OdspSummaryUploadManager(\n this.snapshotUrl,\n getStorageToken,\n logger,\n epochTracker,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n );\n }\n\n public get repositoryUrl(): string {\n return \"\";\n }\n\n public async createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse> {\n this.checkAttachmentPOSTUrl();\n\n const response = await getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"CreateBlob\");\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${this.attachmentPOSTUrl}/content`,\n storageToken,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n );\n headers[\"Content-Type\"] = \"application/octet-stream\";\n\n return PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"createBlob\",\n size: file.byteLength,\n waitQueueLength: this.createBlobRateLimiter.waitQueueLength,\n },\n async (event) => {\n const res = await this.createBlobRateLimiter.schedule(async () =>\n this.epochTracker.fetchAndParseAsJSON<api.ICreateBlobResponse>(\n url,\n {\n body: file,\n headers,\n method: \"POST\",\n },\n \"createBlob\",\n ));\n event.end({\n blobId: res.content.id,\n ...res.propsToLog,\n });\n return res;\n },\n );\n });\n\n return response.content;\n }\n\n private async readBlobCore(blobId: string): Promise<ArrayBuffer> {\n const { blobContent, evicted } = this.blobCache.getBlob(blobId);\n let blob = blobContent;\n\n if (blob === undefined) {\n this.checkAttachmentGETUrl();\n\n blob = await getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"GetBlob\");\n const unAuthedUrl = `${this.attachmentGETUrl}/${encodeURIComponent(blobId)}/content`;\n const { url, headers } = getUrlAndHeadersWithAuth(\n unAuthedUrl,\n storageToken,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n );\n\n return PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"readDataBlob\",\n blobId,\n evicted,\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n waitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,\n },\n async (event) => {\n const res = await this.epochTracker.fetchArray(url, { headers }, \"blob\");\n event.end({\n waitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,\n ...res.propsToLog,\n attempts: options.refresh ? 2 : 1,\n });\n const cacheControl = res.headers.get(\"cache-control\");\n if (cacheControl === undefined || !(cacheControl.includes(\"private\") || cacheControl.includes(\"public\"))) {\n this.logger.sendErrorEvent({\n eventName: \"NonCacheableBlob\",\n cacheControl,\n blobId,\n ...res.propsToLog,\n });\n }\n return res.content;\n },\n );\n });\n this.blobCache.setBlob(blobId, blob);\n }\n\n return blob;\n }\n\n public async readBlob(blobId: string): Promise<ArrayBufferLike> {\n return this.readBlobCore(blobId);\n }\n\n public async getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null> {\n if (!this.snapshotUrl) {\n return null;\n }\n\n let id: string;\n if (!version || !version.id) {\n const versions = await this.getVersions(null, 1);\n if (!versions || versions.length === 0) {\n return null;\n }\n id = versions[0].id;\n } else {\n id = version.id;\n }\n\n const snapshotTree = await this.readTree(id);\n if (!snapshotTree) {\n return null;\n }\n\n if (snapshotTree.blobs) {\n const attributesBlob = snapshotTree.blobs.attributes;\n if (attributesBlob) {\n this.attributesBlobHandles.add(attributesBlob);\n }\n }\n\n // When we upload the container snapshot, we upload appTree in \".app\" and protocol tree in \".protocol\"\n // So when we request the snapshot we get \".app\" as tree and not as commit node as in the case just above.\n const appTree = snapshotTree.trees[\".app\"];\n const protocolTree = snapshotTree.trees[\".protocol\"];\n\n return this.combineProtocolAndAppSnapshotTree(appTree, protocolTree);\n }\n\n public async getVersions(blobid: string | null, count: number): Promise<api.IVersion[]> {\n // Regular load workflow uses blobId === documentID to indicate \"latest\".\n if (blobid !== this.documentId && blobid) {\n // FluidFetch & FluidDebugger tools use empty sting to query for versions\n // In such case we need to make a call against SPO to give full picture to the tool.\n // Otherwise, each commit calls getVersions but odsp doesn't have a history for each commit\n // return the blobid as is\n return [\n {\n id: blobid,\n treeId: undefined!,\n },\n ];\n }\n\n // Can't really make a call if we do not have URL\n if (!this.snapshotUrl) {\n return [];\n }\n\n // If count is one, we can use the trees/latest API, which returns the latest version and trees in a single request for better performance\n // Do it only once - we might get more here due to summarizer - it needs only container tree, not full snapshot.\n if (this.firstVersionCall && count === 1 && (blobid === null || blobid === this.documentId)) {\n const hostSnapshotOptions = this.hostPolicy.snapshotOptions;\n const odspSnapshotCacheValue: ISnapshotContents = await PerformanceEvent.timedExecAsync(\n this.logger,\n { eventName: \"ObtainSnapshot\" },\n async (event: PerformanceEvent) => {\n const props: GetVersionsTelemetryProps = {};\n let retrievedSnapshot: ISnapshotContents | undefined;\n // Here's the logic to grab the persistent cache snapshot implemented by the host\n // Epoch tracker is responsible for communicating with the persistent cache, handling epochs and cache versions\n const cachedSnapshotP: Promise<ISnapshotContents | undefined> =\n this.epochTracker.get(createCacheSnapshotKey(this.odspResolvedUrl))\n .then(async (snapshotCachedEntry: ISnapshotCachedEntry) => {\n if (snapshotCachedEntry !== undefined) {\n // If the cached entry does not contain the entry time, then assign it a default of 30 days old.\n const age = Date.now() - (snapshotCachedEntry.cacheEntryTime ??\n (Date.now() - 30 * 24 * 60 * 60 * 1000));\n\n // In order to decrease the number of times we have to execute a snapshot refresh,\n // if this is the summarizer and we have a cache entry but it is past the defaultSummarizerCacheExpiryTimeout,\n // force the network retrieval instead as there might be a more recent snapshot available.\n // See: https://github.com/microsoft/FluidFramework/issues/8995 for additional information.\n if (this.hostPolicy.summarizerClient) {\n if (age > defaultSummarizerCacheExpiryTimeout) {\n props.cacheSummarizerExpired = true;\n return undefined;\n } else {\n props.cacheSummarizerExpired = false;\n }\n }\n\n // Record the cache age\n props.cacheEntryAge = age;\n }\n\n return snapshotCachedEntry;\n });\n\n // Based on the concurrentSnapshotFetch policy:\n // Either retrieve both the network and cache snapshots concurrently and pick the first to return,\n // or grab the cache value and then the network value if the cache value returns undefined.\n let method: string;\n if (this.hostPolicy.concurrentSnapshotFetch && !this.hostPolicy.summarizerClient) {\n const networkSnapshotP = this.fetchSnapshot(hostSnapshotOptions);\n\n // Ensure that failures on both paths are ignored initially.\n // I.e. if cache fails for some reason, we will proceed with network result.\n // And vice versa - if (for example) client is offline and network request fails first, we\n // do want to attempt to succeed with cached data!\n const promiseRaceWinner = await promiseRaceWithWinner([\n cachedSnapshotP.catch(() => undefined),\n networkSnapshotP.catch(() => undefined),\n ]);\n retrievedSnapshot = promiseRaceWinner.value;\n method = promiseRaceWinner.index === 0 ? \"cache\" : \"network\";\n\n if (retrievedSnapshot === undefined) {\n // if network failed -> wait for cache ( then return network failure)\n // If cache returned empty or failed -> wait for network (success of failure)\n if (promiseRaceWinner.index === 1) {\n retrievedSnapshot = await cachedSnapshotP;\n method = \"cache\";\n }\n if (retrievedSnapshot === undefined) {\n retrievedSnapshot = await networkSnapshotP;\n method = \"network\";\n }\n }\n } else {\n // Note: There's a race condition here - another caller may come past the undefined check\n // while the first caller is awaiting later async code in this block.\n\n retrievedSnapshot = await cachedSnapshotP;\n\n method = retrievedSnapshot !== undefined ? \"cache\" : \"network\";\n\n if (retrievedSnapshot === undefined) {\n retrievedSnapshot = await this.fetchSnapshot(hostSnapshotOptions);\n }\n }\n if (method === \"network\") {\n props.cacheEntryAge = undefined;\n }\n event.end({ ...props, method });\n return retrievedSnapshot;\n },\n );\n\n // Successful call, make network calls only\n this.firstVersionCall = false;\n\n this._snapshotSequenceNumber = odspSnapshotCacheValue.sequenceNumber;\n const { snapshotTree, blobs, ops } = odspSnapshotCacheValue;\n // id should be undefined in case of just ops in snapshot.\n let id: string | undefined;\n if (snapshotTree) {\n id = snapshotTree.id;\n assert(id !== undefined, 0x221 /* \"Root tree should contain the id\" */);\n this.setRootTree(id, snapshotTree);\n }\n if (blobs) {\n this.initBlobsCache(blobs);\n }\n\n this.ops = ops;\n return id ? [{ id, treeId: undefined! }] : [];\n }\n\n return getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"GetVersions\");\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${this.snapshotUrl}/versions?top=${count}`,\n storageToken,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n );\n\n // Fetch the latest snapshot versions for the document\n const response = await PerformanceEvent.timedExecAsync(\n this.logger,\n {\n eventName: \"getVersions\",\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n },\n async () => this.epochTracker.fetchAndParseAsJSON<IDocumentStorageGetVersionsResponse>(url, { headers }, \"versions\"),\n );\n const versionsResponse = response.content;\n if (!versionsResponse) {\n throw new NonRetryableError(\n \"No response from /versions endpoint\",\n DriverErrorType.genericNetworkError,\n { driverVersion });\n }\n if (!Array.isArray(versionsResponse.value)) {\n throw new NonRetryableError(\n \"Incorrect response from /versions endpoint, expected an array\",\n DriverErrorType.genericNetworkError,\n { driverVersion });\n }\n return versionsResponse.value.map((version) => {\n return {\n id: version.id,\n treeId: undefined!,\n };\n });\n });\n }\n\n private async fetchSnapshot(hostSnapshotOptions: ISnapshotOptions | undefined) {\n return this.fetchSnapshotCore(hostSnapshotOptions).catch((error) => {\n // Issue #5895:\n // If we are offline, this error is retryable. But that means that RetriableDocumentStorageService\n // will run in circles calling getSnapshotTree, which would result in OdspDocumentStorageService class\n // going getVersions / individual blob download path. This path is very slow, and will not work with\n // delay-loaded data stores and ODSP storage deleting old snapshots and blobs.\n if (typeof error === \"object\" && error !== null) {\n error.canRetry = false;\n }\n throw error;\n });\n }\n\n private async fetchSnapshotCore(hostSnapshotOptions: ISnapshotOptions | undefined) {\n const snapshotOptions: ISnapshotOptions = {\n mds: this.maxSnapshotSizeLimit,\n ...hostSnapshotOptions,\n timeout: hostSnapshotOptions?.timeout ? Math.min(hostSnapshotOptions.timeout, this.maxSnapshotFetchTimeout) : this.maxSnapshotFetchTimeout,\n };\n\n // No limit on size of snapshot or time to fetch, as otherwise we fail all clients to summarize\n if (this.hostPolicy.summarizerClient) {\n snapshotOptions.mds = undefined;\n snapshotOptions.timeout = undefined;\n }\n\n const snapshotDownloader = async (\n finalOdspResolvedUrl: IOdspResolvedUrl,\n storageToken: string,\n options: ISnapshotOptions | undefined,\n controller?: AbortController,\n ) => {\n return downloadSnapshot(\n finalOdspResolvedUrl,\n storageToken,\n this.logger,\n options,\n this.snapshotFormatFetchType,\n controller,\n this.epochTracker,\n );\n };\n const putInCache = async (valueWithEpoch: IVersionedValueWithEpoch) => {\n return this.cache.persistedCache.put(\n createCacheSnapshotKey(this.odspResolvedUrl),\n // Epoch tracker will add the epoch and version to the value here. So just send value to cache.\n valueWithEpoch.value,\n );\n };\n const removeEntries = async () => this.cache.persistedCache.removeEntries();\n try {\n const odspSnapshot = await fetchSnapshotWithRedeem(\n this.odspResolvedUrl,\n this.getStorageToken,\n snapshotOptions,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n this.logger,\n snapshotDownloader,\n putInCache,\n removeEntries,\n this.hostPolicy.enableRedeemFallback,\n );\n return odspSnapshot;\n } catch (error: any) {\n const errorType = error.errorType;\n // If the snapshot size is too big and the host specified the size limitation(specified in hostSnapshotOptions), then don't try to fetch the snapshot again.\n if ((errorType === OdspErrorType.snapshotTooBig && hostSnapshotOptions?.mds !== undefined) && (this.hostPolicy.summarizerClient !== true)) {\n throw error;\n }\n // If the first snapshot request was with blobs and we either timed out or the size was too big, then try to fetch without blobs.\n if ((errorType === OdspErrorType.snapshotTooBig || errorType === OdspErrorType.fetchTimeout) && snapshotOptions.blobs) {\n this.logger.sendErrorEvent({\n eventName: \"TreeLatest_SecondCall\",\n errorType,\n });\n const snapshotOptionsWithoutBlobs: ISnapshotOptions = { ...snapshotOptions, blobs: 0, mds: undefined, timeout: undefined };\n const odspSnapshot = await fetchSnapshotWithRedeem(\n this.odspResolvedUrl,\n this.getStorageToken,\n snapshotOptionsWithoutBlobs,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n this.logger,\n snapshotDownloader,\n putInCache,\n removeEntries,\n this.hostPolicy.enableRedeemFallback,\n );\n return odspSnapshot;\n }\n throw error;\n }\n }\n\n public async uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string> {\n this.checkSnapshotUrl();\n\n // Enable flushing only if we have single commit summary and this is not the initial summary for an empty file\n if (\".protocol\" in summary.tree && context.ackHandle !== undefined) {\n let retry = 0;\n for (;;) {\n const result = await this.flushCallback();\n const seq = result.lastPersistedSequenceNumber;\n if (seq !== undefined && seq >= context.referenceSequenceNumber) {\n break;\n }\n\n retry++;\n if (retry > 3) {\n this.logger.sendErrorEvent({\n eventName: \"FlushFailure\",\n ...result,\n retry,\n referenceSequenceNumber: context.referenceSequenceNumber,\n });\n break;\n }\n\n this.logger.sendPerformanceEvent({\n eventName: \"FlushExtraCall\",\n ...result,\n retry,\n referenceSequenceNumber: context.referenceSequenceNumber,\n });\n\n await delay(1000 * (result.retryAfter ?? 1));\n }\n }\n\n const id = await this.odspSummaryUploadManager.writeSummaryTree(summary, context);\n return id;\n }\n\n public async downloadSummary(commit: api.ISummaryHandle): Promise<api.ISummaryTree> {\n throw new Error(\"Not implemented yet\");\n }\n\n private setRootTree(id: string, tree: api.ISnapshotTree) {\n this.commitCache.set(id, tree);\n }\n\n private initBlobsCache(blobs: Map<string, ArrayBuffer>) {\n this.blobCache.addBlobs(blobs);\n }\n\n private checkSnapshotUrl() {\n if (!this.snapshotUrl) {\n throw new NonRetryableError(\n \"Method failed because no snapshot url was available\",\n DriverErrorType.genericError,\n { driverVersion });\n }\n }\n\n private checkAttachmentPOSTUrl() {\n if (!this.attachmentPOSTUrl) {\n throw new NonRetryableError(\n \"Method failed because no attachment POST url was available\",\n DriverErrorType.genericError,\n { driverVersion });\n }\n }\n\n private checkAttachmentGETUrl() {\n if (!this.attachmentGETUrl) {\n throw new NonRetryableError(\n \"Method failed because no attachment GET url was available\",\n DriverErrorType.genericError,\n { driverVersion });\n }\n }\n\n private async readTree(id: string): Promise<api.ISnapshotTree | null> {\n if (!this.snapshotUrl) {\n return null;\n }\n let tree = this.commitCache.get(id);\n if (!tree) {\n tree = await getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"ReadCommit\");\n const snapshotDownloader = async (url: string, fetchOptions: { [index: string]: any; }) => {\n return this.epochTracker.fetchAndParseAsJSON(\n url,\n fetchOptions,\n \"snapshotTree\",\n );\n };\n const snapshot = await fetchSnapshot(\n this.snapshotUrl!,\n storageToken,\n id,\n this.fetchFullSnapshot,\n !!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n this.logger,\n snapshotDownloader,\n );\n let treeId = \"\";\n if (snapshot.snapshotTree) {\n assert(snapshot.snapshotTree.id !== undefined, 0x222 /* \"Root tree should contain the id!!\" */);\n treeId = snapshot.snapshotTree.id;\n this.setRootTree(treeId, snapshot.snapshotTree);\n }\n if (snapshot.blobs) {\n this.initBlobsCache(snapshot.blobs);\n }\n // If the version id doesn't match with the id of the tree, then use the id of first tree which in that case\n // will be the actual id of tree to be fetched.\n return this.commitCache.get(id) ?? this.commitCache.get(treeId);\n });\n }\n\n if (!tree) {\n return null;\n }\n\n return tree;\n }\n\n private combineProtocolAndAppSnapshotTree(\n hierarchicalAppTree: api.ISnapshotTree,\n hierarchicalProtocolTree: api.ISnapshotTree,\n ) {\n const summarySnapshotTree: api.ISnapshotTree = {\n blobs: {\n ...hierarchicalAppTree.blobs,\n },\n trees: {\n ...hierarchicalAppTree.trees,\n // the app tree could have a .protocol\n // in that case we want to server protocol to override it\n \".protocol\": hierarchicalProtocolTree,\n },\n };\n\n return summarySnapshotTree;\n }\n}\n\n/* eslint-enable max-len */\n"]}
|
|
@@ -8,5 +8,5 @@ import { ISnapshotContents } from "./odspUtils";
|
|
|
8
8
|
* Converts existing IOdspSnapshot to snapshot tree, blob array and ops
|
|
9
9
|
* @param odspSnapshot - snapshot
|
|
10
10
|
*/
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function convertOdspSnapshotToSnapshotTreeAndBlobs(odspSnapshot: IOdspSnapshot): ISnapshotContents;
|
|
12
12
|
//# sourceMappingURL=odspSnapshotParser.d.ts.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.convertOdspSnapshotToSnapshotTreeAndBlobs = void 0;
|
|
8
8
|
const common_utils_1 = require("@fluidframework/common-utils");
|
|
9
9
|
/**
|
|
10
10
|
* Build a tree hierarchy base on a flat tree
|
|
@@ -45,7 +45,7 @@ function buildHierarchy(flatTree) {
|
|
|
45
45
|
* Converts existing IOdspSnapshot to snapshot tree, blob array and ops
|
|
46
46
|
* @param odspSnapshot - snapshot
|
|
47
47
|
*/
|
|
48
|
-
function
|
|
48
|
+
function convertOdspSnapshotToSnapshotTreeAndBlobs(odspSnapshot) {
|
|
49
49
|
var _a, _b;
|
|
50
50
|
const blobsWithBufferContent = new Map();
|
|
51
51
|
if (odspSnapshot.blobs) {
|
|
@@ -63,5 +63,5 @@ function convertOdspSnapshotToSnapsohtTreeAndBlobs(odspSnapshot) {
|
|
|
63
63
|
};
|
|
64
64
|
return val;
|
|
65
65
|
}
|
|
66
|
-
exports.
|
|
66
|
+
exports.convertOdspSnapshotToSnapshotTreeAndBlobs = convertOdspSnapshotToSnapshotTreeAndBlobs;
|
|
67
67
|
//# sourceMappingURL=odspSnapshotParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspSnapshotParser.js","sourceRoot":"","sources":["../src/odspSnapshotParser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsE;AAKtE;;;;;;GAMG;AACH,SAAS,cAAc,CAAC,QAA6B;IACjD,MAAM,MAAM,GAA2C,EAAE,CAAC;IAC1D,2FAA2F;IAC3F,MAAM,IAAI,GAAoB,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACrF,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;IAElB,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,OAAO,EAAE;QAClC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC9C,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;QACjE,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;QAEtD,sGAAsG;QACtG,MAAM,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;QAElC,iCAAiC;QACjC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE;YACvB,MAAM,OAAO,GAAoB;gBAC7B,KAAK,EAAE,EAAE;gBACT,KAAK,EAAE,EAAE;gBACT,OAAO,EAAE,EAAE;gBACX,YAAY,EAAE,KAAK,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AAC;KACtD,CAAC;IACF,OAAO,GAAG,CAAC;AACf,CAAC;AAlBD,8FAkBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, stringToBuffer } from \"@fluidframework/common-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { IOdspSnapshot, IOdspSnapshotCommit, ISnapshotTreeEx } from \"./contracts\";\nimport { ISnapshotContents } from \"./odspUtils\";\n\n/**\n * Build a tree hierarchy base on a flat tree\n *\n * @param flatTree - a flat tree\n * @param blobsShaToPathCache - Map with blobs sha as keys and values as path of the blob.\n * @returns the hierarchical tree\n */\nfunction buildHierarchy(flatTree: IOdspSnapshotCommit): api.ISnapshotTree {\n const lookup: { [path: string]: api.ISnapshotTree; } = {};\n // id is required for root tree as it will be used to determine the version we loaded from.\n const root: ISnapshotTreeEx = { id: flatTree.id, blobs: {}, commits: {}, trees: {} };\n lookup[\"\"] = root;\n\n for (const entry of flatTree.entries) {\n const lastIndex = entry.path.lastIndexOf(\"/\");\n const entryPathDir = entry.path.slice(0, Math.max(0, lastIndex));\n const entryPathBase = entry.path.slice(lastIndex + 1);\n\n // ODSP snapshots are created breadth-first so we can assume we see tree nodes prior to their contents\n const node = lookup[entryPathDir];\n\n // Add in either the blob or tree\n if (entry.type === \"tree\") {\n const newTree: ISnapshotTreeEx = {\n blobs: {},\n trees: {},\n commits: {},\n unreferenced: entry.unreferenced,\n };\n node.trees[decodeURIComponent(entryPathBase)] = newTree;\n lookup[entry.path] = newTree;\n } else if (entry.type === \"blob\") {\n node.blobs[decodeURIComponent(entryPathBase)] = entry.id;\n }\n }\n\n return root;\n}\n\n/**\n * Converts existing IOdspSnapshot to snapshot tree, blob array and ops\n * @param odspSnapshot - snapshot\n */\nexport function
|
|
1
|
+
{"version":3,"file":"odspSnapshotParser.js","sourceRoot":"","sources":["../src/odspSnapshotParser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA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D;KACJ;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAgB,yCAAyC,CACrD,YAA2B;;IAE3B,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC9D,IAAI,YAAY,CAAC,KAAK,EAAE;QACpB,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;;YAChC,IAAA,qBAAM,EAAC,IAAI,CAAC,QAAQ,KAAK,QAAQ,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAC5D,KAAK,CAAC,mCAAmC,CAAC,CAAC;YAC/C,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAA,6BAAc,EAAC,IAAI,CAAC,OAAO,EAAE,MAAA,IAAI,CAAC,QAAQ,mCAAI,MAAM,CAAC,CAAC,CAAC;QAC/F,CAAC,CAAC,CAAC;KACN;IACD,MAAM,GAAG,GAAsB;QAC3B,KAAK,EAAE,sBAAsB;QAC7B,GAAG,EAAE,MAAA,MAAA,YAAY,CAAC,GAAG,0CAAE,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,mCAAI,EAAE;QAC/C,cAAc,EAAE,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,KAAK,CAAC,CAAC,EAAE,cAAc;QACrD,YAAY,EAAE,cAAc,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACtD,CAAC;IACF,OAAO,GAAG,CAAC;AACf,CAAC;AAlBD,8FAkBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, stringToBuffer } from \"@fluidframework/common-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { IOdspSnapshot, IOdspSnapshotCommit, ISnapshotTreeEx } from \"./contracts\";\nimport { ISnapshotContents } from \"./odspUtils\";\n\n/**\n * Build a tree hierarchy base on a flat tree\n *\n * @param flatTree - a flat tree\n * @param blobsShaToPathCache - Map with blobs sha as keys and values as path of the blob.\n * @returns the hierarchical tree\n */\nfunction buildHierarchy(flatTree: IOdspSnapshotCommit): api.ISnapshotTree {\n const lookup: { [path: string]: api.ISnapshotTree; } = {};\n // id is required for root tree as it will be used to determine the version we loaded from.\n const root: ISnapshotTreeEx = { id: flatTree.id, blobs: {}, commits: {}, trees: {} };\n lookup[\"\"] = root;\n\n for (const entry of flatTree.entries) {\n const lastIndex = entry.path.lastIndexOf(\"/\");\n const entryPathDir = entry.path.slice(0, Math.max(0, lastIndex));\n const entryPathBase = entry.path.slice(lastIndex + 1);\n\n // ODSP snapshots are created breadth-first so we can assume we see tree nodes prior to their contents\n const node = lookup[entryPathDir];\n\n // Add in either the blob or tree\n if (entry.type === \"tree\") {\n const newTree: ISnapshotTreeEx = {\n blobs: {},\n trees: {},\n commits: {},\n unreferenced: entry.unreferenced,\n };\n node.trees[decodeURIComponent(entryPathBase)] = newTree;\n lookup[entry.path] = newTree;\n } else if (entry.type === \"blob\") {\n node.blobs[decodeURIComponent(entryPathBase)] = entry.id;\n }\n }\n\n return root;\n}\n\n/**\n * Converts existing IOdspSnapshot to snapshot tree, blob array and ops\n * @param odspSnapshot - snapshot\n */\nexport function convertOdspSnapshotToSnapshotTreeAndBlobs(\n odspSnapshot: IOdspSnapshot,\n): ISnapshotContents {\n const blobsWithBufferContent = new Map<string, ArrayBuffer>();\n if (odspSnapshot.blobs) {\n odspSnapshot.blobs.forEach((blob) => {\n assert(blob.encoding === \"base64\" || blob.encoding === undefined,\n 0x0a4 /* Unexpected blob encoding type */);\n blobsWithBufferContent.set(blob.id, stringToBuffer(blob.content, blob.encoding ?? \"utf8\"));\n });\n }\n const val: ISnapshotContents = {\n blobs: blobsWithBufferContent,\n ops: odspSnapshot.ops?.map((op) => op.op) ?? [],\n sequenceNumber: odspSnapshot?.trees[0].sequenceNumber,\n snapshotTree: buildHierarchy(odspSnapshot.trees[0]),\n };\n return val;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspSummaryUploadManager.d.ts","sourceRoot":"","sources":["../src/odspSummaryUploadManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EAAE,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAU1F,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAM9C;;;GAGG;AACH,qBAAa,wBAAwB;IAM7B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAEhC,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,sCAAsC;IAR3D,OAAO,CAAC,yBAAyB,CAAqB;IACtD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAoB;gBAGlB,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,+BAA+B,EACjE,MAAM,EAAE,gBAAgB,EACP,YAAY,EAAE,YAAY,EAC1B,sCAAsC,EAAE,OAAO;IAKvD,gBAAgB,CAAC,IAAI,EAAE,GAAG,CAAC,YAAY,EAAE,OAAO,EAAE,eAAe;YAqBhE,oBAAoB;
|
|
1
|
+
{"version":3,"file":"odspSummaryUploadManager.d.ts","sourceRoot":"","sources":["../src/odspSummaryUploadManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EAAE,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAU1F,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAM9C;;;GAGG;AACH,qBAAa,wBAAwB;IAM7B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAEhC,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,sCAAsC;IAR3D,OAAO,CAAC,yBAAyB,CAAqB;IACtD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAoB;gBAGlB,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,+BAA+B,EACjE,MAAM,EAAE,gBAAgB,EACP,YAAY,EAAE,YAAY,EAC1B,sCAAsC,EAAE,OAAO;IAKvD,gBAAgB,CAAC,IAAI,EAAE,GAAG,CAAC,YAAY,EAAE,OAAO,EAAE,eAAe;YAqBhE,oBAAoB;IA6DlC;;;;;;;;OAQG;YACW,4BAA4B;CAoG7C"}
|
|
@@ -64,9 +64,7 @@ class OdspSummaryUploadManager {
|
|
|
64
64
|
return id;
|
|
65
65
|
}
|
|
66
66
|
async writeSummaryTreeCore(parentHandle, referenceSequenceNumber, tree) {
|
|
67
|
-
const
|
|
68
|
-
const containsProtocolTree = enableContainerTypeSummaryUpload &&
|
|
69
|
-
Object.keys(tree.tree).includes(".protocol");
|
|
67
|
+
const containsProtocolTree = Object.keys(tree.tree).includes(".protocol");
|
|
70
68
|
const { snapshotTree, blobs } = await this.convertSummaryToSnapshotTree(parentHandle, tree, ".app");
|
|
71
69
|
const snapshot = {
|
|
72
70
|
entries: snapshotTree.entries,
|
|
@@ -94,7 +92,6 @@ class OdspSummaryUploadManager {
|
|
|
94
92
|
size: postBody.length,
|
|
95
93
|
referenceSequenceNumber,
|
|
96
94
|
type: snapshot.type,
|
|
97
|
-
enableContainerTypeSummaryUpload,
|
|
98
95
|
}, async () => {
|
|
99
96
|
const response = await this.epochTracker.fetchAndParseAsJSON(url, {
|
|
100
97
|
body: postBody,
|
|
@@ -1 +1 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YAAY,EAAE,KAAK,EAAE,CAAC;IACnC,CAAC;CACJ;AAjND,4DAiNC;AAED,2BAA2B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, Uint8ArrayToString, unreachableCase } from \"@fluidframework/common-utils\";\nimport { ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { getGitType } from \"@fluidframework/protocol-base\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { loggerToMonitoringContext, MonitoringContext, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n IOdspSummaryPayload,\n IWriteSummaryResponse,\n IOdspSummaryTree,\n IOdspSummaryTreeBaseEntry,\n OdspSummaryTreeEntry,\n OdspSummaryTreeValue,\n} from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { getWithRetryForTokenRefresh } from \"./odspUtils\";\n\n/* eslint-disable max-len */\n\n/**\n * This class manages a summary upload. When it receives a call to upload summary, it converts the summary tree into\n * a snapshot tree and then uploads that to the server.\n */\nexport class OdspSummaryUploadManager {\n // Last proposed handle of the uploaded app summary.\n private lastSummaryProposalHandle: string | undefined;\n private readonly mc: MonitoringContext;\n\n constructor(\n private readonly snapshotUrl: string,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n logger: ITelemetryLogger,\n private readonly epochTracker: EpochTracker,\n private readonly forceAccessTokenViaAuthorizationHeader: boolean,\n ) {\n this.mc = loggerToMonitoringContext(logger);\n }\n\n public async writeSummaryTree(tree: api.ISummaryTree, context: ISummaryContext) {\n // If the last proposed handle is not the proposed handle of the acked summary(could happen when the last summary get nacked),\n // then re-initialize the caches with the previous ones else just update the previous caches with the caches from acked summary.\n // Don't bother logging if lastSummaryProposalHandle hasn't been set before; only log on a positive mismatch.\n if (this.lastSummaryProposalHandle !== undefined &&\n this.lastSummaryProposalHandle !== context.proposalHandle) {\n this.mc.logger.sendTelemetryEvent({\n eventName: \"LastSummaryProposedHandleMismatch\",\n ackedSummaryProposedHandle: context.proposalHandle,\n lastSummaryProposalHandle: this.lastSummaryProposalHandle,\n });\n }\n const result = await this.writeSummaryTreeCore(context.ackHandle, context.referenceSequenceNumber, tree);\n const id = result ? result.id : undefined;\n if (!result || !id) {\n throw new Error(`Failed to write summary tree`);\n }\n this.lastSummaryProposalHandle = id;\n return id;\n }\n\n private async writeSummaryTreeCore(\n parentHandle: string | undefined,\n referenceSequenceNumber: number,\n tree: api.ISummaryTree,\n ): Promise<IWriteSummaryResponse> {\n const enableContainerTypeSummaryUpload = this.mc.config.getBoolean(\"Fluid.Driver.Odsp.EnableContainerTypeSummaryUpload\");\n const containsProtocolTree = enableContainerTypeSummaryUpload &&\n Object.keys(tree.tree).includes(\".protocol\");\n const { snapshotTree, blobs } = await this.convertSummaryToSnapshotTree(\n parentHandle,\n tree,\n \".app\",\n );\n const snapshot: IOdspSummaryPayload = {\n entries: snapshotTree.entries!,\n message: \"app\",\n sequenceNumber: referenceSequenceNumber,\n // no ack handle implies this is initial summary after empty file creation.\n // send container payload so server will use it without a summary op\n type: containsProtocolTree || parentHandle === undefined ? \"container\" : \"channel\",\n };\n\n return getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"WriteSummaryTree\");\n\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${this.snapshotUrl}/snapshot`,\n storageToken,\n this.forceAccessTokenViaAuthorizationHeader,\n );\n headers[\"Content-Type\"] = \"application/json\";\n if (parentHandle) {\n headers[\"If-Match\"] = `fluid:containerid=${parentHandle}`;\n }\n\n const postBody = JSON.stringify(snapshot);\n\n return PerformanceEvent.timedExecAsync(this.mc.logger,\n {\n eventName: \"uploadSummary\",\n attempt: options.refresh ? 2 : 1,\n hasClaims: !!options.claims,\n hasTenantId: !!options.tenantId,\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n blobs,\n size: postBody.length,\n referenceSequenceNumber,\n type: snapshot.type,\n enableContainerTypeSummaryUpload,\n },\n async () => {\n const response = await this.epochTracker.fetchAndParseAsJSON<IWriteSummaryResponse>(\n url,\n {\n body: postBody,\n headers,\n method: \"POST\",\n },\n \"uploadSummary\");\n return response.content;\n });\n });\n }\n\n /**\n * Following are the goals of this function.\n * a.) Converts the summary tree to a snapshot/odsp tree to be uploaded. Always upload full snapshot tree.\n * @param parentHandle - Handle of the last uploaded summary or detach new summary.\n * @param tree - Summary Tree which will be converted to snapshot tree to be uploaded.\n * @param rootNodeName - Root node name of the summary tree.\n * @param path - Current path of node which is getting evaluated.\n * @param markUnreferencedNodes - True if we should mark unreferenced nodes.\n */\n private async convertSummaryToSnapshotTree(\n parentHandle: string | undefined,\n tree: api.ISummaryTree,\n rootNodeName: string,\n markUnreferencedNodes: boolean = this.mc.config.getBoolean(\"Fluid.Driver.Odsp.MarkUnreferencedNodes\") ?? true,\n ) {\n const snapshotTree: IOdspSummaryTree = {\n type: \"tree\",\n entries: [] as OdspSummaryTreeEntry[],\n };\n\n let blobs = 0;\n const keys = Object.keys(tree.tree);\n for (const key of keys) {\n const summaryObject = tree.tree[key];\n\n let id: string | undefined;\n let value: OdspSummaryTreeValue | undefined;\n\n // Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n // property is not present, the tree entry is considered referenced. If the property is present and is\n // true (which is the only value it can have), the tree entry is considered unreferenced.\n let unreferenced: true | undefined;\n switch (summaryObject.type) {\n case api.SummaryType.Tree: {\n const result = await this.convertSummaryToSnapshotTree(\n parentHandle,\n summaryObject,\n rootNodeName);\n value = result.snapshotTree;\n unreferenced = markUnreferencedNodes ? summaryObject.unreferenced : undefined;\n blobs += result.blobs;\n break;\n }\n case api.SummaryType.Blob: {\n if (typeof summaryObject.content === \"string\") {\n value = {\n type: \"blob\",\n content: summaryObject.content,\n encoding: \"utf-8\",\n };\n } else {\n value = {\n type: \"blob\",\n content: Uint8ArrayToString(summaryObject.content, \"base64\"),\n encoding: \"base64\",\n };\n }\n blobs++;\n break;\n }\n case api.SummaryType.Handle: {\n if (!parentHandle) {\n throw Error(\"Parent summary does not exist to reference by handle.\");\n }\n let handlePath = summaryObject.handle;\n if (handlePath.length > 0 && !handlePath.startsWith(\"/\")) {\n handlePath = `/${handlePath}`;\n }\n const pathKey = `${rootNodeName}${handlePath}`;\n id = `${parentHandle}/${pathKey}`;\n break;\n }\n case api.SummaryType.Attachment: {\n id = summaryObject.id;\n break;\n }\n default: {\n unreachableCase(summaryObject, `Unknown type: ${(summaryObject as any).type}`);\n }\n }\n\n const baseEntry: IOdspSummaryTreeBaseEntry = {\n path: encodeURIComponent(key),\n type: getGitType(summaryObject),\n };\n\n let entry: OdspSummaryTreeEntry;\n\n if (value) {\n assert(id === undefined, 0x0ad /* \"Snapshot entry has both a tree value and a referenced id!\" */);\n entry = {\n value,\n ...baseEntry,\n unreferenced,\n };\n } else if (id) {\n entry = {\n ...baseEntry,\n id,\n };\n } else {\n throw new Error(`Invalid tree entry for ${summaryObject.type}`);\n }\n\n snapshotTree.entries!.push(entry);\n }\n\n return { snapshotTree, blobs };\n }\n}\n\n/* eslint-enable max-len */\n"]}
|
|
1
|
+
{"version":3,"file":"odspSummaryUploadManager.js","sourceRoot":"","sources":["../src/odspSummaryUploadManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAGH,+DAA2F;AAE3F,iEAA2D;AAC3D,0EAA4D;AAE5D,qEAAiH;AAUjH,yEAAsE;AACtE,2CAA0D;AAE1D,4BAA4B;AAE5B;;;GAGG;AACH,MAAa,wBAAwB;IAKjC,YACqB,WAAmB,EACnB,eAAgD,EACjE,MAAwB,EACP,YAA0B,EAC1B,sCAA+C;QAJ/C,gBAAW,GAAX,WAAW,CAAQ;QACnB,oBAAe,GAAf,eAAe,CAAiC;QAEhD,iB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C;oBACL,IAAA,8BAAe,EAAC,aAAa,EAAE,iBAAkB,aAAqB,CAAC,IAAI,EAAE,CAAC,CAAC;iBAClF;aACJ;YAED,MAAM,SAAS,GAA8B;gBACzC,IAAI,EAAE,kBAAkB,CAAC,GAAG,CAAC;gBAC7B,IAAI,EAAE,IAAA,0BAAU,EAAC,aAAa,CAAC;aAClC,CAAC;YAEF,IAAI,KAA2B,CAAC;YAEhC,IAAI,KAAK,EAAE;gBACP,IAAA,qBAAM,EAAC,EAAE,KAAK,SAAS,EAAE,KAAK,CAAC,iEAAiE,CAAC,CAAC;gBAClG,KAAK,iCACD,KAAK,IACF,SAAS,KACZ,YAAY,GACf,CAAC;aACL;iBAAM,IAAI,EAAE,EAAE;gBACX,KAAK,mCACE,SAAS,KACZ,EAAE,GACL,CAAC;aACL;iBAAM;gBACH,MAAM,IAAI,KAAK,CAAC,0BAA0B,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;aACnE;YAED,YAAY,CAAC,OAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACrC;QAED,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IACnC,CAAC;CACJ;AA9MD,4DA8MC;AAED,2BAA2B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, Uint8ArrayToString, unreachableCase } from \"@fluidframework/common-utils\";\nimport { ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { getGitType } from \"@fluidframework/protocol-base\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { loggerToMonitoringContext, MonitoringContext, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n IOdspSummaryPayload,\n IWriteSummaryResponse,\n IOdspSummaryTree,\n IOdspSummaryTreeBaseEntry,\n OdspSummaryTreeEntry,\n OdspSummaryTreeValue,\n} from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { getWithRetryForTokenRefresh } from \"./odspUtils\";\n\n/* eslint-disable max-len */\n\n/**\n * This class manages a summary upload. When it receives a call to upload summary, it converts the summary tree into\n * a snapshot tree and then uploads that to the server.\n */\nexport class OdspSummaryUploadManager {\n // Last proposed handle of the uploaded app summary.\n private lastSummaryProposalHandle: string | undefined;\n private readonly mc: MonitoringContext;\n\n constructor(\n private readonly snapshotUrl: string,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n logger: ITelemetryLogger,\n private readonly epochTracker: EpochTracker,\n private readonly forceAccessTokenViaAuthorizationHeader: boolean,\n ) {\n this.mc = loggerToMonitoringContext(logger);\n }\n\n public async writeSummaryTree(tree: api.ISummaryTree, context: ISummaryContext) {\n // If the last proposed handle is not the proposed handle of the acked summary(could happen when the last summary get nacked),\n // then re-initialize the caches with the previous ones else just update the previous caches with the caches from acked summary.\n // Don't bother logging if lastSummaryProposalHandle hasn't been set before; only log on a positive mismatch.\n if (this.lastSummaryProposalHandle !== undefined &&\n this.lastSummaryProposalHandle !== context.proposalHandle) {\n this.mc.logger.sendTelemetryEvent({\n eventName: \"LastSummaryProposedHandleMismatch\",\n ackedSummaryProposedHandle: context.proposalHandle,\n lastSummaryProposalHandle: this.lastSummaryProposalHandle,\n });\n }\n const result = await this.writeSummaryTreeCore(context.ackHandle, context.referenceSequenceNumber, tree);\n const id = result ? result.id : undefined;\n if (!result || !id) {\n throw new Error(`Failed to write summary tree`);\n }\n this.lastSummaryProposalHandle = id;\n return id;\n }\n\n private async writeSummaryTreeCore(\n parentHandle: string | undefined,\n referenceSequenceNumber: number,\n tree: api.ISummaryTree,\n ): Promise<IWriteSummaryResponse> {\n const containsProtocolTree = Object.keys(tree.tree).includes(\".protocol\");\n const { snapshotTree, blobs } = await this.convertSummaryToSnapshotTree(\n parentHandle,\n tree,\n \".app\",\n );\n const snapshot: IOdspSummaryPayload = {\n entries: snapshotTree.entries!,\n message: \"app\",\n sequenceNumber: referenceSequenceNumber,\n // no ack handle implies this is initial summary after empty file creation.\n // send container payload so server will use it without a summary op\n type: containsProtocolTree || parentHandle === undefined ? \"container\" : \"channel\",\n };\n\n return getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"WriteSummaryTree\");\n\n const { url, headers } = getUrlAndHeadersWithAuth(\n `${this.snapshotUrl}/snapshot`,\n storageToken,\n this.forceAccessTokenViaAuthorizationHeader,\n );\n headers[\"Content-Type\"] = \"application/json\";\n if (parentHandle) {\n headers[\"If-Match\"] = `fluid:containerid=${parentHandle}`;\n }\n\n const postBody = JSON.stringify(snapshot);\n\n return PerformanceEvent.timedExecAsync(this.mc.logger,\n {\n eventName: \"uploadSummary\",\n attempt: options.refresh ? 2 : 1,\n hasClaims: !!options.claims,\n hasTenantId: !!options.tenantId,\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n blobs,\n size: postBody.length,\n referenceSequenceNumber,\n type: snapshot.type,\n },\n async () => {\n const response = await this.epochTracker.fetchAndParseAsJSON<IWriteSummaryResponse>(\n url,\n {\n body: postBody,\n headers,\n method: \"POST\",\n },\n \"uploadSummary\");\n return response.content;\n });\n });\n }\n\n /**\n * Following are the goals of this function.\n * a.) Converts the summary tree to a snapshot/odsp tree to be uploaded. Always upload full snapshot tree.\n * @param parentHandle - Handle of the last uploaded summary or detach new summary.\n * @param tree - Summary Tree which will be converted to snapshot tree to be uploaded.\n * @param rootNodeName - Root node name of the summary tree.\n * @param path - Current path of node which is getting evaluated.\n * @param markUnreferencedNodes - True if we should mark unreferenced nodes.\n */\n private async convertSummaryToSnapshotTree(\n parentHandle: string | undefined,\n tree: api.ISummaryTree,\n rootNodeName: string,\n markUnreferencedNodes: boolean = this.mc.config.getBoolean(\"Fluid.Driver.Odsp.MarkUnreferencedNodes\") ?? true,\n ) {\n const snapshotTree: IOdspSummaryTree = {\n type: \"tree\",\n entries: [] as OdspSummaryTreeEntry[],\n };\n\n let blobs = 0;\n const keys = Object.keys(tree.tree);\n for (const key of keys) {\n const summaryObject = tree.tree[key];\n\n let id: string | undefined;\n let value: OdspSummaryTreeValue | undefined;\n\n // Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n // property is not present, the tree entry is considered referenced. If the property is present and is\n // true (which is the only value it can have), the tree entry is considered unreferenced.\n let unreferenced: true | undefined;\n switch (summaryObject.type) {\n case api.SummaryType.Tree: {\n const result = await this.convertSummaryToSnapshotTree(\n parentHandle,\n summaryObject,\n rootNodeName);\n value = result.snapshotTree;\n unreferenced = markUnreferencedNodes ? summaryObject.unreferenced : undefined;\n blobs += result.blobs;\n break;\n }\n case api.SummaryType.Blob: {\n if (typeof summaryObject.content === \"string\") {\n value = {\n type: \"blob\",\n content: summaryObject.content,\n encoding: \"utf-8\",\n };\n } else {\n value = {\n type: \"blob\",\n content: Uint8ArrayToString(summaryObject.content, \"base64\"),\n encoding: \"base64\",\n };\n }\n blobs++;\n break;\n }\n case api.SummaryType.Handle: {\n if (!parentHandle) {\n throw Error(\"Parent summary does not exist to reference by handle.\");\n }\n let handlePath = summaryObject.handle;\n if (handlePath.length > 0 && !handlePath.startsWith(\"/\")) {\n handlePath = `/${handlePath}`;\n }\n const pathKey = `${rootNodeName}${handlePath}`;\n id = `${parentHandle}/${pathKey}`;\n break;\n }\n case api.SummaryType.Attachment: {\n id = summaryObject.id;\n break;\n }\n default: {\n unreachableCase(summaryObject, `Unknown type: ${(summaryObject as any).type}`);\n }\n }\n\n const baseEntry: IOdspSummaryTreeBaseEntry = {\n path: encodeURIComponent(key),\n type: getGitType(summaryObject),\n };\n\n let entry: OdspSummaryTreeEntry;\n\n if (value) {\n assert(id === undefined, 0x0ad /* \"Snapshot entry has both a tree value and a referenced id!\" */);\n entry = {\n value,\n ...baseEntry,\n unreferenced,\n };\n } else if (id) {\n entry = {\n ...baseEntry,\n id,\n };\n } else {\n throw new Error(`Invalid tree entry for ${summaryObject.type}`);\n }\n\n snapshotTree.entries!.push(entry);\n }\n\n return { snapshotTree, blobs };\n }\n}\n\n/* eslint-enable max-len */\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/odsp-driver";
|
|
8
|
-
export declare const pkgVersion = "0.
|
|
8
|
+
export declare const pkgVersion = "1.0.2";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,gCAAgC,CAAC;AACrD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,gCAAgC,CAAC;AACrD,eAAO,MAAM,UAAU,UAAU,CAAC"}
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/odsp-driver";
|
|
11
|
-
exports.pkgVersion = "0.
|
|
11
|
+
exports.pkgVersion = "1.0.2";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,6BAA6B,CAAC;AACxC,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,6BAA6B,CAAC;AACxC,QAAA,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"1.0.2\";\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { IDocumentStorageService, IDocumentStorageServicePolicies, ISummaryContext } from "@fluidframework/driver-definitions";
|
|
6
|
-
import { ICreateBlobResponse, ISnapshotTree, ISummaryHandle, ISummaryTree,
|
|
6
|
+
import { ICreateBlobResponse, ISnapshotTree, ISummaryHandle, ISummaryTree, IVersion } from "@fluidframework/protocol-definitions";
|
|
7
7
|
import { IDisposable, ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
8
8
|
export declare class RetryErrorsStorageAdapter implements IDocumentStorageService, IDisposable {
|
|
9
9
|
private readonly internalStorageService;
|
|
@@ -17,7 +17,6 @@ export declare class RetryErrorsStorageAdapter implements IDocumentStorageServic
|
|
|
17
17
|
getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null>;
|
|
18
18
|
readBlob(id: string): Promise<ArrayBufferLike>;
|
|
19
19
|
getVersions(versionId: string | null, count: number): Promise<IVersion[]>;
|
|
20
|
-
write(tree: ITree, parents: string[], message: string, ref: string): Promise<IVersion>;
|
|
21
20
|
uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string>;
|
|
22
21
|
downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree>;
|
|
23
22
|
createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryErrorsStorageAdapter.d.ts","sourceRoot":"","sources":["../src/retryErrorsStorageAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,uBAAuB,EACvB,+BAA+B,EAC/B,eAAe,EAClB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"retryErrorsStorageAdapter.d.ts","sourceRoot":"","sources":["../src/retryErrorsStorageAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,uBAAuB,EACvB,+BAA+B,EAC/B,eAAe,EAClB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACX,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGnF,qBAAa,yBAA0B,YAAW,uBAAuB,EAAE,WAAW;IAG9E,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAH3B,OAAO,CAAC,SAAS,CAAS;gBAEL,sBAAsB,EAAE,uBAAuB,EAC/C,MAAM,EAAE,gBAAgB;IAI7C,IAAW,QAAQ,IAAI,+BAA+B,GAAG,SAAS,CAEjE;IACD,IAAW,QAAQ,YAA6B;IACzC,OAAO;IAId,IAAW,aAAa,IAAI,MAAM,CAEjC;IAEY,eAAe,CAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAOlE,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAO9C,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAOzE,wBAAwB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ1F,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAO9D,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO5E,OAAO,CAAC,oBAAoB;YAOd,YAAY;CAQ7B"}
|
|
@@ -32,9 +32,6 @@ class RetryErrorsStorageAdapter {
|
|
|
32
32
|
async getVersions(versionId, count) {
|
|
33
33
|
return this.runWithRetry(async () => this.internalStorageService.getVersions(versionId, count), "storage_getVersions");
|
|
34
34
|
}
|
|
35
|
-
async write(tree, parents, message, ref) {
|
|
36
|
-
return this.runWithRetry(async () => this.internalStorageService.write(tree, parents, message, ref), "storage_write");
|
|
37
|
-
}
|
|
38
35
|
async uploadSummaryWithContext(summary, context) {
|
|
39
36
|
// Creation flow with attachment blobs - need to do retries!
|
|
40
37
|
return this.runWithRetry(async () => this.internalStorageService.uploadSummaryWithContext(summary, context), "storage_uploadSummaryWithContext");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryErrorsStorageAdapter.js","sourceRoot":"","sources":["../src/retryErrorsStorageAdapter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAA+D;
|
|
1
|
+
{"version":3,"file":"retryErrorsStorageAdapter.js","sourceRoot":"","sources":["../src/retryErrorsStorageAdapter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAA+D;AAc/D,6CAA4C;AAE5C,MAAa,yBAAyB;IAElC,YACqB,sBAA+C,EAC/C,MAAwB;QADxB,2BAAsB,GAAtB,sBAAsB,CAAyB;QAC/C,WAAM,GAAN,MAAM,CAAkB;QAHrC,cAAS,GAAG,KAAK,CAAC;IAK1B,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAA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IAEM,KAAK,CAAC,UAAU,CAAC,IAAqB;QACzC,OAAO,IAAI,CAAC,YAAY,CACpB,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,IAAI,CAAC,EACxD,oBAAoB,CACvB,CAAC;IACN,CAAC;IAEO,oBAAoB;QACxB,IAAI,IAAI,CAAC,SAAS,EAAE;YAChB,4DAA4D;YAC5D,MAAM,IAAI,8BAAY,CAAC,2CAA2C,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;SAC5F;IACL,CAAC;IAEO,KAAK,CAAC,YAAY,CAAI,GAAqB,EAAE,QAAgB;QACjE,OAAO,IAAA,yBAAY,EACf,GAAG,EACH,QAAQ,EACR,IAAI,CAAC,MAAM,EACX,GAAG,EAAE,CAAC,IAAI,CAAC,oBAAoB,EAAE,CACpC,CAAC;IACN,CAAC;CACJ;AA9ED,8DA8EC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { LoggingError } from \"@fluidframework/telemetry-utils\";\nimport {\n IDocumentStorageService,\n IDocumentStorageServicePolicies,\n ISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n ICreateBlobResponse,\n ISnapshotTree,\n ISummaryHandle,\n ISummaryTree,\n IVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { IDisposable, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { runWithRetry } from \"./retryUtils\";\n\nexport class RetryErrorsStorageAdapter implements IDocumentStorageService, IDisposable {\n private _disposed = false;\n constructor(\n private readonly internalStorageService: IDocumentStorageService,\n private readonly logger: ITelemetryLogger,\n ) {\n }\n\n public get policies(): IDocumentStorageServicePolicies | undefined {\n return this.internalStorageService.policies;\n }\n public get disposed() { return this._disposed; }\n public dispose() {\n this._disposed = true;\n }\n\n public get repositoryUrl(): string {\n return this.internalStorageService.repositoryUrl;\n }\n\n public async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n return this.runWithRetry(\n async () => this.internalStorageService.getSnapshotTree(version),\n \"storage_getSnapshotTree\",\n );\n }\n\n public async readBlob(id: string): Promise<ArrayBufferLike> {\n return this.runWithRetry(\n async () => this.internalStorageService.readBlob(id),\n \"storage_readBlob\",\n );\n }\n\n public async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n return this.runWithRetry(\n async () => this.internalStorageService.getVersions(versionId, count),\n \"storage_getVersions\",\n );\n }\n\n public async uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string> {\n // Creation flow with attachment blobs - need to do retries!\n return this.runWithRetry(\n async () => this.internalStorageService.uploadSummaryWithContext(summary, context),\n \"storage_uploadSummaryWithContext\",\n );\n }\n\n public async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n return this.runWithRetry(\n async () => this.internalStorageService.downloadSummary(handle),\n \"storage_downloadSummary\",\n );\n }\n\n public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n return this.runWithRetry(\n async () => this.internalStorageService.createBlob(file),\n \"storage_createBlob\",\n );\n }\n\n private checkStorageDisposed() {\n if (this._disposed) {\n // pre-0.58 error message: storageServiceDisposedCannotRetry\n throw new LoggingError(\"Storage Service is disposed. Cannot retry\", { canRetry: false });\n }\n }\n\n private async runWithRetry<T>(api: () => Promise<T>, callName: string): Promise<T> {\n return runWithRetry(\n api,\n callName,\n this.logger,\n () => this.checkStorageDisposed(),\n );\n }\n}\n"]}
|
package/dist/retryUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryUtils.d.ts","sourceRoot":"","sources":["../src/retryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAMtE;;GAEG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAChC,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACrB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,gBAAgB,EACxB,aAAa,CAAC,EAAE,MAAM,IAAI,GAC3B,OAAO,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"retryUtils.d.ts","sourceRoot":"","sources":["../src/retryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAMtE;;GAEG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAChC,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACrB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,gBAAgB,EACxB,aAAa,CAAC,EAAE,MAAM,IAAI,GAC3B,OAAO,CAAC,CAAC,CAAC,CAsDZ"}
|
package/dist/retryUtils.js
CHANGED
|
@@ -36,8 +36,8 @@ async function runWithRetry(api, callName, logger, checkDisposed) {
|
|
|
36
36
|
const canRetry = (0, driver_utils_1.canRetryOnError)(error);
|
|
37
37
|
const coherencyError = (error === null || error === void 0 ? void 0 : error[epochTracker_1.Odsp409Error]) === true;
|
|
38
38
|
const serviceReadonlyError = (error === null || error === void 0 ? void 0 : error.errorType) === odsp_driver_definitions_1.OdspErrorType.serviceReadOnly;
|
|
39
|
-
// Retry for 409 coherency errors or serviceReadOnly errors.
|
|
40
|
-
if (!(coherencyError || serviceReadonlyError)) {
|
|
39
|
+
// Retry for retriable 409 coherency errors or serviceReadOnly errors.
|
|
40
|
+
if (!(coherencyError || serviceReadonlyError || canRetry)) {
|
|
41
41
|
throw error;
|
|
42
42
|
}
|
|
43
43
|
// SPO itself does number of retries internally before returning 409 to client.
|
|
@@ -55,7 +55,6 @@ async function runWithRetry(api, callName, logger, checkDisposed) {
|
|
|
55
55
|
error.canRetry = false;
|
|
56
56
|
throw error;
|
|
57
57
|
}
|
|
58
|
-
(0, common_utils_1.assert)(canRetry, 0x24d /* "can retry" */);
|
|
59
58
|
await (0, common_utils_1.delay)(Math.floor(retryAfter));
|
|
60
59
|
retryAfter += retryAfter / 4 * (1 + Math.random());
|
|
61
60
|
lastError = error;
|
package/dist/retryUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryUtils.js","sourceRoot":"","sources":["../src/retryUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+
|
|
1
|
+
{"version":3,"file":"retryUtils.js","sourceRoot":"","sources":["../src/retryUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAkE;AAClE,+DAA+D;AAC/D,qFAAwE;AACxE,iDAA8C;AAE9C;;GAEG;AACI,KAAK,UAAU,YAAY,CAC9B,GAAqB,EACrB,QAAgB,EAChB,MAAwB,EACxB,aAA0B;IAE1B,IAAI,UAAU,GAAG,IAAI,CAAC;IACtB,MAAM,KAAK,GAAG,0BAAW,CAAC,GAAG,EAAE,CAAC;IAChC,IAAI,SAAc,CAAC;IACnB,KAAK,IAAI,QAAQ,GAAG,CAAC,GAAI,QAAQ,EAAE,EAAE;QACjC,IAAI,aAAa,KAAK,SAAS,EAAE;YAC7B,aAAa,EAAE,CAAC;SACnB;QACD,IAAI;YACA,MAAM,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC;YAC3B,IAAI,QAAQ,GAAG,CAAC,EAAE;gBACd,MAAM,CAAC,kBAAkB,CACrB;oBACI,SAAS,EAAE,iBAAiB;oBAC5B,QAAQ;oBACR,QAAQ;oBACR,QAAQ,EAAE,0BAAW,CAAC,GAAG,EAAE,GAAG,KAAK;iBACtC,EACD,SAAS,CAAC,CAAC;aAClB;YACD,OAAO,MAAM,CAAC;SACjB;QAAC,OAAO,KAAU,EAAE;YACjB,MAAM,QAAQ,GAAG,IAAA,8BAAe,EAAC,KAAK,CAAC,CAAC;YAExC,MAAM,cAAc,GAAG,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAG,2BAAY,CAAC,MAAK,IAAI,CAAC;YACtD,MAAM,oBAAoB,GAAG,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,uCAAa,CAAC,eAAe,CAAC;YAChF,sEAAsE;YACtE,IAAI,CAAC,CAAC,cAAc,IAAI,oBAAoB,IAAI,QAAQ,CAAC,EAAE;gBACvD,MAAM,KAAK,CAAC;aACf;YAED,+EAA+E;YAC/E,oFAAoF;YACpF,uEAAuE;YACvE,IAAI,QAAQ,KAAK,CAAC,EAAE;gBAChB,MAAM,CAAC,cAAc,CACjB;oBACI,SAAS,EAAE,cAAc,CAAC,CAAC;wBACvB,8BAA8B,CAAC,CAAC,CAAC,oCAAoC;oBACzE,QAAQ;oBACR,QAAQ;oBACR,QAAQ,EAAE,0BAAW,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,0BAA0B;iBAClE,EACD,KAAK,CAAC,CAAC;gBACX,aAAa;gBACb,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC;gBACvB,MAAM,KAAK,CAAC;aACf;YAED,MAAM,IAAA,oBAAK,EAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;YACpC,UAAU,IAAI,UAAU,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YACnD,SAAS,GAAG,KAAK,CAAC;SACrB;KACJ;AACL,CAAC;AA3DD,oCA2DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { delay, performance } from \"@fluidframework/common-utils\";\nimport { canRetryOnError } from \"@fluidframework/driver-utils\";\nimport { OdspErrorType } from \"@fluidframework/odsp-driver-definitions\";\nimport { Odsp409Error } from \"./epochTracker\";\n\n/**\n * This method retries only for retriable coherency and service read only errors.\n */\nexport async function runWithRetry<T>(\n api: () => Promise<T>,\n callName: string,\n logger: ITelemetryLogger,\n checkDisposed?: () => void,\n): Promise<T> {\n let retryAfter = 1000;\n const start = performance.now();\n let lastError: any;\n for (let attempts = 1; ; attempts++) {\n if (checkDisposed !== undefined) {\n checkDisposed();\n }\n try {\n const result = await api();\n if (attempts > 1) {\n logger.sendTelemetryEvent(\n {\n eventName: \"MultipleRetries\",\n callName,\n attempts,\n duration: performance.now() - start,\n },\n lastError);\n }\n return result;\n } catch (error: any) {\n const canRetry = canRetryOnError(error);\n\n const coherencyError = error?.[Odsp409Error] === true;\n const serviceReadonlyError = error?.errorType === OdspErrorType.serviceReadOnly;\n // Retry for retriable 409 coherency errors or serviceReadOnly errors.\n if (!(coherencyError || serviceReadonlyError || canRetry)) {\n throw error;\n }\n\n // SPO itself does number of retries internally before returning 409 to client.\n // That multiplied to 5 suggests need to reconsider current design, as client spends\n // too much time / bandwidth doing the same thing without any progress.\n if (attempts === 5) {\n logger.sendErrorEvent(\n {\n eventName: coherencyError ?\n \"CoherencyErrorTooManyRetries\" : \"ServiceReadonlyErrorTooManyRetries\",\n callName,\n attempts,\n duration: performance.now() - start, // record total wait time.\n },\n error);\n // Fail hard.\n error.canRetry = false;\n throw error;\n }\n\n await delay(Math.floor(retryAfter));\n retryAfter += retryAfter / 4 * (1 + Math.random());\n lastError = error;\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compactSnapshotParser.d.ts","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAa/C,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAC5C,eAAO,MAAM,kBAAkB,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"compactSnapshotParser.d.ts","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAa/C,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAC5C,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAkGxC;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,UAAU,GAAG,iBAAiB,CAqBlF"}
|