From 62eccd48e591fac2774032330ee03a2e60df00b5 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sun, 18 Dec 2016 22:52:30 +0800 Subject: Try to fix when server have heavy loading cache might not update to db properly --- lib/history.js | 2 +- lib/realtime.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/history.js b/lib/history.js index 4a3bbe1e..2723422c 100644 --- a/lib/history.js +++ b/lib/history.js @@ -27,10 +27,10 @@ var updater = setInterval(function () { if (cache.isDirty) { if (config.debug) logger.info("history updater found dirty history: " + key); var history = parseHistoryToArray(cache.history); + cache.isDirty = false; finishUpdateHistory(key, history, function (err, count) { if (err) return callback(err, null); if (!count) return callback(null, null); - cache.isDirty = false; cache.updateAt = Date.now(); return callback(null, null); }); diff --git a/lib/realtime.js b/lib/realtime.js index 0b9e0c77..ed36a24f 100644 --- a/lib/realtime.js +++ b/lib/realtime.js @@ -84,6 +84,7 @@ var updater = setInterval(function () { var note = notes[key]; if (note.server.isDirty) { if (config.debug) logger.info("updater found dirty note: " + key); + note.server.isDirty = false; updateNote(note, function(err, _note) { // handle when note already been clean up if (!notes[key] || !notes[key].server) return callback(null, null); @@ -104,7 +105,6 @@ var updater = setInterval(function () { } return callback(err, null); } - note.server.isDirty = false; note.updatetime = moment(_note.lastchangeAt).valueOf(); emitCheck(note); return callback(null, null); -- cgit v1.2.3