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

Race condition improved #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/storage/dataset-clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ function upsertOrDeleteDatasetRecords(datasetId, datasetClientId, records, cb) {
} else if (op === 'delete') {
//remove the ref
update['$pull'] = {'refs': datasetClientId};
if(datasetClientId && datasetClientId.length !==0){
Copy link
Member Author

@wtrocki wtrocki Dec 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this is still quite bad. Technically we should be

A) Removing an item if there is no other ref
B) Removing just ref if there are other refs

Not sure if that is not going to cause and side issues

// Remove set data to null as there are other refs already linked
delete update['$set'].data;
}
}
datasetRecordsCol.findOneAndUpdate({uid: record.uid}, update, {upsert: true, returnOriginal: false}, function(err, updated) {
if (err) {
Expand Down