Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #56 from feedhenry/race-condition
Browse files Browse the repository at this point in the history
Fix to cope with race condition with multiple refs for one sync record
  • Loading branch information
wtrocki authored Dec 19, 2019
2 parents 8733af9 + 3ccb1c8 commit b1c7c8a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/storage/dataset-clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ function upsertOrDeleteDatasetRecords(datasetId, datasetClientId, records, cb) {
} else if (op === 'delete') {
//remove the ref
update['$pull'] = {'refs': datasetClientId};
// also set the hash to null to handle race condition when multiple refs associated with single record
update['$set']['hash'] = null;
}
datasetRecordsCol.findOneAndUpdate({uid: record.uid}, update, {upsert: true, returnOriginal: false}, function(err, updated) {
if (err) {
Expand Down

0 comments on commit b1c7c8a

Please sign in to comment.