From 3b602ed93a1e6a3e9ca201fb0e77b600ba3129b0 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Fri, 24 Jan 2025 11:32:12 +0000 Subject: [PATCH] [project-history] log previous error when retrying createBlob operation (#23103) GitOrigin-RevId: ff59d15e93c406e17775e5e4acac1f13da9a7788 --- .../project-history/app/js/BlobManager.js | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/services/project-history/app/js/BlobManager.js b/services/project-history/app/js/BlobManager.js index a6ca8417ca..8f62204ee0 100644 --- a/services/project-history/app/js/BlobManager.js +++ b/services/project-history/app/js/BlobManager.js @@ -1,3 +1,4 @@ +import _ from 'lodash' import async from 'async' import logger from '@overleaf/logger' import OError from '@overleaf/o-error' @@ -37,6 +38,7 @@ export function createBlobsForUpdates( let attempts = 0 // Since we may be creating O(1000) blobs in an update, allow for the // occasional failure to prevent the whole update failing. + let lastErr async.retry( { times: RETRY_ATTEMPTS, @@ -46,14 +48,28 @@ export function createBlobsForUpdates( attempts++ if (attempts > 1) { logger.error( - { projectId, doc: update.doc, file: update.file, attempts }, + { + err: lastErr, + projectId, + historyId, + update: _.pick( + update, + 'doc', + 'file', + 'hash', + 'createdBlob', + 'url' + ), + attempts, + }, 'previous createBlob attempt failed, retrying' ) } // extend the lock for each file because large files may take a long time extendLock(err => { if (err) { - return _cb(OError.tag(err)) + lastErr = OError.tag(err) + return _cb(lastErr) } HistoryStoreManager.createBlobForUpdate( projectId, @@ -61,12 +77,12 @@ export function createBlobsForUpdates( update, (err, hashes) => { if (err) { - OError.tag(err, 'retry: error creating blob', { + lastErr = OError.tag(err, 'retry: error creating blob', { projectId, doc: update.doc, file: update.file, }) - _cb(err) + _cb(lastErr) } else { _cb(null, hashes) }