Meteor-Community-Packages/Meteor-CollectionFS

When mongoDB split read and write, "find after update" will be wrong

jacky-cyber opened this issue · 2 comments

https://github.com/CollectionFS/Meteor-CollectionFS/blob/45f7288f9c9e4470e15f7ad927a634704064e4da/packages/tempstore/tempStore.js#L294

tracker.update(selector, {$set: setObj});
var temp = tracker.findOne(selector);
if (!temp) {
      FS.debug && console.log('NOT FOUND FROM TEMPSTORE => EXIT (REMOVED)');
      return;
}

// Get updated chunkCount
 var chunkCount = FS.Utility.size(temp.keys);

The chunkCount will be 0.

Hi @ljshj Could you please elaborate? As far as I can tell, there's a return within that if statement, so if temp is empty, it'd never move on to deduce the chunkCount.

@harryadel When "update" is write to mongodb primary node(or write node), the secondary node (or read node)'s data is little later. so I think we should test the return value of "tracker.update" for checking "temp".