[SERVER-4267] getLastError "n" is 0 if previous writes goes through writebackListener Created: 11/Nov/11  Updated: 13/Dec/12  Resolved: 14/Apr/12

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

Type: Bug Priority: Minor - P4
Reporter: Scott Hernandez (Inactive) Assignee: Scott Hernandez (Inactive)
Resolution: Duplicate Votes: 1
Labels: writeback
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-5243 mongos will route getLastError comman... Closed
Operating System: ALL
Participants:

 Description   

If a write hits the wrong shard, immediately after a migrate, and has to go through the writebackListener then the getLastError call returns n:0.

We should indicate a special state (writeback:true, or n:-1, or something) if we can't correctly report the "n" value.



 Comments   
Comment by Scott Hernandez (Inactive) [ 14/Apr/12 ]

Probably a dup of SERVER-5243

Comment by Matthew Barlocker [ 19/Dec/11 ]

We weren't doing anything fancy.

$mongo = new Mongo();
$lucid = $mongo->lucid;

$document = array('_id' => 'unique id', 'state' => 'another string', 'pdf' => 'more');
$lucid->documents->save($document, array('safe' => 2));

$err = $lucid->lastError();
return $err['n'] === 1;

Comment by Scott Hernandez (Inactive) [ 16/Nov/11 ]

Matthew, do you have tests you can attach?

Comment by Eliot Horowitz (Inactive) [ 12/Nov/11 ]

@scott - do you have a case?
there are tests for exactly this case.

Comment by Matthew Barlocker [ 12/Nov/11 ]

I've had instances where inserting a single record into a sharded database will return n:2. This could be related.

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