From 9893f18ca500f974fb35ad3fbcb490def322b1e4 Mon Sep 17 00:00:00 2001 From: Eric Mc Sween <5454374+emcsween@users.noreply.github.com> Date: Thu, 6 Feb 2025 09:53:19 -0500 Subject: [PATCH] Merge pull request #23447 from overleaf/em-reduce-validation-error-logs Only log validation errors once per flush GitOrigin-RevId: ee3f656c4c7c09fd7f3ff2462278c9aef81b9bb5 --- .../history-v1/storage/lib/persist_changes.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/services/history-v1/storage/lib/persist_changes.js b/services/history-v1/storage/lib/persist_changes.js index 2ed2742f0c..0b0d8db16b 100644 --- a/services/history-v1/storage/lib/persist_changes.js +++ b/services/history-v1/storage/lib/persist_changes.js @@ -78,6 +78,12 @@ async function persistChanges(projectId, allChanges, limits, clientEndVersion) { let originalEndVersion let changesToPersist + /** + * It's only useful to log validation errors once per flush. When we enforce + * content hash validation, it will stop the flush right away anyway. + */ + let validationErrorLogged = false + limits = limits || {} _.defaults(limits, { changeBucketMinutes: 60, @@ -127,10 +133,13 @@ async function persistChanges(projectId, allChanges, limits, clientEndVersion) { } catch (err) { // Temporary: skip validation errors if (err instanceof InvalidChangeError) { - logger.warn( - { err, projectId }, - 'content snapshot mismatch (ignored)' - ) + if (!validationErrorLogged) { + logger.warn( + { err, projectId }, + 'content snapshot mismatch (ignored)' + ) + validationErrorLogged = true + } } else { throw err }