From 168bab696068b382ea5853ed6029a681b4304112 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Wed, 22 Feb 2017 14:32:51 +0000 Subject: [PATCH] make hash error logging fine grained --- services/document-updater/app/coffee/RedisManager.coffee | 8 +++++--- .../unit/coffee/RedisManager/RedisManagerTests.coffee | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/services/document-updater/app/coffee/RedisManager.coffee b/services/document-updater/app/coffee/RedisManager.coffee index 7a2d9c39e6..1eef4971e7 100644 --- a/services/document-updater/app/coffee/RedisManager.coffee +++ b/services/document-updater/app/coffee/RedisManager.coffee @@ -19,6 +19,8 @@ setScript = """ """ logHashErrors = Settings.documentupdater?.logHashErrors +logHashReadErrors = logHashErrors?.read +logHashWriteErrors = logHashErrors?.write module.exports = RedisManager = rclient: rclient @@ -45,7 +47,7 @@ module.exports = RedisManager = return callback(error) if error? # check the hash computed on the redis server writeHash = result?[0] - if logHashErrors and writeHash? and writeHash isnt docHash + if logHashWriteErrors and writeHash? and writeHash isnt docHash logger.error project_id: project_id, doc_id: doc_id, writeHash: writeHash, origHash: docHash, "hash mismatch on putDocInMemory" # update docsInProject set rclient.sadd keys.docsInProject(project_id:project_id), doc_id, callback @@ -85,7 +87,7 @@ module.exports = RedisManager = # check sha1 hash value if present if docLines? and storedHash? computedHash = RedisManager._computeHash(docLines) - if logHashErrors and computedHash isnt storedHash + if logHashReadErrors and computedHash isnt storedHash logger.error project_id: project_id, doc_id: doc_id, doc_project_id: doc_project_id, computedHash: computedHash, storedHash: storedHash, "hash mismatch on retrieved document" try @@ -166,7 +168,7 @@ module.exports = RedisManager = return callback(error) if error? # check the hash computed on the redis server writeHash = result?[0] - if logHashErrors and writeHash? and writeHash isnt newHash + if logHashWriteErrors and writeHash? and writeHash isnt newHash logger.error doc_id: doc_id, writeHash: writeHash, origHash: newHash, "hash mismatch on updateDocument" return callback() diff --git a/services/document-updater/test/unit/coffee/RedisManager/RedisManagerTests.coffee b/services/document-updater/test/unit/coffee/RedisManager/RedisManagerTests.coffee index c61cfddfc7..3e3128324e 100644 --- a/services/document-updater/test/unit/coffee/RedisManager/RedisManagerTests.coffee +++ b/services/document-updater/test/unit/coffee/RedisManager/RedisManagerTests.coffee @@ -26,7 +26,7 @@ describe "RedisManager", -> docsInProject: ({project_id}) -> "DocsIn:#{project_id}" ranges: ({doc_id}) -> "Ranges:#{doc_id}" "logger-sharelatex": @logger = { error: sinon.stub(), log: sinon.stub(), warn: sinon.stub() } - "settings-sharelatex": {documentupdater: {logHashErrors: true}} + "settings-sharelatex": {documentupdater: {logHashErrors: {write:true, read:true}}} "./Metrics": @metrics = inc: sinon.stub() Timer: class Timer