Incorrect sort when viewing the oplog collection

Sergio Maruki shared this problem 6 years ago
Solved

Viewing the oplog collection (Menu > View or SHIFT + Enter) results in an incorrect sort command because the oplog collection does not have the _id field.


db.getCollection("oplog.rs").find({})
   .projection({})
   .sort({_id:-1})
   .limit(50)
This is not a serious problem but the operation get very slow.

Replies (7)

photo
2

Thank you for your feedback.

Opening the collection with the same code template does not solve the problem. For a collection without the _id field, we need another code template.

To avoid slow execution when opening the collection,  you can hold "SHIFT" key to bypass auto-exec when opening "oplog.rs" collection, then comment the ".sort({_id:-1})" line.

photo
1

Hi,

Another problem that I noticed today. My template is configured according to the image, but when I check for currentOp() there is another different operation running.


a520d5cac39cbe9891221a151e76aaa3


db.currentOp({ns: "local.oplog.rs"})
{
        "inprog" : [
                {
                        "host" : "127.0.0.1:27017",
                        "desc" : "conn158947",
                        "connectionId" : 158947,
                        "appName" : "sergio",
                        "active" : true,
                        "currentOpTime" : "2018-12-27T18:35:52.794+0000",
                        "opid" : 675542849,
                        "secs_running" : NumberLong(732),
                        "microsecs_running" : NumberLong(732214376),
                        "op" : "query",
                        "ns" : "local.oplog.rs",
                        "command" : {
                                "find" : "oplog.rs",
                                "filter" : {

                                },
                                "sort" : {
                                        "_id" : -1
                                },
                                "projection" : {

                                },
                                "limit" : 32,
                                "returnKey" : false,
                                "showRecordId" : false,
                                "$readPreference" : {
                                        "mode" : "secondaryPreferred"
                                },
                                "$db" : "local"
                        },
                        "planSummary" : "COLLSCAN",
                }
        ],
        "ok" : 1
}

This happens even by holding the "SHIFT" key.

Thank you!

photo
1

Please turn off auto-complete feature and try it again.

Menu->Options-> Options That May Affect Performance -> Enable Fields/Collection Auto Complete

I noticed that the op's "appName" is "sergio" rather than "NoSQLBooster". It doesn't look like a query generated by NoSQLBooster.

photo
1

I added the "appName" in the NoSQLBooster options.

All options in the menu "Options That May Affect Performance" are disabled.


ef6da004f1e9514b40acf431c568496b


091fc76cc973223988410dc4111f2e67

Thanks!

photo
2

Thank you for you feedback.

We have worked out a test build to try to resolve this issue, please download and give it a try.

Windows: https://s3.mongobooster.com/download/releasesv5/nosqlbooster4mongo-5.0.4-beta.1.exe

photo
1

This version fixed the problem.


Thank you!

photo
2

Resolved in version 5.1.0

Leave a Comment
 
Attach a file