From aa013f0bee14441462fc9a8fe372c9abe5b23b7d Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 16 Aug 2018 11:13:11 +0100 Subject: [PATCH 1/2] limit parallel resync doc requests to web --- services/document-updater/app/coffee/HistoryManager.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/document-updater/app/coffee/HistoryManager.coffee b/services/document-updater/app/coffee/HistoryManager.coffee index 9d39166681..802d944ced 100644 --- a/services/document-updater/app/coffee/HistoryManager.coffee +++ b/services/document-updater/app/coffee/HistoryManager.coffee @@ -65,10 +65,12 @@ module.exports = HistoryManager = newBlock = Math.floor(length / threshold) return newBlock != prevBlock + MAX_PARALLEL_REQUESTS: 4 + resyncProjectHistory: (project_id, projectHistoryId, docs, files, callback) -> ProjectHistoryRedisManager.queueResyncProjectStructure project_id, projectHistoryId, docs, files, (error) -> return callback(error) if error? DocumentManager = require "./DocumentManager" resyncDoc = (doc, cb) -> DocumentManager.resyncDocContentsWithLock project_id, doc.doc, cb - async.each docs, resyncDoc, callback + async.eachLimit docs, HistoryManager.MAX_PARALLEL_REQUESTS, resyncDoc, callback From 910b27357da6995c890c3b42a44837aae6d1f32f Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 16 Aug 2018 11:14:11 +0100 Subject: [PATCH 2/2] add more logging to resync operations --- .../document-updater/app/coffee/DocumentManager.coffee | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/document-updater/app/coffee/DocumentManager.coffee b/services/document-updater/app/coffee/DocumentManager.coffee index 0c50d9b1f3..39713a1981 100644 --- a/services/document-updater/app/coffee/DocumentManager.coffee +++ b/services/document-updater/app/coffee/DocumentManager.coffee @@ -181,14 +181,19 @@ module.exports = DocumentManager = callback(null, lines, version) resyncDocContents: (project_id, doc_id, callback) -> + logger.log {project_id: project_id, doc_id: doc_id}, "start resyncing doc contents" RedisManager.getDoc project_id, doc_id, (error, lines, version, ranges, pathname, projectHistoryId) -> return callback(error) if error? if !lines? or !version? + logger.log {project_id: project_id, doc_id: doc_id}, "resyncing doc contents - not found in redis - retrieving from web" PersistenceManager.getDoc project_id, doc_id, (error, lines, version, ranges, pathname, projectHistoryId) -> - return callback(error) if error? + if error? + logger.error {project_id: project_id, doc_id: doc_id, getDocError: error}, "resyncing doc contents - error retrieving from web" + return callback(error) ProjectHistoryRedisManager.queueResyncDocContent project_id, projectHistoryId, doc_id, lines, version, pathname, callback else + logger.log {project_id: project_id, doc_id: doc_id}, "resyncing doc contents - doc in redis - will queue in redis" ProjectHistoryRedisManager.queueResyncDocContent project_id, projectHistoryId, doc_id, lines, version, pathname, callback getDocWithLock: (project_id, doc_id, callback = (error, lines, version) ->) ->