فهرست منبع

Merge pull request #22107 from overleaf/jpa-error-handling

[history-v1] back_fill_file_hash: error handling

GitOrigin-RevId: 2dbf52d015206cf42ca434b1f16221d6e0f2cc2b
Jakob Ackermann 1 سال پیش
والد
کامیت
ed27af11f8

+ 4 - 0
libraries/object-persistor/src/PersistorHelper.js

@@ -140,6 +140,10 @@ async function verifyMd5(persistor, bucket, key, sourceMd5, destMd5 = null) {
 }
 
 function wrapError(error, message, params, ErrorType) {
+  params = {
+    ...params,
+    cause: error,
+  }
   if (
     error instanceof NotFoundError ||
     ['NoSuchKey', 'NotFound', 404, 'AccessDenied', 'ENOENT'].includes(

+ 4 - 2
services/history-v1/storage/scripts/back_fill_file_hash.mjs

@@ -356,7 +356,8 @@ async function processFile(entry, filePath) {
         { err, projectId, fileId, hash, path, attempt },
         'failed to process file, trying again'
       )
-      await setTimeout(RETRY_DELAY_MS)
+      const jitter = Math.random() * RETRY_DELAY_MS
+      await setTimeout(RETRY_DELAY_MS + jitter)
     }
   }
   return await processFileOnce(entry, filePath)
@@ -1000,7 +1001,8 @@ class ProjectContext {
             { err, projectId: this.projectId, attempt },
             'failed to get DEK, trying again'
           )
-          await setTimeout(RETRY_DELAY_MS)
+          const jitter = Math.random() * RETRY_DELAY_MS
+          await setTimeout(RETRY_DELAY_MS + jitter)
         }
       }
     }