[SERVER-1038] mongos count fails Created: 21/Apr/10  Updated: 12/Jul/16  Resolved: 28/Apr/10

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

Type: Bug Priority: Major - P3
Reporter: Kristina Chodorow (Inactive) Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

./mongos --configdb localhost:20000,localhost:20001,localhost:20002
Wed Apr 21 16:46:18 ./mongos db version v1.5.1-pre-, pdfile version 4.5 starting (--help for usage)
Wed Apr 21 16:46:18 git version: 28a303759cf6bc1a0d082939496b959495d74a00
Wed Apr 21 16:46:18 sys info: Linux ubuntu 2.6.31-15-generic #50-Ubuntu SMP Tue Nov 10 14:54:29 UTC 2009 i686 BOOST_LIB_VERSION=1_38


Participants:

 Description   

> db.y.save(

{"regex" : /foo/i}

)
> db.y.save(

{"regex" : /foo/i}

)
> db.y.save(

{"regex" : /foo/i}

)
> db.y.find()

{ "_id" : ObjectId("4bcf6346433ae414cd59caf7"), "regex" : /foo/i } { "_id" : ObjectId("4bcf6350433ae414cd59caf8"), "regex" : /foo/i } { "_id" : ObjectId("4bcf6351433ae414cd59caf9"), "regex" : /foo/i }

> db.runCommand(

{count : "y"}

)
Wed Apr 21 16:43:10 JS Error: uncaught exception: error

{ "$err" : "mongos: assertion s/../util/../util/../db/jsobj.h:1845" }

db log:
Wed Apr 21 16:44:04 Assertion failure isABSONObj() s/../util/../util/../db/jsobj.h 1845
0x80ef6d8 0x80f913d 0x817f5da 0x8142917 0x8172197 0x818626e 0x818c50b 0x8143867 0x80e6b3f 0x327c1d 0xb9f80e 0xaf48de
./mongos(_ZN5mongo12sayDbContextEPKc+0x168) [0x80ef6d8]
./mongos(_ZN5mongo8assertedEPKcS1_j+0xed) [0x80f913d]
./mongos(_ZN5mongo15dbgrid_pub_cmds8CountCmd3runEPKcRNS_7BSONObjERSsRNS_14BSONObjBuilderEb+0x13a) [0x817f5da]
./mongos(_ZN5mongo7Command20runAgainstRegisteredEPKcRNS_7BSONObjERNS_14BSONObjBuilderE+0x727) [0x8142917]
./mongos(_ZN5mongo14SingleStrategy7queryOpERNS_7RequestE+0x387) [0x8172197]
./mongos(_ZN5mongo7Request7processEi+0x27e) [0x818626e]
./mongos(_ZN5mongo21ShardedMessageHandler7processERNS_7MessageEPNS_21AbstractMessagingPortE+0x17b) [0x818c50b]
./mongos(_ZN5mongo3pms9threadRunEv+0xa7) [0x8143867]
./mongos(_ZN5boost6detail11thread_dataIPFvvEE3runEv+0xf) [0x80e6b3f]
/usr/lib/libboost_thread-mt.so.1.38.0(thread_proxy+0x5d) [0x327c1d]
/lib/tls/i686/cmov/libpthread.so.0 [0xb9f80e]
/lib/tls/i686/cmov/libc.so.6(clone+0x5e) [0xaf48de]



 Comments   
