diff --git a/lib/storage/dataset-clients.js b/lib/storage/dataset-clients.js index 2c5b0ae..4e5eefe 100644 --- a/lib/storage/dataset-clients.js +++ b/lib/storage/dataset-clients.js @@ -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) {