From c707d0b345da315e0b537c3d95ac4fd5b6ac4daa Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Thu, 6 May 2021 17:19:23 +0100 Subject: [PATCH] [RedisManager] block inserting of too large docs into redis --- services/document-updater/app/js/RedisManager.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/document-updater/app/js/RedisManager.js b/services/document-updater/app/js/RedisManager.js index 73d85f60d5..d81c7151b3 100644 --- a/services/document-updater/app/js/RedisManager.js +++ b/services/document-updater/app/js/RedisManager.js @@ -72,6 +72,13 @@ module.exports = RedisManager = { logger.error({ err: error, doc_id, docLines }, error.message) return callback(error) } + // Do a cheap size check on the serialized blob. + if (docLines.length > Settings.max_doc_length) { + const docSize = docLines.length + const err = new Error('blocking doc insert into redis: doc is too large') + logger.error({ project_id, doc_id, err, docSize }, err.message) + return callback(err) + } const docHash = RedisManager._computeHash(docLines) // record bytes sent to redis metrics.summary('redis.docLines', docLines.length, { status: 'set' })