-
Type: Question
-
Resolution: Unresolved
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Sharding
-
Cluster Scalability
For example:
c = t.find( {$or:[
{a:2},
{b:3},
{c:4}]} ).batchSize( 2 );
c.next();
t.remove(
);
assert.eq.automsg( "3", c.itcount() );
The first getmore, caused by itcount(), may happen either before or after the remove if mediated by mongos. The following workaround is currently needed:
c = t.find( {$or:[
{a:2},
{b:3},
{c:4}]} ).batchSize( 2 );
c.next();
t.remove(
);
db.getLastError();
assert.eq.automsg( "3", c.itcount() );
Here is an example logging expected behavior from the above script:
m30001| Mon Apr 25 23:31:42 [conn4] query test.jstests_or5 ntoreturn:2 reslen:102 nreturned:2 0ms
m30001| Mon Apr 25 23:31:42 [conn4] remove test.jstests_or5 query:
0ms
m30001| Mon Apr 25 23:31:42 [conn8] getmore test.jstests_or5 cid:4546250274389464629 ntoreturn:2 getMore: { $or: [
,
{ b: 3.0 },
{ c: 4.0 } ] } bytes:86 nreturned:2 0ms
m30001| Mon Apr 25 23:31:42 [conn8] getmore test.jstests_or5 cid:4546250274389464629 ntoreturn:2 getMore: { $or: [
,
{ b: 3.0 },
{ c: 4.0 }] } bytes:20 nreturned:0 0ms
Here is an example of unexpected behavior that sometimes occurs:
m30001| Mon Apr 25 23:11:51 [conn4] query test.jstests_or5 ntoreturn:2 reslen:102 nreturned:2 0ms
m30001| Mon Apr 25 23:11:51 [conn8] getmore test.jstests_or5 cid:5426795093500586304 ntoreturn:2 getMore: { $or: [
,
{ b: 3.0 },
{ c: 4.0 } ] } bytes:86 nreturned:2 0ms
m30001| Mon Apr 25 23:11:51 [conn8] getmore test.jstests_or5 cid:5426795093500586304 ntoreturn:2 getMore: { $or: [
,
{ b: 3.0 },
{ c: 4.0 } ] } bytes:86 nreturned:2 0ms
m30001| Mon Apr 25 23:11:51 [conn8] getmore test.jstests_or5 cid:5426795093500586304 ntoreturn:2 getMore: { $or: [
,
{ b: 3.0 },
{ c: 4.0 } ] } bytes:20 nreturned:0 0ms
m30001| Mon Apr 25 23:11:51 [conn4] remove test.jstests_or5 query:
0ms
As far as I know there is a single connection from mongo to mongos in these examples, but there seem to be two connections from mongos to mongod and this causes the unexpected operation ordering.