Open tonybranfort opened 5 years ago
let dups = {};
let limit = 1000;
let nIsDupWithinSecs = 30;
let startNotes_id = ObjectId("5c07e1bcbf328d0005a49212")
let a = db.notes.find({_id: {$lte: startNotes_id}}).sort({_id:-1}).limit(limit).toArray()
let isWithinSecs = (note1, note2, nSecs) => {let secsBetween = Math.abs(note1.createdTS.valueOf() - note2.createdTS.valueOf()); return secsBetween < (nSecs * 1000);}
let fn = (note) => {
let nMatch = a.filter((n) =>
note._id.valueOf() !== n._id.valueOf() &&
note.note === n.note &&
isWithinSecs(note, n, nIsDupWithinSecs)
);
if(nMatch.length > 1) dups[note.note] = {n: nMatch.length};
}
a.forEach(fn)
dups
Only dupes from last 8 months are a few (< 5) duplicates that occurred about 5 months ago. There is one triplicate about the same time and the one that generated this issue that had 17 duplicates. No dupes in last 4 months.
17 dupes on that one client: "createdTS" : ISODate("2018-12-05T14:33:32.472Z")
Looked through logs and no errors or any other issues that would give a hint. Does show the 17 note create requests coming through but they all look "normal" other than being duplicated.
Manually deleted duplicates on that one client. Closing.
Another duplicate found on 12/4/18 for client diazyul0812
3 Notes created 1/19/21 for mimbayr0819
let dups = {};
let limit = 1000; // NOTE - is resource intensive
let nIsDupWithinSecs = 30;
//let startNotes_id = ObjectId.fromDate(ISODate("2021-01-19T12:09:42Z")) // this doesn't work as expect
let startNotes_id = new ObjectId()
let isWithinSecs = (note1, note2, nSecs) => {let secsBetween = Math.abs(note1.createdTS.valueOf() - note2.createdTS.valueOf()); return secsBetween < (nSecs * 1000);}
let fn = (note) => {
let nMatch = a.filter((n) =>
note._id.valueOf() !== n._id.valueOf() &&
note.note === n.note &&
isWithinSecs(note, n, nIsDupWithinSecs)
);
if(nMatch.length > 1) dups[note._id] = {n: nMatch.length, note: note};
}
let a = db.notes.find({_id: {$lte: startNotes_id}}).sort({_id:-1}).limit(limit).toArray()
a.forEach(fn)
dups
A note was duplicated 18 times for one client on 12/5/18. Haven't seen or heard of any other situations like this. Investigate. Client _id : '569d5444024548b509c76ead'