[SERVER-2198] getlasterror works oddly with sharding Created: 09/Dec/10  Updated: 04/Feb/11  Resolved: 04/Feb/11

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: David Mytton Assignee: Kristina Chodorow (Inactive)
Resolution: Duplicate Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

mongos:

Wed Dec 1 16:30:37 /home/david/mongodb/latest/bin/mongos db version v1.7.2-pre-, pdfile version 4.5 starting (--help for usage)
Wed Dec 1 16:30:37 git version: 876dae7981e1ec1141fd1b155429274b83a1f99c
Wed Dec 1 16:30:37 sys info: Linux domU-12-31-39-06-79-A1 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41

mongod:

Wed Nov 10 06:55:56 db version v1.7.3-pre-, pdfile version 4.5
Wed Nov 10 06:55:56 git version: 0ca797e907c62a174a90f48954bb55c09a1ee475
Wed Nov 10 06:55:56 sys info: Linux domU-12-31-39-06-79-A1 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41

PHP Version 5.3.3
mongo driver 1.0.11


Issue Links:
Related
Operating System: ALL
Participants:

 Description   

The PHP remove() method set with safe => true is returning instantly and not outputting any count for the removed docs even though I can see the remove op in db.currentOp()

try
{
$DBMongoConn = new Mongo($config['database']['mongodb']['server']);
}
catch (Exception $e)
{
throw new Exception('MongoDB Error: connection failed: ' . $e->getMessage());
}

$collection = $sdDb->selectCollection('metrics');

try
{
$result = $collection->remove(array('accId' => $account['accountId'], 'tA' => array('$lte' => $deleteTime)), array('safe' => true));
}
catch (Exception $e)
{
die('Query failed (' . _LINE_ . '): ' . $e->getMessage() . "\n");
}

$error = $sdDb->lastError();

$account['accountId'] = int
$deleteTime = MongoDate

$error['err'] is null
$result['n'] is 0

db.currentOp()

{
"opid" : "shard1:418732718",
"active" : true,
"lockType" : "write",
"waitingForLock" : false,
"secs_running" : 124,
"op" : "remove",
"ns" : "sd.processes",
"query" : {
"accId" : 1,
"tA" :

{ "$lte" : ISODate("2010-12-02T09:16:15Z") }

},
"client" : "10.121.12.228:33739",
"desc" : "conn"
},



 Comments   
Comment by Eliot Horowitz (Inactive) [ 04/Feb/11 ]

There were a ton of fixed to getLastError in 1.7.4 and 1.7.5.
This should be fixed.

Comment by Kristina Chodorow (Inactive) [ 09/Dec/10 ]

e.g., removing two elements through mongos:

> db1.foo.bar.count()
2
> db1.foo.bar.remove()
> db1.runCommand(

{getlasterror:1}

)
{
"err" : "unrecognized command: replSetGetStatus",
"code" : 13390,
"n" : 0,
"ok" : 1
}

Generated at Thu Feb 08 02:59:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.