Skip to content

Commit 62eccd4

Browse files
committed
Try to fix when server have heavy loading cache might not update to db properly
1 parent be3aa3b commit 62eccd4

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

lib/history.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ var updater = setInterval(function () {
2727
if (cache.isDirty) {
2828
if (config.debug) logger.info("history updater found dirty history: " + key);
2929
var history = parseHistoryToArray(cache.history);
30+
cache.isDirty = false;
3031
finishUpdateHistory(key, history, function (err, count) {
3132
if (err) return callback(err, null);
3233
if (!count) return callback(null, null);
33-
cache.isDirty = false;
3434
cache.updateAt = Date.now();
3535
return callback(null, null);
3636
});

lib/realtime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ var updater = setInterval(function () {
8484
var note = notes[key];
8585
if (note.server.isDirty) {
8686
if (config.debug) logger.info("updater found dirty note: " + key);
87+
note.server.isDirty = false;
8788
updateNote(note, function(err, _note) {
8889
// handle when note already been clean up
8990
if (!notes[key] || !notes[key].server) return callback(null, null);
@@ -104,7 +105,6 @@ var updater = setInterval(function () {
104105
}
105106
return callback(err, null);
106107
}
107-
note.server.isDirty = false;
108108
note.updatetime = moment(_note.lastchangeAt).valueOf();
109109
emitCheck(note);
110110
return callback(null, null);

0 commit comments

Comments
 (0)