diff --git a/services/document-updater/app/coffee/RedisManager.coffee b/services/document-updater/app/coffee/RedisManager.coffee index 700df0a4a3..d822f4ef74 100644 --- a/services/document-updater/app/coffee/RedisManager.coffee +++ b/services/document-updater/app/coffee/RedisManager.coffee @@ -32,7 +32,9 @@ module.exports = RedisManager = _callback(error) docLines = JSON.stringify(docLines) if docLines.indexOf("\u0000") != -1 - return callback(new Error("null bytes found in doc lines")) + error = new Error("null bytes found in doc lines") + logger.error err: error, doc_id: doc_id, docLines: docLines, error.message + return callback(error) docHash = RedisManager._computeHash(docLines) logger.log project_id:project_id, doc_id:doc_id, version: version, hash:docHash, "putting doc in redis" ranges = RedisManager._serializeRanges(ranges) @@ -150,12 +152,18 @@ module.exports = RedisManager = error = new Error("Version mismatch. '#{doc_id}' is corrupted.") logger.error {err: error, doc_id, currentVersion, newVersion, opsLength: appliedOps.length}, "version mismatch" return callback(error) + jsonOps = appliedOps.map (op) -> JSON.stringify op - multi = rclient.multi() newDocLines = JSON.stringify(docLines) if newDocLines.indexOf("\u0000") != -1 - return callback(new Error("null bytes found in doc lines")) + error = new Error("null bytes found in doc lines") + logger.error err: error, doc_id: doc_id, newDocLines: newDocLines, error.message + return callback(error) newHash = RedisManager._computeHash(newDocLines) + + logger.log doc_id: doc_id, version: newVersion, hash: newHash, "updating doc in redis" + + multi = rclient.multi() multi.eval setScript, 1, keys.docLines(doc_id:doc_id), newDocLines multi.set keys.docVersion(doc_id:doc_id), newVersion multi.set keys.docHash(doc_id:doc_id), newHash diff --git a/services/document-updater/app/coffee/UpdateManager.coffee b/services/document-updater/app/coffee/UpdateManager.coffee index 89f58bfd1f..2ad3281bfe 100644 --- a/services/document-updater/app/coffee/UpdateManager.coffee +++ b/services/document-updater/app/coffee/UpdateManager.coffee @@ -61,7 +61,6 @@ module.exports = UpdateManager = return callback(error) if error? RangesManager.applyUpdate project_id, doc_id, ranges, appliedOps, (error, new_ranges) -> return callback(error) if error? - logger.log doc_id: doc_id, version: version, "updating doc in redis" RedisManager.updateDocument doc_id, updatedDocLines, version, appliedOps, new_ranges, (error) -> return callback(error) if error? HistoryManager.pushUncompressedHistoryOps project_id, doc_id, appliedOps, callback diff --git a/services/document-updater/test/unit/coffee/RedisManager/RedisManagerTests.coffee b/services/document-updater/test/unit/coffee/RedisManager/RedisManagerTests.coffee index 0050bd119b..abc7307c15 100644 --- a/services/document-updater/test/unit/coffee/RedisManager/RedisManagerTests.coffee +++ b/services/document-updater/test/unit/coffee/RedisManager/RedisManagerTests.coffee @@ -331,6 +331,9 @@ describe "RedisManager", -> afterEach -> @JSON.stringify = @_stringify + + it "should log an error", -> + @logger.error.called.should.equal true it "should call the callback with an error", -> @callback.calledWith(new Error("null bytes found in doc lines")).should.equal true @@ -416,6 +419,9 @@ describe "RedisManager", -> afterEach -> @JSON.stringify = @_stringify + + it "should log an error", -> + @logger.error.called.should.equal true it "should call the callback with an error", -> @callback.calledWith(new Error("null bytes found in doc lines")).should.equal true