@julian After the last update to 1.11.2 we have been seeing one of our forum getting pretty slow. Each page load has slowed down a lot (the rest calls too).
e.g https://chatrooms.talkwithstranger.com/api/topic/29181/tell-your-dreams-here/8
It seems that indices are not being created properly. So when I run the 3 commands above, i get stuck on a lot of duplicate errors like mentioned here https://github.com/NodeBB/NodeBB/issues/5265 on line 2
db.objects.createIndex({ _key: 1, value: -1 }, { background: true, unique: true, sparse: true });
I've been able to delete many by using following but the duplicates keep coming.
db.objects.aggregate([
// discard selection criteria, You can remove "$match" section if you want
{ $match: { _key: "tid:38:bookmarks"}
},
{ $group: {
_id: {value: "$value"}, // can be grouped on multiple properties
dups: { "$addToSet": "$_id" },
count: { "$sum": 1 }
}},
{ $match: {
count: { "$gt": 1 } // Duplicates considered as count greater than one
}}
],
{allowDiskUse: true} // For faster processing if set is larger
) // You can display result until this and check duplicates
.forEach(function(doc) {
doc.dups.shift(); // First element skipped for deleting
db.objects.remove({_id : {$in: doc.dups }}); // Delete remaining duplicates
})
I also noticed that when the forum is running the duplicate keys are being created for the same keys even when when they have been deleted.
Result of following is below
db.objects.createIndex({ expireAt: 1 }, { expireAfterSeconds: 0, background: true });
{
"createdCollectionAutomatically" : false,
"numIndexesBefore" : 3.0,
"numIndexesAfter" : 3.0,
"note" : "all indexes already exist",
"ok" : 1.0
}
Bottom line. We're unable to create indices. Any help would be appreciated.