Comment by auto [ 28/Apr/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: fix count with no filter SERVER-1038
http://github.com/mongodb/mongo/commit/e3fa699ae4f9a56fba3a5e3e75f4074d7f778136

Comment by Eliot Horowitz (Inactive) [ 28/Apr/10 ]

was able to reproduce the last part

Comment by bvnx [ 28/Apr/10 ]

sorry, I didn't 'watch' the issue after commenting, I'll reproduce in a clean session now – this assumes all fresh setup for both shards and config

it seems it might just be due to missing 'query' property of the object sent to runCommand – I noticed that the PHP driver executes count like that?

this is based off nightly: mongodb-win32-x86_64-2010-04-28

start.bat file:
@echo off

rem config processes
start c:\mongodb\bin\mongod --configsvr --port 27010 --dbpath /data/shard_config/

rem shard processes
start c:\mongodb\bin\mongod --shardsvr --port 27020 --dbpath /data/shard_a/
start c:\mongodb\bin\mongod --shardsvr --port 27030 --dbpath /data/shard_b/

rem router and client
start c:\mongodb\bin\mongos --port 27000 --configdb localhost:27010
start c:\mongodb\bin\mongo localhost:27000/admin


MongoDB shell version: 1.5.1-pre-
url: localhost:27000/admin
connecting to: localhost:27000/admin
type "exit" to exit
type "help" for help
> db.runCommand(

{ addshard: 'localhost:27020', allowLocal: true }

);

{ "added" : "localhost:27020", "ok" : 1 }

> db.runCommand(

{ addshard: 'localhost:27030', allowLocal: true }

);

{ "added" : "localhost:27030", "ok" : 1 }

> db.runCommand(

{ enablesharding: 'shardtest' }

);

{ "ok" : 1 }

> db.runCommand({ shardcollection: 'shardtest.shardable', key:

{ name: 1 }

});

{ "collectionsharded" : "shardtest.shardable", "ok" : 1 }

> db.runCommand(

{ listshards: 1 }

);
{
"shards" : [

{ "_id" : "shard0", "host" : "localhost:27020" }

,

{ "_id" : "shard1", "host" : "localhost:27030" }

],
"ok" : 1
}
> shardtest = db.getSisterDB('shardtest')
shardtest
> shardtest.shardable.count()
0
> shardtest.runCommand(

{ count: 'shardable' }

);
Wed Apr 28 20:03:41 JS Error: uncaught exception: error {
"$err" : "mongos: assertion c:\work\buildslaves\windows_64bit_nightly\mongo\db\../bson/bsoninlines.h:31",
"code" : 0
}
> shardtest.runCommand({ count: 'shardtest.shardable', query: { } });

{ "n" : 0, "ok" : 1 }

> shardtest.shardable.save(

{ name: 'test' }

);
isABSONObj()
> shardtest.shardable.count()
1
> shardtest.runCommand(

{ count: 'shardable' }

);
Wed Apr 28 20:12:49 JS Error: uncaught exception: error {
"$err" : "mongos: assertion c:\work\buildslaves\windows_64bit_nightly\mongo\db\../bson/bsoninlines.h:31",
"code" : 0
> shardtest.runCommand({ count: 'shardable', query: { } });

{ "n" : 1, "ok" : 1 }

mongos console only says, apart from all other normal info:

Wed Apr 28 20:12:49 Assertion failure isABSONObj() c:\work\buildslaves\windows_64bit_nightly\mongo\db\../bson/bsoninlines.h 31

hope that is helpful

Comment by Eliot Horowitz (Inactive) [ 25/Apr/10 ]

what's shardtest?
can you send the whole session?

Comment by Eliot Horowitz (Inactive) [ 25/Apr/10 ]

can you send data, what command, etc...
the more details the better

Comment by bvnx [ 25/Apr/10 ]

mongo
> shardtest.runCommand(

{count:1}

);
Mon Apr 26 07:55:48 trying reconnect to localhost:27017
Mon Apr 26 07:55:48 reconnect localhost:27017 ok
Mon Apr 26 07:55:48 JS Error: uncaught exception: error {
"$err" : "mongos: assertion c:\work\buildslaves\windows_64bit_nightly\mongo\db\../bson/bsoninlines.h:28"

mongos
C:\>mongodb\bin\mongos.exe --configdb localhost:27019 --vvvvv
Mon Apr 26 07:55:34 mongodb\bin\mongos.exe db version v1.5.1-pre-, pdfile version 4.5 starting (--help for usage)
Mon Apr 26 07:55:34 git version: 452e5c21ea7e321b38f51dad1e9fad24faac94cc
Mon Apr 26 07:55:34 sys info: windows (6, 0, 6002, 2, 'Service Pack 2') BOOST_LIB_VERSION=1_39
Mon Apr 26 07:55:34 config string : localhost:27019
Mon Apr 26 07:55:34 creating new connection for pool to:localhost:27019
Mon Apr 26 07:55:34 MaxChunkSize: value: 235
Mon Apr 26 07:55:34 balancer myid: G-PC:27017
Mon Apr 26 07:55:34 waiting for connections on port 27017
Mon Apr 26 07:55:48 connection accepted from 127.0.0.1:55046 #1
Mon Apr 26 07:55:48 DBConfig unserialize: shardtest { _id: "shardtest", partitioned: true, primary: "localhost:27020", sharded: { shardtest.products: { key:

{ name:en: 1 }

, unique: false } } }
Mon Apr 26 07:55:48 Request::process ns: shardtest.$cmd msg id:-966605210 attempt: 0
Mon Apr 26 07:55:48 single query: shardtest.$cmd

{ count: 1.0 }

ntoreturn: -1
Mon Apr 26 07:55:48 Assertion failure isABSONObj() c:\work\buildslaves\windows_64bit_nightly\mongo\db\../bson/bsoninlines.h 28

Under Windows, without a build environment, I'm unsure how to provide more in-depth info, such as a stacktrace.

Notably though, a .count() on the DBCollection object works OK.

Comment by Eliot Horowitz (Inactive) [ 21/Apr/10 ]

can't reproduce this, and did exactly what you have.
if you can reproduce that would help

Comment by auto [ 21/Apr/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: count test for SERVER-1038
http://github.com/mongodb/mongo/commit/835c65adc298dde1b311d6346f914f9c60e4a71e

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