[SERVER-13029] "n" field in GLE following write command doesnt match command output Created: 04/Mar/14  Updated: 19/May/14  Resolved: 05/Mar/14

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 2.6.0-rc0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Mathias Stearn Assignee: Greg Studer
Resolution: Won't Fix Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Operating System: ALL
Participants:

 Description   

Insert seems to always report n=0. Update and delete seem to make it match the last op. This differs from how the upserted field is handled.

> [db.foo.runCommand('update', {updates:[{q:{_id:1}, u:{an: 'object'}, upsert:true}, {q:{_id:2}, u:{an: 'object'}, upsert:true}]}), db.getLastErrorObj()]
[
        {
                "ok" : 1,
                "nModified" : 0,
                "n" : 2,
                "upserted" : [
                        {
                                "index" : 0,
                                "_id" : 1
                        },
                        {
                                "index" : 1,
                                "_id" : 2
                        }
                ]
        },
        {
                "connectionId" : 2,
                "updatedExisting" : false,
                "upserted" : 2,
                "n" : 1,
                "syncMillis" : 0,
                "writtenTo" : null,
                "err" : null,
                "ok" : 1
        }
]
> [db.foo.runCommand('insert', {documents:[{},{}]}), db.getLastErrorObj()]
[
        {
                "ok" : 1,
                "n" : 2
        },
        {
                "connectionId" : 2,
                "n" : 0,
                "syncMillis" : 0,
                "writtenTo" : null,
                "err" : null,
                "ok" : 1
        }
]
> [db.foo.runCommand('delete', {deletes:[{q:{}, limit:1},{q:{}, limit:0}]}), db.getLastErrorObj()]
[
        {
                "ok" : 1,
                "n" : 4
        },
        {
                "connectionId" : 2,
                "n" : 3,
                "syncMillis" : 0,
                "writtenTo" : null,
                "err" : null,
                "ok" : 1
        }
]
 



 Comments   
Comment by Greg Studer [ 05/Mar/14 ]

Leaving this way for older scripts - we may revisit reporting of bulk update stats elsewhere as discussed.

Comment by Greg Studer [ 05/Mar/14 ]

Insert and GLE always reported n : 0:
In 2.4:

> db.coll.insert(

{ x : 1 }

)
> db.getLastErrorObj()

{ "n" : 0, "connectionId" : 3, "err" : null, "ok" : 1 }

This behavior didn't change, are we missing something?

Generated at Thu Feb 08 03:30:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.